当前位置:   article > 正文

qmt量化交易策略小白学习笔记第9期【qmt编程之获取股票资金流向数据--原生Python】

qmt量化交易策略小白学习笔记第9期【qmt编程之获取股票资金流向数据--原生Python】

qmt编程之获取股票资金流向数据

qmt更加详细的教程方法,会持续慢慢梳理。

也可找寻博主的历史文章,搜索关键词查看解决方案 !

感谢关注,需免费开通量化回测与咨询实盘权限,可以和博主联系!

获取股票资金流向数据

获取一只或者多只股票在一个时间段内的资金流向数据

提示

1.该数据通过get_market_dataget_market_data_ex接口获取,period参数选择transactioncount1d 或者 transactioncount1m
2.获取历史数据前需要先用download_history_data下载历史数据

3.VIP 权限数据

原生python

原型

原生python

  1. # 逐笔成交统计日级
  2. get_market_data_ex([],stock_list,period="transactioncount1d",start_time = "", end_time = "")
  3. # 逐步成交统计1分钟级
  4. get_market_data_ex([],stock_list,period="transactioncount1m",start_time = "", end_time = "")

参数

参数名称类型描述
field_listlist数据字段列表,传空则为全部字段
stock_listlist合约代码列表
periodstring周期
start_timestring起始时间
end_timestring结束时间
countint数据个数。默认参数,大于等于0时,若指定了 start_timeend_time,此时以 end_time 为基准向前取 count 条;若 start_timeend_time 缺省,默认取本地数据最新的 count 条数据;若 start_timeend_timecount 都缺省时,默认取本地全部数据
dividend_typestring除权方式
fill_databool是否向后填充空缺数据
  • field_list字段可选:

提示

特大单:成交金额大于或等于100万元或成交量大于或等于5000手

大单:成交金额大于或等于20万元或成交量大于或等于1000手

中单:成交金额大于或等于4万元或成交量大于或等于200手

小单:其它为小单

字段名数据类型含义
timeint时间戳
bidNumberint主买单总单数
bidMostVolumeint主买特大单成交量
bidBigVolumeint主买大单成交量
bidMediumVolumeint主买中单成交量
bidSmallVolumeint主买小单成交量
offNumberint主卖单总单数
offMostVolumeint主卖特大单成交量
offBigVolumeint主卖大单成交量
offMediumVolumeint主卖中单成交量
offSmallVolumeint主卖小单成交量
bidMostAmountfloat主买特大单成交额
bidBigAmountfloat主买大单成交额
bidMediumAmountfloat主买中单成交额
bidSmallAmountfloat主买小单成交额
offMostAmountfloat主卖特大单成交额
offBigAmountfloat主卖大单成交额
offMediumAmountfloat主卖中单成交额
offSmallAmountfloat主卖小单成交额
ddxfloat大单动向
ddyfloat涨跌动因
ddzfloat大单差分
zjbyNetInflowint资金博弈 净流入
zjbyMostint资金博弈 超大单
zjbyBigint资金博弈 大单
zjbyMediumint资金博弈 中单
zjbySmallint资金博弈 小单
netOrderint净挂
netWithdrawint净撤
withdrawBidint总撤买
withdrawOffint总撤卖
unactiveBidMostVolumeint被动买特大单成交量
unactiveBidBigVolumeint被动买大单成交量
unactiveBidMediumVolumeint被动买中单成交量
unactiveBidSmallVolumeint被动买小单成交量
unactiveOffMostVolumeint被动卖特大单成交量
unactiveOffBigVolumeint被动卖大单成交量
unactiveOffMediumVolumeint被动卖中单成交量
unactiveOffSmallVolumeint被动卖小单成交量
unactiveBidMostAmountfloat被动买特大单成交额
unactiveBidBigAmountfloat被动买大单成交额
unactiveBidMediumAmountfloat被动买中单成交额
unactiveBidSmallAmountfloat被动买小单成交额
unactiveOffMostAmountfloat被动卖特大单成交额
unactiveOffBigAmountfloat被动卖大单成交额
unactiveOffMediumAmountfloat被动卖中单成交额
unactiveOffSmallAmountfloat被动卖小单成交额

返回

返回一个 {stock_code:pd.DataFrame} 结构的dict对象,默认的列索引为取得的全部字段. 如果给定了 fields 参数, 则列索引与给定的 fields 对应.

示例

示例

  1. from xtquant import xtdata
  2. # 获取历史数据前,请确保已经下载历史数据
  3. xtdata.download_history_data("000001.SZ",period="transactioncount1d")
  4. xtdata.download_history_data("000582.SZ",period="transactioncount1d")
  5. # 获取一只股票在一个时间段内的资金流量数据
  6. data1 = xtdata.get_market_data_ex([],["000001.SZ"],period="transactioncount1d",start_time = "20230101", end_time = "20231009")
  7. # 获取多只股票在一个时间段内的资金流向数据
  8. data2 = xtdata.get_market_data_ex([],["000001.SZ","000582.SZ"],period="transactioncount1d",start_time = "20230101", end_time = "20231009")
  9. # 获取多只股票在某一天的资金流向数据
  10. data3 = xtdata.get_market_data_ex([],["000001.SZ","000582.SZ"],period="transactioncount1d",start_time = "20231009", end_time = "20231009")

data1返回值 

  1. {'000001.SZ': time bidNumber bidMostVolume bidBigVolume \
  2. 20230919000000 1695052800000 984 69117 44872
  3. 20230921000000 1695225600000 895 108902 83679
  4. 20230925000000 1695571200000 1623 231467 74114
  5. 20230926000000 1695657600000 2062 67169 55677
  6. 20230927000000 1695744000000 2009 58878 62465
  7. bidMediumVolume bidSmallVolume offNumber offMostVolume \
  8. 20230919000000 26438 6501 1967 85488
  9. 20230921000000 35465 3924 983 229549
  10. 20230925000000 43191 10924 2505 187342
  11. 20230926000000 51364 17352 2249 116657
  12. 20230927000000 56459 14777 1309 81739
  13. offBigVolume offMediumVolume ... unactiveOffMediumVolume \
  14. 20230919000000 59203 59738 ... 26438
  15. 20230921000000 86736 32368 ... 35465
  16. 20230925000000 122762 72830 ... 43191
  17. 20230926000000 60107 56529 ... 51364
  18. 20230927000000 45153 35564 ... 56459
  19. unactiveOffSmallVolume unactiveBidMostAmount \
  20. 20230919000000 6501 95675555.0
  21. 20230921000000 3924 254330642.0
  22. 20230925000000 10924 210680989.0
  23. 20230926000000 17352 130480050.0
  24. 20230927000000 14777 91271341.0
  25. unactiveBidBigAmount unactiveBidMediumAmount \
  26. 20230919000000 66298552.0 66894672.0
  27. 20230921000000 96037439.0 35829510.0
  28. 20230925000000 138055328.0 81832159.0
  29. 20230926000000 67243196.0 63224375.0
  30. 20230927000000 50446231.0 39734344.0
  31. unactiveBidSmallAmount unactiveOffMostAmount \
  32. 20230919000000 15027131.0 77417455.0
  33. 20230921000000 6162863.0 120659362.0
  34. 20230925000000 20874412.0 260444433.0
  35. 20230926000000 22504832.0 75270646.0
  36. 20230927000000 9942591.0 65804316.0
  37. unactiveOffBigAmount unactiveOffMediumAmount \
  38. 20230919000000 50235300.0 29606244.0
  39. 20230921000000 92703643.0 39276977.0
  40. 20230925000000 83333817.0 48529084.0
  41. 20230926000000 62328071.0 57432804.0
  42. 20230927000000 69814571.0 63092343.0
  43. unactiveOffSmallAmount
  44. 20230919000000 7278898.0
  45. 20230921000000 4345184.0
  46. 20230925000000 12272276.0
  47. 20230926000000 19401833.0
  48. 20230927000000 16510431.0
  49. [5 rows x 47 columns]}

 data2返回值

  1. {'000001.SZ': time bidNumber bidMostVolume bidBigVolume \
  2. 20230919000000 1695052800000 984 69117 44872
  3. 20230921000000 1695225600000 895 108902 83679
  4. 20230925000000 1695571200000 1623 231467 74114
  5. 20230926000000 1695657600000 2062 67169 55677
  6. 20230927000000 1695744000000 2009 58878 62465
  7. bidMediumVolume bidSmallVolume offNumber offMostVolume \
  8. 20230919000000 26438 6501 1967 85488
  9. 20230921000000 35465 3924 983 229549
  10. 20230925000000 43191 10924 2505 187342
  11. 20230926000000 51364 17352 2249 116657
  12. 20230927000000 56459 14777 1309 81739
  13. offBigVolume offMediumVolume ... unactiveOffMediumVolume \
  14. 20230919000000 59203 59738 ... 26438
  15. 20230921000000 86736 32368 ... 35465
  16. 20230925000000 122762 72830 ... 43191
  17. 20230926000000 60107 56529 ... 51364
  18. 20230927000000 45153 35564 ... 56459
  19. unactiveOffSmallVolume unactiveBidMostAmount \
  20. 20230919000000 6501 95675555.0
  21. 20230921000000 3924 254330642.0
  22. 20230925000000 10924 210680989.0
  23. 20230926000000 17352 130480050.0
  24. 20230927000000 14777 91271341.0
  25. unactiveBidBigAmount unactiveBidMediumAmount \
  26. 20230919000000 66298552.0 66894672.0
  27. 20230921000000 96037439.0 35829510.0
  28. 20230925000000 138055328.0 81832159.0
  29. 20230926000000 67243196.0 63224375.0
  30. 20230927000000 50446231.0 39734344.0
  31. unactiveBidSmallAmount unactiveOffMostAmount \
  32. 20230919000000 15027131.0 77417455.0
  33. 20230921000000 6162863.0 120659362.0
  34. 20230925000000 20874412.0 260444433.0
  35. 20230926000000 22504832.0 75270646.0
  36. 20230927000000 9942591.0 65804316.0
  37. unactiveOffBigAmount unactiveOffMediumAmount \
  38. 20230919000000 50235300.0 29606244.0
  39. 20230921000000 92703643.0 39276977.0
  40. 20230925000000 83333817.0 48529084.0
  41. 20230926000000 62328071.0 57432804.0
  42. 20230927000000 69814571.0 63092343.0
  43. unactiveOffSmallAmount
  44. 20230919000000 7278898.0
  45. 20230921000000 4345184.0
  46. 20230925000000 12272276.0
  47. 20230926000000 19401833.0
  48. 20230927000000 16510431.0
  49. [5 rows x 47 columns],
  50. '000582.SZ': time bidNumber bidMostVolume bidBigVolume \
  51. 20231009000000 1696780800000 1235 1822 7834
  52. bidMediumVolume bidSmallVolume offNumber offMostVolume \
  53. 20231009000000 13594 11220 1158 0
  54. offBigVolume offMediumVolume ... unactiveOffMediumVolume \
  55. 20231009000000 13378 19074 ... 13594
  56. unactiveOffSmallVolume unactiveBidMostAmount \
  57. 20231009000000 11220 0.0
  58. unactiveBidBigAmount unactiveBidMediumAmount \
  59. 20231009000000 10446929.0 14883956.0
  60. unactiveBidSmallAmount unactiveOffMostAmount \
  61. 20231009000000 9972652.0 1419544.0
  62. unactiveOffBigAmount unactiveOffMediumAmount \
  63. 20231009000000 6119272.0 10617787.0
  64. unactiveOffSmallAmount
  65. 20231009000000 8753931.0
  66. [1 rows x 47 columns]}

data3返回值

  1. {'000582.SZ': time bidNumber bidMostVolume bidBigVolume \
  2. 20231009000000 1696780800000 1235 1822 7834
  3. bidMediumVolume bidSmallVolume offNumber offMostVolume \
  4. 20231009000000 13594 11220 1158 0
  5. offBigVolume offMediumVolume ... unactiveOffMediumVolume \
  6. 20231009000000 13378 19074 ... 13594
  7. unactiveOffSmallVolume unactiveBidMostAmount \
  8. 20231009000000 11220 0.0
  9. unactiveBidBigAmount unactiveBidMediumAmount \
  10. 20231009000000 10446929.0 14883956.0
  11. unactiveBidSmallAmount unactiveOffMostAmount \
  12. 20231009000000 9972652.0 1419544.0
  13. unactiveOffBigAmount unactiveOffMediumAmount \
  14. 20231009000000 6119272.0 10617787.0
  15. unactiveOffSmallAmount
  16. 20231009000000 8753931.0
  17. [1 rows x 47 columns],
  18. '000001.SZ': time bidNumber bidMostVolume bidBigVolume \
  19. 20231009000000 1696780800000 1720 124493 91717
  20. bidMediumVolume bidSmallVolume offNumber offMostVolume \
  21. 20231009000000 52939 12295 2691 193122
  22. offBigVolume offMediumVolume ... unactiveOffMediumVolume \
  23. 20231009000000 120549 79591 ... 52939
  24. unactiveOffSmallVolume unactiveBidMostAmount \
  25. 20231009000000 12295 214620203.0
  26. unactiveBidBigAmount unactiveBidMediumAmount \
  27. 20231009000000 133821821.0 88366888.0
  28. unactiveBidSmallAmount unactiveOffMostAmount \
  29. 20231009000000 23450520.0 138450770.0
  30. unactiveOffBigAmount unactiveOffMediumAmount \
  31. 20231009000000 101823002.0 58774037.0
  32. unactiveOffSmallAmount
  33. 20231009000000 13652109.0
  34. [1 rows x 47 columns]}
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/646723
推荐阅读
相关标签
  

闽ICP备14008679号