Tusahre注册链接 https://tushare.pro/register?reg=365850
import os
import tushare as ts
import pandas
import datetimetoken = '自己的'
#可以登录文章首的链接注册获取
pro = ts.pro_api(token)
dateToday = datetime.datetime.today().strftime('%Y%m%d')def GetList():try:data = pro.stock_basic(exchange='SSE', list_status='L', fields='ts_code,symbol,name,area,industry,list_date')#上交所exchange='SSE' 交易所 SSE上交所 SZSE深交所 BSE北交所filelist = 'D:\PycharmProjects\Liang-huajiaoyi\A-Data\LIST\Tickerlist.csv'list = data.ts_codeif os.path.exists(filelist)==True:history = pandas.read_csv(filelist, index_col=0)list.append(filelist)elif os.path.exists(filelist)==False:list.to_csv(filelist)list.to_csv(filelist,index=None)except:passif __name__ == '__main__':GetList()
数据样例:
当然也可以修改参数获得更详细的信息
更详细的信息可以去Tushare的社区找
https://tushare.pro/register?reg=365850
以后会不定期更新一些关于量化交易的文章,如果感兴趣或者有什么不清楚的话可以关注交流一下