qmt编程之获取期货数据
qmt更加详细的教程方法,会持续慢慢梳理。
也可找寻博主的历史文章,搜索关键词查看解决方案 !
感谢关注,咨询免费开通量化回测与获取实盘权限,欢迎和博主联系!
获取5档盘口行情
提示
- 该数据为VIP数据
示例
from xtquant import xtdata
import timesymbol_list = ["rb2405.SF","ec2404.INE"] # 五档行情支持上期所,上期能源period = "l2quote" # 获取5档盘口tickfor symbol in symbol_list:xtdata.subscribe_quote(symbol,period = period,count=-1)
time.sleep(1)data = xtdata.get_market_data_ex(["askPrice","bidPrice"],symbol_list,period = period,count=-1)print(data)
五档返回值
{'ec2404.INE': askPrice \20240115085900 [2300.0, 2300.2, 2304.0, 2306.0, 2310.0, 0.0, ... 20240115090000 [2266.0, 2280.0, 2280.9, 2285.0, 2287.9, 0.0, ... 20240115090001 [2261.6000000000004, 2262.0000000000005, 2262.... 20240115090001 [2253.4, 2253.5, 2253.6, 2254.6, 2255.0, 0.0, ... 20240115090002 [2244.6, 2246.6, 2246.7999999999997, 2248.8999... ... ... 20240115140227 [2138.3, 2138.6000000000004, 2138.700000000000... 20240115140228 [2138.0, 2138.3, 2138.6000000000004, 2138.7000... 20240115140228 [2137.7999999999997, 2137.8999999999996, 2137.... 20240115140229 [2137.2999999999997, 2137.7999999999997, 2137.... 20240115140229 [2136.4, 2137.1, 2137.7999999999997, 2137.8999... bidPrice 20240115085900 [2288.0, 2280.0, 2266.0, 2265.0, 2262.1, 0.0, ... 20240115090000 [2222.1, 2222.0, 2220.0, 2219.0, 2216.0, 0.0, ... 20240115090001 [2227.0000000000005, 2226.8000000000006, 2226.... 20240115090001 [2230.2000000000003, 2230.0000000000005, 2229.... 20240115090002 [2233.2000000000003, 2223.4, 2222.0, 2220.0, 2... ... ... 20240115140227 [2137.1, 2135.2999999999997, 2134.999999999999... 20240115140228 [2137.1, 2135.2999999999997, 2134.999999999999... 20240115140228 [2137.1, 2135.2999999999997, 2134.999999999999... 20240115140229 [2137.1, 2135.2999999999997, 2134.999999999999... 20240115140229 [2135.0, 2134.0, 2132.4, 2132.0, 2131.0, 0.0, ... [15942 rows x 2 columns],'rb2405.SF': askPrice \20240112205900 [3906.0, 3907.0, 3908.0, 3909.0, 3910.0, 0.0, ... 20240112210000 [3904.0, 3905.0, 3906.0, 3907.0, 3908.0, 0.0, ... 20240112210001 [3905.0, 3906.0, 3907.0, 3908.0, 3909.0, 0.0, ... 20240112210001 [3905.0, 3906.0, 3907.0, 3908.0, 3909.0, 0.0, ... 20240112210002 [3905.0, 3906.0, 3907.0, 3908.0, 3909.0, 0.0, ... ... ... 20240115140227 [3911.0, 3912.0, 3913.0, 3914.0, 3915.0, 0.0, ... 20240115140227 [3911.0, 3912.0, 3913.0, 3914.0, 3915.0, 0.0, ... 20240115140228 [3911.0, 3912.0, 3913.0, 3914.0, 3915.0, 0.0, ... 20240115140228 [3911.0, 3912.0, 3913.0, 3914.0, 3915.0, 0.0, ... 20240115140229 [3911.0, 3912.0, 3913.0, 3914.0, 3915.0, 0.0, ... bidPrice 20240112205900 [3905.0, 3904.0, 3903.0, 3902.0, 3901.0, 0.0, ... 20240112210000 [3903.0, 3902.0, 3901.0, 3900.0, 3899.0, 0.0, ... 20240112210001 [3904.0, 3903.0, 3902.0, 3901.0, 3900.0, 0.0, ... 20240112210001 [3904.0, 3903.0, 3902.0, 3901.0, 3900.0, 0.0, ... 20240112210002 [3904.0, 3903.0, 3902.0, 3901.0, 3900.0, 0.0, ... ... ... 20240115140227 [3910.0, 3909.0, 3908.0, 3907.0, 3906.0, 0.0, ... 20240115140227 [3910.0, 3909.0, 3908.0, 3907.0, 3906.0, 0.0, ... 20240115140228 [3910.0, 3909.0, 3908.0, 3907.0, 3906.0, 0.0, ... 20240115140228 [3910.0, 3909.0, 3908.0, 3907.0, 3906.0, 0.0, ... 20240115140229 [3910.0, 3909.0, 3908.0, 3907.0, 3906.0, 0.0, ... [35329 rows x 2 columns]}
期货结算价与持仓量
字段 | 数据类型 | 含义 |
---|---|---|
settelementPrice | float | 结算价 |
openInterest | float | 持仓量 |
示例 |
示例
from xtquant import xtdata
xtdata.get_market_data_ex(['settelementPrice','openInterest'],['rb2401.SF'],period='1d')
返回值
'rb2401.SF': settelementPrice openInterest20230117 3996.0 57320230118 4036.0 71320230119 4066.0 82120230120 4065.0 94420230130 4123.0 1201... ... ...20230922 3773.0 164392520230925 3741.0 171002320230926 3697.0 177290020230927 3684.0 176775820230928 3700.0 1697143[172 rows x 2 columns]}