qmt编程之获取股票资金流向数据
qmt更加详细的教程方法,会持续慢慢梳理。
也可找寻博主的历史文章,搜索关键词查看解决方案 !
感谢关注,需免费开通量化回测与咨询实盘权限,可以和博主联系!
获取股票资金流向数据
获取一只或者多只股票在一个时间段内的资金流向数据
提示
1.该数据通过get_market_data
和get_market_data_ex
接口获取,period参数选择transactioncount1d
或者 transactioncount1m
2.获取历史数据前需要先用download_history_data
下载历史数据
3.VIP 权限数据
#内置python
原型
内置python
# 逐笔成交统计日级
C.get_market_data_ex([],stock_list,period="transactioncount1d",start_time = "", end_time = "")
# 逐步成交统计1分钟级
C.get_market_data_ex([],stock_list,period="transactioncount1m",start_time = "", end_time = "")
参数
除period参数需指定为transactioncount1d
或者 transactioncount1m
外,其余参数与ContextInfo.get_market_data_ex一致
返回值
- 返回dict { stock_code1 : value1, stock_code2 : value2, ... }
- value1, value2, ... :pd.DataFrame 数据集,index为time_list,columns为fields
提示
特大单:成交金额大于或等于100万元或成交量大于或等于5000手
大单:成交金额大于或等于20万元或成交量大于或等于1000手
中单:成交金额大于或等于4万元或成交量大于或等于200手
小单:其它为小单
字段名 | 数据类型 | 含义 |
---|---|---|
time | int | 时间戳 |
bidNumber | int | 主买单总单数 |
bidMostVolume | int | 主买特大单成交量 |
bidBigVolume | int | 主买大单成交量 |
bidMediumVolume | int | 主买中单成交量 |
bidSmallVolume | int | 主买小单成交量 |
offNumber | int | 主卖单总单数 |
offMostVolume | int | 主卖特大单成交量 |
offBigVolume | int | 主卖大单成交量 |
offMediumVolume | int | 主卖中单成交量 |
offSmallVolume | int | 主卖小单成交量 |
bidMostAmount | float | 主买特大单成交额 |
bidBigAmount | float | 主买大单成交额 |
bidMediumAmount | float | 主买中单成交额 |
bidSmallAmount | float | 主买小单成交额 |
offMostAmount | float | 主卖特大单成交额 |
offBigAmount | float | 主卖大单成交额 |
offMediumAmount | float | 主卖中单成交额 |
offSmallAmount | float | 主卖小单成交额 |
ddx | float | 大单动向 |
ddy | float | 涨跌动因 |
ddz | float | 大单差分 |
zjbyNetInflow | int | 资金博弈 净流入 |
zjbyMost | int | 资金博弈 超大单 |
zjbyBig | int | 资金博弈 大单 |
zjbyMedium | int | 资金博弈 中单 |
zjbySmall | int | 资金博弈 小单 |
netOrder | int | 净挂 |
netWithdraw | int | 净撤 |
withdrawBid | int | 总撤买 |
withdrawOff | int | 总撤卖 |
unactiveBidMostVolume | int | 被动买特大单成交量 |
unactiveBidBigVolume | int | 被动买大单成交量 |
unactiveBidMediumVolume | int | 被动买中单成交量 |
unactiveBidSmallVolume | int | 被动买小单成交量 |
unactiveOffMostVolume | int | 被动卖特大单成交量 |
unactiveOffBigVolume | int | 被动卖大单成交量 |
unactiveOffMediumVolume | int | 被动卖中单成交量 |
unactiveOffSmallVolume | int | 被动卖小单成交量 |
unactiveBidMostAmount | float | 被动买特大单成交额 |
unactiveBidBigAmount | float | 被动买大单成交额 |
unactiveBidMediumAmount | float | 被动买中单成交额 |
unactiveBidSmallAmount | float | 被动买小单成交额 |
unactiveOffMostAmount | float | 被动卖特大单成交额 |
unactiveOffBigAmount | float | 被动卖大单成交额 |
unactiveOffMediumAmount | float | 被动卖中单成交额 |
unactiveOffSmallAmount | float | 被动卖小单成交额 |
示例
python
# coding:gbkdef init(C):returndef f(data):print(data)def after_init(C):stock_list = ["000001.SZ"]if 1:download_history_data("000001.SZ","transactioncount1d",'','')C.subscribe_quote("000001.SZ","transactioncount1d",callback = f)# C.subscribe_quote("000001.SZ","transactioncount1d")print(C.get_market_data_ex([],stock_list,period="transactioncount1d",start_time = "", end_time = ""))pass
返回值
bidBigAmount 3.53868e+08
bidBigVolmue 333765
bidMediumAmount 9.43932e+07
bidMediumVolmue 89050
bidMostAmount 1.76518e+09
bidMostVolmue 1666209
bidNumber 2523
bidSmallAmount 8.33361e+06
bidSmallVolmue 7862
ddx 30.73
ddy -9.83
ddz 2.48
netOrder 0
netWithdraw 0
offBigAmount 3.22761e+08
offBigVolmue 304380
offMediumAmount 7.95061e+07
offMediumVolmue 74975
offMostAmount 1.16452e+09
offMostVolmue 1099078
offNumber 2071
offSmallAmount 5.36e+06
offSmallVolmue 5058
stime 20240315
time 1710432000000
unactiveBidBigAmount 3.22761e+08
unactiveBidBigVolmue 304380
unactiveBidMediumAmount 7.95061e+07
unactiveBidMediumVolmue 74975
unactiveBidMostAmount 1.16452e+09
unactiveBidMostVolmue 1099078
unactiveBidSmallAmount 5.36e+06
unactiveBidSmallVolmue 5058
unactiveOffBigAmount 3.53868e+08
unactiveOffBigVolmue 333765
unactiveOffMediumAmount 9.43932e+07
unactiveOffMediumVolmue 89050
unactiveOffMostAmount 1.76518e+09
unactiveOffMostVolmue 1666209
unactiveOffSmallAmount 8.33361e+06
unactiveOffSmallVolmue 7862
withdrawBid 0
withdrawOff 0
zjbyBig 31107201
zjbyMedium 14887134
zjbyMost 600652357
zjbyNetInflow 649620302
zjbySmall 2973610
Name: 20240315, dtype: object
{'000001.SZ': bidBigAmount bidBigVolmue bidMediumAmount bidMediumVolmue \
stime
20240315 353868458.0 333765 94535250.0 89184 bidMostAmount bidMostVolmue bidNumber bidSmallAmount \
stime
20240315 1.765176e+09 1666209 2524 8333609.0 bidSmallVolmue ddx ... unactiveOffMostVolmue \
stime ...
20240315 7862 30.73 ... 1666209 unactiveOffSmallAmount unactiveOffSmallVolmue withdrawBid \
stime
20240315 8333609.0 7862 0 withdrawOff zjbyBig zjbyMedium zjbyMost zjbyNetInflow \
stime
20240315 0 31107201 15029164 600652357 649762332 zjbySmall
stime
20240315 2973610 [1 rows x 48 columns]}