先下载数据
from xtquant import xtdata
# 取数据前请确保已下载所需要的财务数据
stock_list = ['000001.SZ', '600519.SH', '430017.BJ']
table_list = ['Balance', 'Income', 'CashFlow', 'Capital', 'Holdernum', 'Top10holder', 'Top10flowholder', 'Pershareindex']
def on_progress(data):
print(data)
xtdata.download_financial_data2(stock_list, table_list=table_list, callback=on_progress)
再获得数据
dd = xtdata.get_financial_data(stock_list,table_list)
print(len(dd))
from tqdm import tqdm
for d_stock in tqdm(dd):
d_balance = dd[d_stock]['Balance']
d_income = dd[d_stock]['Income']
d_cashflow = dd[d_stock]['CashFlow']
d_balance.to_csv(f'{d_stock}_balance.csv')
d_income.to_csv(f'{d_stock}_income.csv')
d_cashflow.to_csv(f'{d_stock}_cashflow.csv')
可以去相关安装目录看是否数据下载成功,我的目录是C:\国金证券QMT交易端\userdata_mini\datadir\Finance
Leave a Reply