Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def futures_xgx_index(
symbol: str = 67,
start_date: str = "2000-10-01",
end_date: str = "2020-04-17",
plot: bool = True,
) -> pd.DataFrame:
session = _get_code_pic()
value = input()
payload = {"txtStartTime": start_date, "txtEndTime": end_date, "txtyzcode": value}
res = session.post(xgx_main_url.format(symbol), data=payload, headers=xgx_headers)
soup = BeautifulSoup(res.text, "lxml")
table_df = pd.read_html(res.text)[0]
table_df.index = pd.to_datetime(table_df["日期"])
del table_df["日期"]
if plot:
table_df["值"].plot()
plt.title(
soup.find("div", attrs={"class": "commodity_right"}).find("h5").get_text()
)
plt.xlabel("日期")
plt.ylabel("值")
plt.show()
return table_df
else:
return table_df