feat(data): 添加个股资金流向接口并重构速率限制配置

- 新增 moneyflow 资金流向数据同步模块
- 实现接口级速率限制配置(sync_config.py)
- 更新流动性相关因子定义
- 添加非对称量化损失函数
This commit is contained in:
2026-04-03 23:57:47 +08:00
parent c143815443
commit 9e7d4241c6
18 changed files with 1473 additions and 334 deletions

View File

@@ -749,4 +749,114 @@ df = pro.cyq_perf(ts_code='600000.SH', start_date='20220101', end_date='20220429
73 600000.SH 20220107 0.72 12.16 8.60 11.36 9.89 7.59
74 600000.SH 20220106 0.72 12.16 8.60 11.36 9.89 3.92
75 600000.SH 20220105 0.72 12.16 8.60 11.36 9.89 5.65
76 600000.SH 20220104 0.72 12.16 8.60 11.36 9.89 3.93
76 600000.SH 20220104 0.72 12.16 8.60 11.36 9.89 3.93
个股资金流向
接口moneyflow可以通过数据工具调试和查看数据。
描述获取沪深A股票资金流向数据分析大单小单成交情况用于判别资金动向数据开始于2010年。
限量单次最大提取6000行记录总量不限制
积分用户需要至少2000积分才可以调取基础积分有流量控制积分越多权限越大请自行提高积分具体请参阅积分获取办法
输入参数
名称 类型 必选 描述
ts_code str N 股票代码 (股票和时间参数至少输入一个)
trade_date str N 交易日期
start_date str N 开始日期
end_date str N 结束日期
输出参数
名称 类型 默认显示 描述
ts_code str Y TS代码
trade_date str Y 交易日期
buy_sm_vol int Y 小单买入量(手)
buy_sm_amount float Y 小单买入金额(万元)
sell_sm_vol int Y 小单卖出量(手)
sell_sm_amount float Y 小单卖出金额(万元)
buy_md_vol int Y 中单买入量(手)
buy_md_amount float Y 中单买入金额(万元)
sell_md_vol int Y 中单卖出量(手)
sell_md_amount float Y 中单卖出金额(万元)
buy_lg_vol int Y 大单买入量(手)
buy_lg_amount float Y 大单买入金额(万元)
sell_lg_vol int Y 大单卖出量(手)
sell_lg_amount float Y 大单卖出金额(万元)
buy_elg_vol int Y 特大单买入量(手)
buy_elg_amount float Y 特大单买入金额(万元)
sell_elg_vol int Y 特大单卖出量(手)
sell_elg_amount float Y 特大单卖出金额(万元)
net_mf_vol int Y 净流入量(手)
net_mf_amount float Y 净流入额(万元)
各类别统计规则如下:
小单5万以下 中单5万20万 大单20万100万 特大单:成交额>=100万 ,数据基于主动买卖单统计
接口示例
pro = ts.pro_api('your token')
#获取单日全部股票数据
df = pro.moneyflow(trade_date='20190315')
#获取单个股票数据
df = pro.moneyflow(ts_code='002149.SZ', start_date='20190115', end_date='20190315')
数据示例
ts_code trade_date buy_sm_vol buy_sm_amount sell_sm_vol \
0 000779.SZ 20190315 11377 1150.17 11100
1 000933.SZ 20190315 94220 4803.22 105924
2 002270.SZ 20190315 43979 2330.96 45893
3 002319.SZ 20190315 21502 2952.88 17155
4 002604.SZ 20190315 31944 607.35 58667
5 300065.SZ 20190315 16048 2294.71 16425
6 600062.SH 20190315 55439 7432.13 65765
7 002735.SZ 20190315 3220 797.10 4598
8 300196.SZ 20190315 12534 1286.02 8340
9 300350.SZ 20190315 15346 1120.12 18853
10 600193.SH 20190315 12183 503.73 19576
11 002866.SZ 20190315 16932 2213.68 16037
12 300481.SZ 20190315 21386 4275.33 21863
13 600527.SH 20190315 115462 2975.44 79272
14 603980.SH 20190315 13957 1924.69 11718
15 600658.SH 20190315 71767 4826.73 69535
16 600812.SH 20190315 26140 1247.47 34923
17 002013.SZ 20190315 170234 12286.02 148509
18 600789.SH 20190315 211012 21644.56 150598
19 601636.SH 20190315 70737 3117.43 68073
20 000807.SZ 20190315 129668 6361.06 122077
...
sell_sm_amount buy_md_vol buy_md_amount sell_md_vol sell_md_amount \
0 1122.97 13012 1316.72 14812 1498.90
1 5411.72 135976 6935.40 154023 7863.00
2 2435.98 57679 3059.15 47279 2507.55
3 2358.68 27245 3742.52 26708 3670.05
4 1114.40 69897 1327.41 41108 781.19
5 2353.34 31232 4472.05 26771 3834.95
6 8817.75 86617 11615.40 79551 10676.99
7 1140.61 4602 1141.61 2730 676.72
8 855.45 9401 963.72 10478 1074.32
9 1380.31 24224 1770.90 21588 1577.92
10 812.58 28696 1185.17 31087 1286.11
11 2100.70 19197 2511.62 20269 2650.56
12 4379.14 31692 6345.72 32873 6578.36
13 2046.54 107103 2763.00 84883 2191.24
14 1619.33 14621 2019.41 14528 2005.69
15 4691.29 92788 6232.80 93273 6280.13
16 1669.97 38812 1855.78 39211 1874.05
17 10726.22 154979 11190.69 164090 11855.76
18 15479.08 269470 27660.18 236958 24338.36
19 3000.73 90416 3984.68 115162 5075.50
20 5999.66 175692 8627.77 178044 8751.08