返回列表 发布新帖

订阅接口中transactionNum成交笔数的获取

127 0


量化交易中,获取数据是第一步,然后清洗数据,判断执行。

那么,在获取数据这一步,不同的数据接口有不同的获取形式、字段内容。到底是自己没有下载还是没有权限,要提前搞搞清楚,别白忙一场~
比如,transactionNum成交笔数。在qmt的订阅接口中,如果你只订阅一只票(subscribe_quote),那就可以获取成交笔数。但如果订阅多只票(subscribe_whole_quote),那就获取不到成交笔数,需要上魔法💴,提升权限。

可以vx我咨询哟 luyucaijing


【订阅】有两种典型的,订阅单股(subscribe_quote),订阅多股(subscribe_whole_quote)

subscribe_quote    单股订阅接口
  1. <span style="background-color: rgb(255, 255, 255);">f</span>rom xtquant import xtdata

  2. def on_data (datas):
  3.     print(datas)

  4. seq = xtdata.subscribe_quote(stock_code='600519.SH', period='tick', callback=on_data)

  5. xtdata.run()
复制代码

返回结果
券商版,有transactionNum成交笔数
  1. {'600519.SH': [{'time': 1748920444000, 'lastPrice': 1515.31, 'open': 1508.01, 'high': 1519.0, 'low': 1505.02, 'lastClose': 1522.0, 'amount': 2447875095.0, 'volume': 16194, 'pvolume': 1619412, 'stockStatus': 3, 'openInt': 13, 'transactionNum': 13145, 'lastSettlementPrice': 0.0, 'settlementPrice': 0.0, 'pe': 0.0, 'askPrice': [1515.31, 1515.32, 1515.33, 1515.5, 1515.51], 'bidPrice': [1515.1000000000001, 1514.1000000000001, 1514.06, 1514.05, 1514.03], 'askVol': [3, 1, 1, 2, 4], 'bidVol': [1, 1, 1, 4, 1], 'volRatio': 0.0, 'speed1Min': 0.0, 'speed5Min': 0.0}]}
复制代码

投研端
  1. {'600519.SH': [{'time': 1748920309000, 'lastPrice': 1513.67, 'open': 1508.01, 'high': 1519.0, 'low': 1505.02, 'lastClose': 1522.0, 'amount': 2424864296.0, 'volume': 16042, 'pvolume': 1604212, 'stockStatus': 3, 'openInt': 13, 'transactionNum': 13007, 'lastSettlementPrice': 0.0, 'settlementPrice': 0.0, 'pe': 0.0, 'askPrice': [1513.67, 1513.68, 1513.77, 1513.81, 1513.82], 'bidPrice': [1513.46, 1513.28, 1513.0, 1512.88, 1512.84], 'askVol': [3, 1, 2, 2, 3], 'bidVol': [1, 3, 1, 1, 1], 'volRatio': 0.0, 'speed1Min': 6.95191732658945e-310, 'speed5Min': 6.9519173956956e-310}]}
复制代码

subscribe_whole_quote 订阅多股接口
  1. from xtquant import xtdata
  2. #code_list =xtdata.get_stock_list_in_sector('沪深300')
  3. code_list = ['300750.SZ','600000.SH']
  4. def on_data (datas):
  5.     print(datas)


  6. seq = xtdata.subscribe_whole_quote(code_list, callback=on_data)

  7. xtdata.run()
复制代码

返回结果
券商版,无transactionNum成交笔数
  1. {'600000.SH': {'time': 1748920828000, 'lastPrice': 12.55, 'open': 12.31, 'high': 12.57, 'low': 12.23, 'lastClose': 12.33, 'amount': 598757700.0, 'volume': 483066, 'pvolume': 48306577, 'stockStatus': 3, 'openInt': 13, 'transactionNum': 0, 'lastSettlementPrice': 12.33, 'settlementPrice': 0.0, 'pe': 0.0, 'askPrice': [12.55, 12.56, 12.57, 12.58, 12.59], 'bidPrice': [12.540000000000001, 12.530000000000001, 12.52, 12.51, 12.5], 'askVol': [136, 2480, 1991, 4815, 2406], 'bidVol': [1077, 288, 110, 197, 485], 'volRatio': 0.0, 'speed1Min': 0.0, 'speed5Min': 0.0}}

  2. {'300750.SZ': {'time': 1748920827000, 'lastPrice': 252.29, 'open': 252.0, 'high': 253.9, 'low': 250.66, 'lastClose': 250.0, 'amount': 2391527400.0, 'volume': 94863, 'pvolume': 9486349, 'stockStatus': 3, 'openInt': 13, 'transactionNum': 0, 'lastSettlementPrice': 250.0, 'settlementPrice': 0.0, 'pe': 0.0, 'askPrice': [252.3, 252.31, 252.32, 252.33, 252.34], 'bidPrice': [252.29, 252.28, 252.24, 252.23000000000002, 252.21], 'askVol': [2, 8, 8, 1, 7], 'bidVol': [19, 10, 2, 78, 2], 'volRatio': 0.0, 'speed1Min': 0.0, 'speed5Min': 0.0}}
复制代码

投研版,有transactionNum成交笔数

  1. {'600000.SH': {'time': 1748921128000, 'lastPrice': 12.55, 'open': 12.31, 'high': 12.57, 'low': 12.23, 'lastClose': 12.33, 'amount': 624296500.0, 'volume': 503407, 'pvolume': 50340677, 'stockStatus': 3, 'openInt': 13, 'transactionNum': 36307, 'lastSettlementPrice': 0.0, 'settlementPrice': 0.0, 'pe': 0.0, 'askPrice': [12.56, 12.57, 12.58, 12.59, 12.6], 'bidPrice': [12.55, 12.540000000000001, 12.530000000000001, 12.52, 12.51], 'askVol': [595, 1052, 4752, 2404, 4020], 'bidVol': [300, 1592, 233, 231, 334], 'volRatio': 0.0, 'speed1Min': 6.9519187286039e-310, 'speed5Min': 6.95191879771003e-310}}

  2. {'300750.SZ': {'time': 1748921127000, 'lastPrice': 252.29, 'open': 252.0, 'high': 253.9, 'low': 250.66, 'lastClose': 250.0, 'amount': 2421477300.0, 'volume': 96050, 'pvolume': 9605049, 'stockStatus': 3, 'openInt': 13, 'transactionNum': 45485, 'lastSettlementPrice': 0.0, 'settlementPrice': 0.0, 'pe': 0.0, 'askPrice': [252.29, 252.3, 252.31, 252.32, 252.33], 'bidPrice': [252.28, 252.27, 252.26000000000002, 252.25, 252.24], 'askVol': [1, 3, 10, 6, 7], 'bidVol': [1, 6, 18, 10, 29], 'volRatio': 0.0, 'speed1Min': 6.9519187286039e-310, 'speed5Min': 6.95191879771003e-310}}
复制代码



先想想自己的策略最需要什么字段,然后选接口,别忙了半天是因为权限的问题获取不到想要的数据。



40804f944e0fcba97ee34ec26318483.png

回复

您需要登录后才可以回帖 登录 | 立即注册

客服专线

400-080-8112

用思考的速度交易,用真诚的态度合作,我们是认真的!
  • 关注公众号
  • 添加微信客服
Copyright © 2001-2025 迅投QMT社区 版权所有 All Rights Reserved. 京ICP备2025122616号-3
关灯 快速发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表