qmt编程之获取期货行情数据
qmt更加详细的教程方法,会持续慢慢梳理。
也可找寻博主的历史文章,搜索关键词查看解决方案 !
感谢关注,咨询免费开通量化回测与获取实盘权限,欢迎和博主联系!
获取日线行情数据
示例
from xtquant import xtdata
xtdata.get_market_data_ex([],['rb2401.SF'],period='1d')
返回值
# 返回结果
{'rb2401.SF': time open high low close volume \
20230117 1673884800000 4001.0 4027.0 3973.0 4011.0 1038
20230118 1673971200000 4027.0 4051.0 4014.0 4037.0 314
20230119 1674057600000 4043.0 4085.0 4043.0 4080.0 352
20230120 1674144000000 4075.0 4076.0 4050.0 4070.0 502
20230130 1675008000000 4127.0 4157.0 4080.0 4084.0 992
... ... ... ... ... ... ...
20231017 1697472000000 3658.0 3672.0 3637.0 3647.0 1068036
20231018 1697558400000 3652.0 3660.0 3605.0 3615.0 1361935
20231019 1697644800000 3615.0 3650.0 3595.0 3644.0 1313338
20231020 1697731200000 3650.0 3659.0 3601.0 3610.0 1418587
20231023 1697990400000 3600.0 3616.0 3558.0 3573.0 1513440
amount settelementPrice openInterest preClose suspendFlag
20230117 4.148817e+07 3996.0 573 4061.0 0
20230118 1.267393e+07 4036.0 713 4011.0 0
20230119 1.431537e+07 4066.0 821 4037.0 0
20230120 2.040859e+07 4065.0 944 4080.0 0
20230130 4.090941e+07 4123.0 1201 4070.0 0
... ... ... ... ... ...
20231017 3.900789e+10 3652.0 1870289 3657.0 0
20231018 4.950385e+10 3634.0 1951142 3647.0 0
20231019 4.759753e+10 3624.0 1886883 3615.0 0
20231020 5.149242e+10 3629.0 1880167 3644.0 0
20231023 5.423026e+10 0.0 1961524 3610.0 0
[183 rows x 11 columns]}
获取tick行情
示例
from xtquant import xtdata
xtdata.get_market_data_ex([],['rb2401.SF'],period='tick')
返回值
time lastPrice open high low lastClose amount volume pvolume stockStatus openInt lastSettlementPrice askPrice bidPrice askVol bidVol settlementPrice transactionNum
20230925085900 1695603540500 3778.0 3786.0 3787.0 3766.0 3779.0 1.291532e+10 341961 0 0 1651554 3773.0 [3779.0, 3780.0, 3781.0, 3782.0, 3783.0] [3777.0, 3776.0, 3775.0, 3774.0, 3773.0] [635, 0, 0, 0, 0] [138, 0, 0, 0, 0] 0.0 0
20230925090000 1695603600500 3779.0 3786.0 3787.0 3766.0 3779.0 1.296989e+10 343405 0 0 1652373 3773.0 [3780.0, 3781.0, 3782.0, 3783.0, 3784.0] [3778.0, 3777.0, 3776.0, 3775.0, 3774.0] [916, 0, 0, 0, 0] [168, 0, 0, 0, 0] 0.0 0
20230925090001 1695603601000 3780.0 3786.0 3787.0 3766.0 3779.0 1.307600e+10 346211 0 0 1651646 3773.0 [3787.0, 3788.0, 3789.0, 3790.0, 3791.0] [3779.0, 3778.0, 3777.0, 3776.0, 3775.0] [420, 0, 0, 0, 0] [20, 0, 0, 0, 0] 0.0 0
20230925090001 1695603601500 3783.0 3786.0 3787.0 3766.0 3779.0 1.309460e+10 346703 0 0 1651496 3773.0 [3784.0, 3785.0, 3786.0, 3787.0, 3788.0] [3776.0, 3775.0, 3774.0, 3773.0, 3772.0] [46, 0, 0, 0, 0] [89, 0, 0, 0, 0] 0.0 0
20230925090002 1695603602000 3783.0 3786.0 3787.0 3766.0 3779.0 1.312842e+10 347597 0 0 1651258 3773.0 [3784.0, 3785.0, 3786.0, 3787.0, 3788.0] [3782.0, 3781.0, 3780.0, 3779.0, 3778.0] [41, 0, 0, 0, 0] [7, 0, 0, 0, 0] 0.0 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
20230928145958 1695884398500 3690.0 3690.0 3717.0 3684.0 3682.0 3.781059e+10 1021634 0 0 1697198 3684.0 [3690.0, 0.0, 0.0, 0.0, 0.0] [3690.0, 0.0, 0.0, 0.0, 0.0] [54, 0, 0, 0, 0] [126, 0, 0, 0, 0] 0.0 0
20230928145959 1695884399000 3690.0 3690.0 3717.0 3684.0 3682.0 3.781148e+10 1021658 0 0 1697179 3684.0 [3690.0, 0.0, 0.0, 0.0, 0.0] [3690.0, 0.0, 0.0, 0.0, 0.0] [20, 0, 0, 0, 0] [112, 0, 0, 0, 0] 0.0 0
20230928145959 1695884399500 3690.0 3690.0 3717.0 3684.0 3682.0 3.781395e+10 1021725 0 0 1697158 3684.0 [3690.0, 0.0, 0.0, 0.0, 0.0] [3690.0, 0.0, 0.0, 0.0, 0.0] [20, 0, 0, 0, 0] [46, 0, 0, 0, 0] 0.0 0
20230928150000 1695884400000 3690.0 3690.0 3717.0 3684.0 3682.0 3.781502e+10 1021754 0 0 1697143 3684.0 [3690.0, 0.0, 0.0, 0.0, 0.0] [3690.0, 0.0, 0.0, 0.0, 0.0] [10, 0, 0, 0, 0] [63, 0, 0, 0, 0] 0.0 0
20230928150000 1695884400500 3690.0 3690.0 3717.0 3684.0 3682.0 3.781502e+10 1021754 0 0 1697143 3684.0 [3690.0, 0.0, 0.0, 0.0, 0.0] [3690.0, 0.0, 0.0, 0.0, 0.0] [10, 0, 0, 0, 0] [63, 0, 0, 0, 0] 3700.0 0
149943 rows × 18 columns