文章声明:本内容为个人的业余研究,和任何单位,机构没有关系,文章出现的股票代码,全部只是测试例子,不做投资参考,投资有风险,代码学习使用,不做商业用途,
结合会员量化基础很多不足,我亲自给大家录视频,给大家免费的学习,目前上线录完了miniqmt量化交易的xtdata数据模块的全部内容,后面重点录一下xttrade交易模块,交易的内容比数据复杂太多了,点赞转发我更有动力继续录

mini我目前录了14内容

我给了对应的源代码

视频我上线了网页直接看就可以,点击界面的索普miniqmt量化教程课程就可以

完整的视频直接看


视频很多,我就不一个一个的贴了直接看就可以,我给一下的源代码1qmt介绍_哔哩哔哩_bilibili
7订阅单股数据
from xtquant import xtdata
from xtquant import xttrader
stock_code='600031.SH'
start_date='20250101'
end_date='20500101'
count=-1
def on_data(datas):
print(datas)
xtdata.subscribe_quote(stock_code=stock_code,
start_time=start_date,end_time=end_date,count=count,callback=on_data)
xtdata.run()
8多股订阅
from xtquant import xtdata
from xtquant import xttrader
stock_list=['513100.SH','000001.SZ']
start_date='20250101'
end_date='20500101'
period='1d'
count=-1
def f(datas):
code_list=list(datas.keys())
df=xtdata.get_market_data_ex(stock_list=code_list,start_time=start_date,end_time=end_date,
period=period,count=-1)
print(df)
xtdata.subscribe_whole_quote(code_list=stock_list,callback=f)
xtdata.run()
9自动数据订阅
from xtquant import xtdata
from xtquant import xttrader
import time
import schedule
stock_list=['000001.SZ','600031.SH']
start_date='20250101'
end_date='20251205'
count=-1
period='1d'
xtdata.subscribe_whole_quote(code_list=stock_list)
for stock in stock_list:
xtdata.subscribe_quote(stock_code=stock,start_time=start_date,end_time=end_date,count=-1,period=period)
def test():
df=xtdata.get_market_data_ex(stock_list=stock_list,
start_time=start_date,end_time=end_date,period=period,count=count)
print(df)
schedule.every(3).seconds.do(test)
while True:
schedule.run_pending()
time.sleep(1)
10读取本地数据
from xtquant import xtdata
from xtquant import xttrader
stock_code='000001.SZ'
period='1d'
start_time='20200101'
end_time='20251205'
incrementally = None
xtdata.download_history_data(
stock_code=stock_code,
period=period,
start_time=start_time,
end_time=end_time,
incrementally=incrementally)
df=xtdata.get_local_data(
stock_list=[stock_code],
period=period,
start_time=start_time,
end_time=end_time,
count=-1
)
print(df)
11单线程下载历史行情数据
from xtquant import xtdata
from xtquant import xttrader
stock_list=['513100.SH','000001.SZ','600111.SH']
for stock in stock_list:
stock_code=stock
period='1d'
start_time='20250101'
end_time='20501208'
incrementally = True
xtdata.download_history_data(stock_code=stock_code,
start_time=start_time,
end_time=end_time,
period=period,incrementally=incrementally)
df=xtdata.get_local_data(
stock_list=stock_list,
period='1d',
start_time='20250101',
end_time='20501208',
count=-1
)
print(df)
12多线程下载数据
from xtquant import xtdata
from xtquant import xttrader
stock_list=['513100.SH','000001.SZ','600111.SH']
period='1d'
start_time='20250101'
end_time='20251209'
incrementally = True
def on_progress(d):
print(d)
xtdata.download_history_data2(
stock_list=stock_list,
period=period,
start_time=start_time,
end_time=end_time,
incrementally=incrementally,
callback=on_progress
)
df=xtdata.get_local_data(
stock_list=stock_list,
start_time=start_time,
end_time=end_time,
period=period,
count=-1,
fill_data=True
)
print(df)
13下载财务数据
from xtquant import xtdata
from xtquant import xttrader
stock_list=['000001.SZ','600111.SH']
table_list=['Balance','Income']
xtdata.download_financial_data(stock_list=stock_list,table_list=table_list)
df=xtdata.get_financial_data(
stock_list=stock_list,
table_list=table_list,
start_time='20240101',
end_time='20251210'
)
print(df)
14基础数据何板块成分股
from xtquant import xtdata
from xtquant import xttrader
stock_code='000001.SZ'
#获取基础数据
info=xtdata.get_instrument_detail(stock_code=stock_code)
print(info)
#板块成分股数据
#1下载板块--2查询板块-3读取板块
#1下载板块
#xtdata.download_sector_data()
#2查询板块
df=xtdata.get_sector_list()
#print(df)
df=xtdata.get_stock_list_in_sector(sector_name='创业板')
print(df)
#获取指数权重
df=xtdata.get_index_weight(index_code='000300.SH')
print(df)
内容我全部上线了可以直接加入下载,专业的量化社区

不懂的问我就可以,源代码直接找我要合集的就可以,网页不好复制的话

给大家的量化福利,需要的可以找我
