当前位置:网站首页>[Python] read the daily market of a certain stock through tushare library and draw the closing value

[Python] read the daily market of a certain stock through tushare library and draw the closing value

2020-11-10 19:24:09 AI_Ruler

First install tushare And other libraries ( I use it pip install )

import pandas as pd
import tushare as ts
import matplotlib.pyplot as plt
#tushare Interface , Find it on your website , Here I'm blocking my 
TOKEN = 'd8549e5bf7xxxxxxxxxxxxxxxxxxx7909a3f5e997859bb3d3'
pro = ts.pro_api(token=TOKEN)
# Reading data 
df = pro.daily(ts_code = '600666.SH',start_date = '20080101')
# Convert to date type 
df['trade_date'] = pd.to_datetime(df['trade_date'], format="%Y%m%d")
# mapping 
plt.plot(df['trade_date'], df['close'], '-', label = df.ts_code[0])
plt.gcf().autofmt_xdate()
# According to the text 
plt.legend()
# display picture 
plt.show()

My registration link :tushare Register link

版权声明
本文为[AI_Ruler]所创,转载请带上原文链接,感谢