feat: 添加 Redis 消息展示功能到监控面板

- 新增 /api/messages API 接口,支持从 Redis Stream 读取消息
- 支持按策略筛选消息和分页展示
- 前端新增消息列表卡片,展示时间、策略、股票代码、动作、价格和状态
- 自动判断消息处理状态(已处理/待处理)
- 消息列表每30秒自动刷新,支持手动刷新
This commit is contained in:
2026-03-01 22:06:42 +08:00
parent e88ba5bcf9
commit 7bb0a0537b
14 changed files with 1814 additions and 806 deletions

View File

@@ -359,7 +359,6 @@
"成功获取 000811.SZ 的数据\n",
"成功获取 000812.SZ 的数据\n",
"成功获取 000813.SZ 的数据\n",
"已调用300次API等待 1.26 秒以满足速率限制...\n",
"成功获取 000815.SZ 的数据\n",
"成功获取 000816.SZ 的数据\n",
"成功获取 000818.SZ 的数据\n",
@@ -660,7 +659,7 @@
"成功获取 002085.SZ 的数据\n",
"成功获取 002086.SZ 的数据\n",
"成功获取 002088.SZ 的数据\n",
"已调用300次API等待 3.46 秒以满足速率限制...\n",
"已调用300次API等待 4.76 秒以满足速率限制...\n",
"成功获取 002090.SZ 的数据\n",
"成功获取 002091.SZ 的数据\n",
"成功获取 002092.SZ 的数据\n",
@@ -961,6 +960,7 @@
"成功获取 002400.SZ 的数据\n",
"成功获取 002401.SZ 的数据\n",
"成功获取 002402.SZ 的数据\n",
"已调用300次API等待 0.19 秒以满足速率限制...\n",
"成功获取 002403.SZ 的数据\n",
"成功获取 002404.SZ 的数据\n",
"成功获取 002405.SZ 的数据\n",
@@ -1261,7 +1261,7 @@
"成功获取 002729.SZ 的数据\n",
"成功获取 002730.SZ 的数据\n",
"成功获取 002731.SZ 的数据\n",
"已调用300次API等待 1.65 秒以满足速率限制...\n",
"已调用300次API等待 1.76 秒以满足速率限制...\n",
"成功获取 002732.SZ 的数据\n",
"成功获取 002733.SZ 的数据\n",
"成功获取 002734.SZ 的数据\n",
@@ -1562,7 +1562,7 @@
"成功获取 300014.SZ 的数据\n",
"成功获取 300015.SZ 的数据\n",
"成功获取 300016.SZ 的数据\n",
"已调用300次API等待 9.99 秒以满足速率限制...\n",
"已调用300次API等待 8.80 秒以满足速率限制...\n",
"成功获取 300017.SZ 的数据\n",
"成功获取 300018.SZ 的数据\n",
"成功获取 300019.SZ 的数据\n",
@@ -1863,7 +1863,7 @@
"成功获取 300337.SZ 的数据\n",
"成功获取 300338.SZ 的数据\n",
"成功获取 300339.SZ 的数据\n",
"已调用300次API等待 0.43 秒以满足速率限制...\n",
"已调用300次API等待 0.56 秒以满足速率限制...\n",
"成功获取 300340.SZ 的数据\n",
"成功获取 300341.SZ 的数据\n",
"成功获取 300342.SZ 的数据\n",
@@ -2164,7 +2164,7 @@
"成功获取 300650.SZ 的数据\n",
"成功获取 300651.SZ 的数据\n",
"成功获取 300652.SZ 的数据\n",
"已调用300次API等待 9.99 秒以满足速率限制...\n",
"已调用300次API等待 10.57 秒以满足速率限制...\n",
"成功获取 300653.SZ 的数据\n",
"成功获取 300654.SZ 的数据\n",
"成功获取 300655.SZ 的数据\n",
@@ -2465,7 +2465,7 @@
"成功获取 300966.SZ 的数据\n",
"成功获取 300967.SZ 的数据\n",
"成功获取 300968.SZ 的数据\n",
"已调用300次API等待 11.36 秒以满足速率限制...\n",
"已调用300次API等待 10.28 秒以满足速率限制...\n",
"成功获取 300969.SZ 的数据\n",
"成功获取 300970.SZ 的数据\n",
"成功获取 300971.SZ 的数据\n",
@@ -2766,7 +2766,7 @@
"成功获取 301313.SZ 的数据\n",
"成功获取 301314.SZ 的数据\n",
"成功获取 301315.SZ 的数据\n",
"已调用300次API等待 12.21 秒以满足速率限制...\n",
"已调用300次API等待 11.13 秒以满足速率限制...\n",
"成功获取 301316.SZ 的数据\n",
"成功获取 301317.SZ 的数据\n",
"成功获取 301318.SZ 的数据\n",
@@ -3668,6 +3668,7 @@
"成功获取 600956.SH 的数据\n",
"成功获取 600958.SH 的数据\n",
"成功获取 600959.SH 的数据\n",
"已调用300次API等待 1.09 秒以满足速率限制...\n",
"成功获取 600960.SH 的数据\n",
"成功获取 600961.SH 的数据\n",
"成功获取 600962.SH 的数据\n",
@@ -3968,7 +3969,7 @@
"成功获取 603041.SH 的数据\n",
"成功获取 603042.SH 的数据\n",
"成功获取 603043.SH 的数据\n",
"已调用300次API等待 4.62 秒以满足速率限制...\n",
"已调用300次API等待 2.18 秒以满足速率限制...\n",
"成功获取 603045.SH 的数据\n",
"成功获取 603048.SH 的数据\n",
"成功获取 603050.SH 的数据\n",
@@ -4269,7 +4270,7 @@
"成功获取 603530.SH 的数据\n",
"成功获取 603533.SH 的数据\n",
"成功获取 603535.SH 的数据\n",
"已调用300次API等待 11.16 秒以满足速率限制...\n",
"已调用300次API等待 12.69 秒以满足速率限制...\n",
"成功获取 603536.SH 的数据\n",
"成功获取 603538.SH 的数据\n",
"成功获取 603551.SH 的数据\n",
@@ -4570,7 +4571,7 @@
"成功获取 605167.SH 的数据\n",
"成功获取 605168.SH 的数据\n",
"成功获取 605169.SH 的数据\n",
"已调用300次API等待 11.24 秒以满足速率限制...\n",
"已调用300次API等待 12.53 秒以满足速率限制...\n",
"成功获取 605177.SH 的数据\n",
"成功获取 605178.SH 的数据\n",
"成功获取 605179.SH 的数据\n",
@@ -4871,7 +4872,7 @@
"成功获取 688271.SH 的数据\n",
"成功获取 688272.SH 的数据\n",
"成功获取 688273.SH 的数据\n",
"已调用300次API等待 12.67 秒以满足速率限制...\n",
"已调用300次API等待 13.01 秒以满足速率限制...\n",
"成功获取 688275.SH 的数据\n",
"成功获取 688276.SH 的数据\n",
"成功获取 688277.SH 的数据\n",
@@ -5172,7 +5173,7 @@
"成功获取 688689.SH 的数据\n",
"成功获取 688690.SH 的数据\n",
"成功获取 688691.SH 的数据\n",
"已调用300次API等待 12.70 秒以满足速率限制...\n",
"已调用300次API等待 12.20 秒以满足速率限制...\n",
"成功获取 688692.SH 的数据\n",
"成功获取 688693.SH 的数据\n",
"成功获取 688695.SH 的数据\n",
@@ -5473,7 +5474,7 @@
"成功获取 000005.SZ 的数据\n",
"成功获取 000013.SZ 的数据\n",
"成功获取 000015.SZ 的数据\n",
"已调用300次API等待 15.49 秒以满足速率限制...\n",
"已调用300次API等待 9.65 秒以满足速率限制...\n",
"成功获取 000018.SZ 的数据\n",
"成功获取 000023.SZ 的数据\n",
"成功获取 000024.SZ 的数据\n",
@@ -5765,7 +5766,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_964/650416012.py:40: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
"/tmp/ipykernel_3041/650416012.py:40: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
" all_cashflow = pd.concat(cashflow_list, ignore_index=True)\n"
]
},
@@ -5828,7 +5829,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"id": "85bdf760cb83fbd3",
"metadata": {
"ExecuteTime": {
@@ -6141,6 +6142,7 @@
"成功获取 000811.SZ 的数据\n",
"成功获取 000812.SZ 的数据\n",
"成功获取 000813.SZ 的数据\n",
"已调用300次API等待 0.05 秒以满足速率限制...\n",
"成功获取 000815.SZ 的数据\n",
"成功获取 000816.SZ 的数据\n",
"成功获取 000818.SZ 的数据\n",
@@ -6441,7 +6443,7 @@
"成功获取 002085.SZ 的数据\n",
"成功获取 002086.SZ 的数据\n",
"成功获取 002088.SZ 的数据\n",
"已调用300次API等待 1.65 秒以满足速率限制...\n",
"已调用300次API等待 2.07 秒以满足速率限制...\n",
"成功获取 002090.SZ 的数据\n",
"成功获取 002091.SZ 的数据\n",
"成功获取 002092.SZ 的数据\n",
@@ -7342,7 +7344,7 @@
"成功获取 300014.SZ 的数据\n",
"成功获取 300015.SZ 的数据\n",
"成功获取 300016.SZ 的数据\n",
"已调用300次API等待 1.69 秒以满足速率限制...\n",
"已调用300次API等待 5.16 秒以满足速率限制...\n",
"成功获取 300017.SZ 的数据\n",
"成功获取 300018.SZ 的数据\n",
"成功获取 300019.SZ 的数据\n",
@@ -7643,6 +7645,7 @@
"成功获取 300337.SZ 的数据\n",
"成功获取 300338.SZ 的数据\n",
"成功获取 300339.SZ 的数据\n",
"已调用300次API等待 0.16 秒以满足速率限制...\n",
"成功获取 300340.SZ 的数据\n",
"成功获取 300341.SZ 的数据\n",
"成功获取 300342.SZ 的数据\n",
@@ -8243,7 +8246,7 @@
"成功获取 300966.SZ 的数据\n",
"成功获取 300967.SZ 的数据\n",
"成功获取 300968.SZ 的数据\n",
"已调用300次API等待 4.85 秒以满足速率限制...\n",
"已调用300次API等待 5.22 秒以满足速率限制...\n",
"成功获取 300969.SZ 的数据\n",
"成功获取 300970.SZ 的数据\n",
"成功获取 300971.SZ 的数据\n",
@@ -8544,7 +8547,7 @@
"成功获取 301313.SZ 的数据\n",
"成功获取 301314.SZ 的数据\n",
"成功获取 301315.SZ 的数据\n",
"已调用300次API等待 9.40 秒以满足速率限制...\n",
"已调用300次API等待 8.96 秒以满足速率限制...\n",
"成功获取 301316.SZ 的数据\n",
"成功获取 301317.SZ 的数据\n",
"成功获取 301318.SZ 的数据\n",
@@ -8845,7 +8848,7 @@
"成功获取 600170.SH 的数据\n",
"成功获取 600171.SH 的数据\n",
"成功获取 600172.SH 的数据\n",
"已调用300次API等待 5.91 秒以满足速率限制...\n",
"已调用300次API等待 6.95 秒以满足速率限制...\n",
"成功获取 600173.SH 的数据\n",
"成功获取 600176.SH 的数据\n",
"成功获取 600177.SH 的数据\n",
@@ -9746,7 +9749,6 @@
"成功获取 603041.SH 的数据\n",
"成功获取 603042.SH 的数据\n",
"成功获取 603043.SH 的数据\n",
"已调用300次API等待 0.80 秒以满足速率限制...\n",
"成功获取 603045.SH 的数据\n",
"成功获取 603048.SH 的数据\n",
"成功获取 603050.SH 的数据\n",
@@ -10047,7 +10049,7 @@
"成功获取 603530.SH 的数据\n",
"成功获取 603533.SH 的数据\n",
"成功获取 603535.SH 的数据\n",
"已调用300次API等待 2.32 秒以满足速率限制...\n",
"已调用300次API等待 1.87 秒以满足速率限制...\n",
"成功获取 603536.SH 的数据\n",
"成功获取 603538.SH 的数据\n",
"成功获取 603551.SH 的数据\n",
@@ -10348,7 +10350,7 @@
"成功获取 605167.SH 的数据\n",
"成功获取 605168.SH 的数据\n",
"成功获取 605169.SH 的数据\n",
"已调用300次API等待 0.98 秒以满足速率限制...\n",
"已调用300次API等待 2.55 秒以满足速率限制...\n",
"成功获取 605177.SH 的数据\n",
"成功获取 605178.SH 的数据\n",
"成功获取 605179.SH 的数据\n",
@@ -10649,7 +10651,7 @@
"成功获取 688271.SH 的数据\n",
"成功获取 688272.SH 的数据\n",
"成功获取 688273.SH 的数据\n",
"已调用300次API等待 8.78 秒以满足速率限制...\n",
"已调用300次API等待 11.16 秒以满足速率限制...\n",
"成功获取 688275.SH 的数据\n",
"成功获取 688276.SH 的数据\n",
"成功获取 688277.SH 的数据\n",
@@ -10950,7 +10952,7 @@
"成功获取 688689.SH 的数据\n",
"成功获取 688690.SH 的数据\n",
"成功获取 688691.SH 的数据\n",
"已调用300次API等待 9.65 秒以满足速率限制...\n",
"已调用300次API等待 7.44 秒以满足速率限制...\n",
"成功获取 688692.SH 的数据\n",
"成功获取 688693.SH 的数据\n",
"成功获取 688695.SH 的数据\n",
@@ -11251,7 +11253,7 @@
"成功获取 000005.SZ 的数据\n",
"成功获取 000013.SZ 的数据\n",
"成功获取 000015.SZ 的数据\n",
"已调用300次API等待 8.80 秒以满足速率限制...\n",
"已调用300次API等待 7.25 秒以满足速率限制...\n",
"成功获取 000018.SZ 的数据\n",
"成功获取 000023.SZ 的数据\n",
"成功获取 000024.SZ 的数据\n",
@@ -11543,7 +11545,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_22119/3613025148.py:40: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
"/tmp/ipykernel_3041/3613025148.py:40: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
" all_fina_indicator = pd.concat(fina_indicator_list, ignore_index=True)\n"
]
},
@@ -11606,7 +11608,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"id": "83403f50",
"metadata": {},
"outputs": [
@@ -12214,7 +12216,7 @@
"成功获取 002085.SZ 的数据\n",
"成功获取 002086.SZ 的数据\n",
"成功获取 002088.SZ 的数据\n",
"已调用300次API等待 2.67 秒以满足速率限制...\n",
"已调用300次API等待 0.14 秒以满足速率限制...\n",
"成功获取 002090.SZ 的数据\n",
"成功获取 002091.SZ 的数据\n",
"成功获取 002092.SZ 的数据\n",
@@ -13115,7 +13117,7 @@
"成功获取 300014.SZ 的数据\n",
"成功获取 300015.SZ 的数据\n",
"成功获取 300016.SZ 的数据\n",
"已调用300次API等待 4.63 秒以满足速率限制...\n",
"已调用300次API等待 6.50 秒以满足速率限制...\n",
"成功获取 300017.SZ 的数据\n",
"成功获取 300018.SZ 的数据\n",
"成功获取 300019.SZ 的数据\n",
@@ -13716,7 +13718,7 @@
"成功获取 300650.SZ 的数据\n",
"成功获取 300651.SZ 的数据\n",
"成功获取 300652.SZ 的数据\n",
"已调用300次API等待 5.36 秒以满足速率限制...\n",
"已调用300次API等待 4.54 秒以满足速率限制...\n",
"成功获取 300653.SZ 的数据\n",
"成功获取 300654.SZ 的数据\n",
"成功获取 300655.SZ 的数据\n",
@@ -14017,7 +14019,7 @@
"成功获取 300966.SZ 的数据\n",
"成功获取 300967.SZ 的数据\n",
"成功获取 300968.SZ 的数据\n",
"已调用300次API等待 9.85 秒以满足速率限制...\n",
"已调用300次API等待 11.83 秒以满足速率限制...\n",
"成功获取 300969.SZ 的数据\n",
"成功获取 300970.SZ 的数据\n",
"成功获取 300971.SZ 的数据\n",
@@ -14318,7 +14320,7 @@
"成功获取 301313.SZ 的数据\n",
"成功获取 301314.SZ 的数据\n",
"成功获取 301315.SZ 的数据\n",
"已调用300次API等待 11.75 秒以满足速率限制...\n",
"已调用300次API等待 10.66 秒以满足速率限制...\n",
"成功获取 301316.SZ 的数据\n",
"成功获取 301317.SZ 的数据\n",
"成功获取 301318.SZ 的数据\n",
@@ -14619,7 +14621,7 @@
"成功获取 600170.SH 的数据\n",
"成功获取 600171.SH 的数据\n",
"成功获取 600172.SH 的数据\n",
"已调用300次API等待 5.16 秒以满足速率限制...\n",
"已调用300次API等待 6.39 秒以满足速率限制...\n",
"成功获取 600173.SH 的数据\n",
"成功获取 600176.SH 的数据\n",
"成功获取 600177.SH 的数据\n",
@@ -15520,7 +15522,6 @@
"成功获取 603041.SH 的数据\n",
"成功获取 603042.SH 的数据\n",
"成功获取 603043.SH 的数据\n",
"已调用300次API等待 0.87 秒以满足速率限制...\n",
"成功获取 603045.SH 的数据\n",
"成功获取 603048.SH 的数据\n",
"成功获取 603050.SH 的数据\n",
@@ -15821,7 +15822,6 @@
"成功获取 603530.SH 的数据\n",
"成功获取 603533.SH 的数据\n",
"成功获取 603535.SH 的数据\n",
"已调用300次API等待 8.80 秒以满足速率限制...\n",
"成功获取 603536.SH 的数据\n",
"成功获取 603538.SH 的数据\n",
"成功获取 603551.SH 的数据\n",
@@ -16122,7 +16122,7 @@
"成功获取 605167.SH 的数据\n",
"成功获取 605168.SH 的数据\n",
"成功获取 605169.SH 的数据\n",
"已调用300次API等待 7.92 秒以满足速率限制...\n",
"已调用300次API等待 6.57 秒以满足速率限制...\n",
"成功获取 605177.SH 的数据\n",
"成功获取 605178.SH 的数据\n",
"成功获取 605179.SH 的数据\n",
@@ -16423,7 +16423,7 @@
"成功获取 688271.SH 的数据\n",
"成功获取 688272.SH 的数据\n",
"成功获取 688273.SH 的数据\n",
"已调用300次API等待 11.83 秒以满足速率限制...\n",
"已调用300次API等待 10.81 秒以满足速率限制...\n",
"成功获取 688275.SH 的数据\n",
"成功获取 688276.SH 的数据\n",
"成功获取 688277.SH 的数据\n",
@@ -16724,7 +16724,7 @@
"成功获取 688689.SH 的数据\n",
"成功获取 688690.SH 的数据\n",
"成功获取 688691.SH 的数据\n",
"已调用300次API等待 11.66 秒以满足速率限制...\n",
"已调用300次API等待 13.70 秒以满足速率限制...\n",
"成功获取 688692.SH 的数据\n",
"成功获取 688693.SH 的数据\n",
"成功获取 688695.SH 的数据\n",
@@ -17025,7 +17025,7 @@
"成功获取 000005.SZ 的数据\n",
"成功获取 000013.SZ 的数据\n",
"成功获取 000015.SZ 的数据\n",
"已调用300次API等待 13.36 秒以满足速率限制...\n",
"已调用300次API等待 15.39 秒以满足速率限制...\n",
"成功获取 000018.SZ 的数据\n",
"成功获取 000023.SZ 的数据\n",
"成功获取 000024.SZ 的数据\n",
@@ -17317,7 +17317,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_964/3548322812.py:40: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
"/tmp/ipykernel_3041/3548322812.py:40: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation.\n",
" all_balancesheet = pd.concat(balancesheet_list, ignore_index=True)\n"
]
},
@@ -17380,7 +17380,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"id": "b27bb37b",
"metadata": {},
"outputs": [
@@ -17394,12 +17394,12 @@
"3 5.364899e+12\n",
"4 5.271746e+12\n",
" ... \n",
"381212 1.150050e+09\n",
"381213 9.132874e+08\n",
"381214 4.395018e+08\n",
"381215 4.792661e+08\n",
"381216 3.738566e+08\n",
"Name: total_liab, Length: 381217, dtype: float64\n"
"381213 1.150050e+09\n",
"381214 9.132874e+08\n",
"381215 4.395018e+08\n",
"381216 4.792661e+08\n",
"381217 3.738566e+08\n",
"Name: total_liab, Length: 381218, dtype: float64\n"
]
}
],

View File

@@ -83,32 +83,32 @@
"output_type": "stream",
"text": [
" ts_code trade_date close open high low \\\n",
"0 000905.SH 20260213 8299.5850 8366.3327 8419.7618 8290.8388 \n",
"1 000905.SH 20260212 8423.5695 8342.3650 8437.4202 8341.7705 \n",
"2 000905.SH 20260211 8325.8107 8295.3326 8373.5033 8295.1223 \n",
"3 000905.SH 20260210 8306.4448 8318.5325 8331.9858 8258.1519 \n",
"4 000905.SH 20260209 8311.2829 8280.1088 8313.4692 8229.0026 \n",
"0 000905.SH 20260227 8658.4503 8499.7957 8658.4503 8499.7957 \n",
"1 000905.SH 20260226 8557.2160 8542.8324 8582.7633 8490.9215 \n",
"2 000905.SH 20260225 8527.5593 8412.0800 8551.5345 8401.5965 \n",
"3 000905.SH 20260224 8392.9098 8403.3106 8444.1283 8328.5678 \n",
"4 000905.SH 20260213 8299.5850 8366.3327 8419.7618 8290.8388 \n",
"... ... ... ... ... ... ... \n",
"14074 399006.SZ 20100607 1069.4680 1005.0280 1075.2250 1001.7020 \n",
"14075 399006.SZ 20100604 1027.6810 989.6810 1027.6810 986.5040 \n",
"14076 399006.SZ 20100603 998.3940 1002.3550 1026.7020 997.7750 \n",
"14077 399006.SZ 20100602 997.1190 967.6090 997.1190 952.6110 \n",
"14078 399006.SZ 20100601 973.2330 986.0150 994.7930 948.1180 \n",
"14086 399006.SZ 20100607 1069.4680 1005.0280 1075.2250 1001.7020 \n",
"14087 399006.SZ 20100604 1027.6810 989.6810 1027.6810 986.5040 \n",
"14088 399006.SZ 20100603 998.3940 1002.3550 1026.7020 997.7750 \n",
"14089 399006.SZ 20100602 997.1190 967.6090 997.1190 952.6110 \n",
"14090 399006.SZ 20100601 973.2330 986.0150 994.7930 948.1180 \n",
"\n",
" pre_close change pct_chg vol amount \n",
"0 8423.5695 -123.9845 -1.4719 2.027857e+08 4.063205e+08 \n",
"1 8325.8107 97.7588 1.1742 2.121383e+08 4.383205e+08 \n",
"2 8306.4448 19.3659 0.2331 2.040197e+08 3.886124e+08 \n",
"3 8311.2829 -4.8381 -0.0582 1.958062e+08 3.942833e+08 \n",
"4 8146.4128 164.8701 2.0238 2.116676e+08 4.279823e+08 \n",
"0 8557.2160 101.2343 1.1830 2.803612e+08 5.128219e+08 \n",
"1 8527.5593 29.6567 0.3478 2.541118e+08 5.139847e+08 \n",
"2 8392.9098 134.6495 1.6043 2.778934e+08 5.068487e+08 \n",
"3 8299.5850 93.3248 1.1245 2.246293e+08 4.497138e+08 \n",
"4 8423.5695 -123.9845 -1.4719 2.027857e+08 4.063205e+08 \n",
"... ... ... ... ... ... \n",
"14074 1027.6810 41.7870 4.0661 2.655275e+06 9.106095e+06 \n",
"14075 998.3940 29.2870 2.9334 1.500295e+06 5.269441e+06 \n",
"14076 997.1190 1.2750 0.1279 1.616805e+06 6.240835e+06 \n",
"14077 973.2330 23.8860 2.4543 1.074628e+06 4.001206e+06 \n",
"14078 1000.0000 -26.7670 -2.6767 1.356285e+06 4.924177e+06 \n",
"14086 1027.6810 41.7870 4.0661 2.655275e+06 9.106095e+06 \n",
"14087 998.3940 29.2870 2.9334 1.500295e+06 5.269441e+06 \n",
"14088 997.1190 1.2750 0.1279 1.616805e+06 6.240835e+06 \n",
"14089 973.2330 23.8860 2.4543 1.074628e+06 4.001206e+06 \n",
"14090 1000.0000 -26.7670 -2.6767 1.356285e+06 4.924177e+06 \n",
"\n",
"[14079 rows x 11 columns]\n"
"[14091 rows x 11 columns]\n"
]
}
],
@@ -137,7 +137,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.2"
"version": "3.12.11"
}
},
"nbformat": 4,

View File

@@ -39,15 +39,15 @@
"3 000006.SZ 20250312\n",
"4 000007.SZ 20250312\n",
"... ... ...\n",
"27325 920978.BJ 20260202\n",
"27326 920981.BJ 20260202\n",
"27327 920982.BJ 20260202\n",
"27328 920985.BJ 20260202\n",
"27329 920992.BJ 20260202\n",
"27350 920978.BJ 20260209\n",
"27351 920981.BJ 20260209\n",
"27352 920982.BJ 20260209\n",
"27353 920985.BJ 20260209\n",
"27354 920992.BJ 20260209\n",
"\n",
"[8679695 rows x 2 columns]\n",
"20260206\n",
"start_date: 20260209\n"
"[8707050 rows x 2 columns]\n",
"20260213\n",
"start_date: 20260224\n"
]
}
],
@@ -96,12 +96,7 @@
"任务 20260227 完成\n",
"任务 20260226 完成\n",
"任务 20260225 完成\n",
"任务 20260224 完成\n",
"任务 20260213 完成\n",
"任务 20260212 完成\n",
"任务 20260211 完成\n",
"任务 20260210 完成\n",
"任务 20260209 完成\n"
"任务 20260224 完成\n"
]
}
],
@@ -183,7 +178,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.2"
"version": "3.12.11"
}
},
"nbformat": 4,

View File

@@ -39,15 +39,15 @@
"3 801005.SI 20250221\n",
"4 801010.SI 20250221\n",
"... ... ...\n",
"2190 859811.SI 20260202\n",
"2191 859821.SI 20260202\n",
"2192 859822.SI 20260202\n",
"2193 859852.SI 20260202\n",
"2194 859951.SI 20260202\n",
"2190 859811.SI 20260209\n",
"2191 859821.SI 20260209\n",
"2192 859822.SI 20260209\n",
"2193 859852.SI 20260209\n",
"2194 859951.SI 20260209\n",
"\n",
"[1147558 rows x 2 columns]\n",
"20260206\n",
"start_date: 20260209\n"
"[1149753 rows x 2 columns]\n",
"20260213\n",
"start_date: 20260224\n"
]
}
],
@@ -96,12 +96,7 @@
"任务 20260227 完成\n",
"任务 20260226 完成\n",
"任务 20260225 完成\n",
"任务 20260224 完成\n",
"任务 20260213 完成\n",
"任务 20260212 完成\n",
"任务 20260211 完成\n",
"任务 20260210 完成\n",
"任务 20260209 完成\n"
"任务 20260224 完成\n"
]
}
],
@@ -183,7 +178,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.2"
"version": "3.12.11"
}
},
"nbformat": 4,

View File

@@ -94,17 +94,17 @@
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Index: 9629640 entries, 0 to 27329\n",
"Index: 9656995 entries, 0 to 27354\n",
"Data columns (total 2 columns):\n",
" # Column Dtype \n",
"--- ------ ----- \n",
" 0 ts_code object\n",
" 1 trade_date object\n",
"dtypes: object(2)\n",
"memory usage: 220.4+ MB\n",
"memory usage: 221.0+ MB\n",
"None\n",
"20260206\n",
"20260209\n"
"20260213\n",
"20260224\n"
]
}
],
@@ -144,22 +144,17 @@
"name": "stdout",
"output_type": "stream",
"text": [
"任务 20260309 完成\n",
"任务 20260310 完成\n",
"任务 20260309 完成\n",
"任务 20260306 完成\n",
"任务 20260305 完成\n",
"任务 20260303 完成\n",
"任务 20260304 完成\n",
"任务 20260303 完成\n",
"任务 20260302 完成\n",
"任务 20260227 完成\n",
"任务 20260226 完成\n",
"任务 20260225 完成\n",
"任务 20260224 完成\n",
"任务 20260213 完成\n",
"任务 20260212 完成\n",
"任务 20260211 完成\n",
"任务 20260210 完成\n",
"任务 20260209 完成\n"
"任务 20260224 完成\n"
]
}
],
@@ -230,58 +225,58 @@
"output_type": "stream",
"text": [
" ts_code trade_date close turnover_rate turnover_rate_f \\\n",
"0 001301.SZ 20260213 78.24 1.0939 1.3757 \n",
"1 301050.SZ 20260213 53.61 2.8931 3.6211 \n",
"2 000829.SZ 20260213 10.58 2.2336 3.5271 \n",
"3 688498.SH 20260213 746.98 3.4302 4.7903 \n",
"4 920510.BJ 20260213 18.30 2.8519 4.1749 \n",
"0 300819.SZ 20260227 58.92 9.7287 24.1597 \n",
"1 001378.SZ 20260227 25.85 3.5842 3.5842 \n",
"2 688505.SH 20260227 8.68 0.4993 1.1491 \n",
"3 605158.SH 20260227 8.58 0.8147 2.9625 \n",
"4 688193.SH 20260227 54.23 0.9385 1.7187 \n",
"... ... ... ... ... ... \n",
"27350 000065.SZ 20260209 12.07 1.7167 3.2552 \n",
"27351 920249.BJ 20260209 13.86 3.2235 3.3218 \n",
"27352 300824.SZ 20260209 11.36 1.2161 3.0644 \n",
"27353 000766.SZ 20260209 23.65 1.8680 2.3253 \n",
"27354 000591.SZ 20260209 5.72 5.9341 9.0727 \n",
"21882 002289.SZ 20260224 27.97 1.5075 2.5139 \n",
"21883 600901.SH 20260224 6.38 0.3122 0.7895 \n",
"21884 002353.SZ 20260224 103.70 2.8704 3.4515 \n",
"21885 300435.SZ 20260224 30.50 3.6153 5.4615 \n",
"21886 300084.SZ 20260224 11.38 9.3900 10.1377 \n",
"\n",
" volume_ratio pe pe_ttm pb ps ps_ttm \\\n",
"0 0.51 24.3404 20.9997 3.0175 3.9021 2.8680 \n",
"1 0.80 38.6753 105.5089 4.2033 11.2338 18.9830 \n",
"2 0.65 347.7936 NaN 3.7189 0.1291 0.1352 \n",
"3 0.66 NaN 640.0343 29.5658 254.5923 140.4090 \n",
"4 1.41 160.0964 NaN 8.4111 14.5063 16.3558 \n",
"... ... ... ... ... ... ... \n",
"27350 0.73 13.3573 18.0503 1.2589 0.7347 0.9425 \n",
"27351 0.85 NaN NaN 8.0159 2.9840 2.5496 \n",
"27352 0.87 53.3349 33.5338 4.9536 4.9192 3.9029 \n",
"27353 0.75 405.0086 397.6822 9.9329 17.2829 18.3415 \n",
"27354 1.27 18.3189 21.1797 0.9314 3.7171 4.1825 \n",
" volume_ratio pe pe_ttm pb ps ps_ttm dv_ratio \\\n",
"0 0.99 136.4038 148.8393 10.2870 14.6635 15.5540 0.6789 \n",
"1 1.20 37.0409 42.9823 1.8561 2.2661 2.3080 2.5094 \n",
"2 0.90 226.4426 NaN 3.9842 12.6831 12.6434 0.3456 \n",
"3 0.94 19.1275 26.8054 1.7756 0.6334 0.6516 1.7306 \n",
"4 0.89 NaN NaN 2.3813 12.2524 13.1011 0.4458 \n",
"... ... ... ... ... ... ... ... \n",
"21882 2.01 NaN NaN 35.8237 35.5848 28.2125 NaN \n",
"21883 0.78 12.5570 11.6882 1.5234 7.0010 6.2032 6.2700 \n",
"21884 1.07 40.4159 37.4306 4.7938 7.9502 6.7506 0.8096 \n",
"21885 1.10 NaN 172.8196 3.5518 4.3304 4.1720 0.6557 \n",
"21886 2.25 NaN NaN 4.6382 9.6453 9.5673 NaN \n",
"\n",
" dv_ratio dv_ttm total_share float_share free_share total_mv \\\n",
"0 1.0183 1.0183 26080.2350 18605.2851 14794.9501 2.040518e+06 \n",
"1 0.6398 0.6398 24721.2171 21036.5666 16807.4482 1.325304e+06 \n",
"2 0.0945 0.0945 102510.0438 102412.9669 64854.1551 1.084556e+06 \n",
"3 0.0665 0.0533 8594.7726 8400.0000 6014.9271 6.420123e+06 \n",
"4 NaN NaN 18421.3929 9389.9078 6414.2078 3.371115e+05 \n",
"... ... ... ... ... ... ... \n",
"27350 1.1303 1.1303 116144.2159 97496.2288 51416.3105 1.401861e+06 \n",
"27351 NaN NaN 42163.0000 12466.9576 12097.9576 5.843792e+05 \n",
"27352 1.7937 1.7937 32634.1682 31649.5307 12560.3926 3.707242e+05 \n",
"27353 NaN NaN 96649.4707 96600.7681 77600.7681 2.285760e+06 \n",
"27354 1.9711 2.0779 392444.2493 392354.1671 256620.6136 2.244781e+06 \n",
" dv_ttm total_share float_share free_share total_mv \\\n",
"0 0.6789 14920.5000 13476.2250 5426.6150 8.791159e+05 \n",
"1 2.5094 13333.3600 6450.5766 6450.5766 3.446674e+05 \n",
"2 0.3456 103657.2100 71057.2100 30872.7971 8.997446e+05 \n",
"3 1.7306 51142.0000 51142.0000 14064.0840 4.387984e+05 \n",
"4 0.4458 4006.9870 4006.9870 2188.0251 2.172989e+05 \n",
"... ... ... ... ... ... \n",
"21882 NaN 28025.3733 27995.3733 16788.3130 7.838697e+05 \n",
"21883 6.2700 579186.6431 579045.2431 228992.3580 3.695211e+06 \n",
"21884 0.8096 102385.5833 69324.3890 57652.8100 1.061738e+07 \n",
"21885 0.6557 38571.3000 36881.4630 24414.0100 1.176425e+06 \n",
"21886 NaN 50838.9899 34610.1638 32057.6638 5.785477e+05 \n",
"\n",
" circ_mv is_st \n",
"0 1.455678e+06 False \n",
"1 1.127770e+06 False \n",
"2 1.083529e+06 False \n",
"3 6.274632e+06 False \n",
"4 1.718353e+05 False \n",
"0 7.940192e+05 False \n",
"1 1.667474e+05 False \n",
"2 6.167766e+05 False \n",
"3 4.387984e+05 False \n",
"4 2.172989e+05 False \n",
"... ... ... \n",
"27350 1.176779e+06 False \n",
"27351 1.727920e+05 False \n",
"27352 3.595387e+05 False \n",
"27353 2.284608e+06 False \n",
"27354 2.244266e+06 False \n",
"21882 7.830306e+05 True \n",
"21883 3.694309e+06 False \n",
"21884 7.188939e+06 False \n",
"21885 1.124885e+06 False \n",
"21886 3.938637e+05 False \n",
"\n",
"[27355 rows x 19 columns]\n"
"[21887 rows x 19 columns]\n"
]
}
],
@@ -306,58 +301,58 @@
"output_type": "stream",
"text": [
" ts_code trade_date close turnover_rate turnover_rate_f \\\n",
"5 603261.SH 20260213 28.95 0.4664 1.3719 \n",
"14 002700.SZ 20260213 7.28 1.5973 1.6181 \n",
"34 300344.SZ 20260213 1.87 14.3407 25.9753 \n",
"67 000430.SZ 20260213 7.26 0.8541 1.3705 \n",
"81 000752.SZ 20260213 10.86 1.0429 1.2849 \n",
"7 600360.SH 20260227 9.58 2.1195 2.7285 \n",
"77 000669.SZ 20260227 4.56 7.5951 9.5786 \n",
"108 603580.SH 20260227 17.19 0.8104 2.4841 \n",
"111 603557.SH 20260227 3.51 5.2656 7.8297 \n",
"127 603377.SH 20260227 3.70 1.1320 1.7903 \n",
"... ... ... ... ... ... \n",
"27165 300301.SZ 20260209 2.49 1.9012 2.0554 \n",
"27244 002822.SZ 20260209 3.53 1.0762 1.0762 \n",
"27270 300147.SZ 20260209 9.44 1.7053 2.2069 \n",
"27281 002501.SZ 20260209 2.16 3.6044 4.6543 \n",
"27297 002620.SZ 20260209 5.98 2.2406 3.1755 \n",
"21722 603843.SH 20260224 5.66 2.1676 3.0441 \n",
"21751 002253.SZ 20260224 10.51 1.2118 1.4935 \n",
"21808 000903.SZ 20260224 2.70 1.2350 1.8672 \n",
"21813 000995.SZ 20260224 15.83 11.1164 16.4343 \n",
"21882 002289.SZ 20260224 27.97 1.5075 2.5139 \n",
"\n",
" volume_ratio pe pe_ttm pb ps ps_ttm dv_ratio \\\n",
"5 0.49 NaN NaN 3.3744 7.7410 7.8754 NaN \n",
"14 0.77 32.3153 40.4077 2.2014 4.2912 4.3540 0.9066 \n",
"34 0.60 NaN NaN 5.3118 4.6416 4.9881 NaN \n",
"67 0.49 NaN NaN 21.9522 13.6188 12.8340 NaN \n",
"81 1.21 109.3444 19.4711 4.6597 6.7963 6.4062 NaN \n",
"7 1.08 72.0218 52.4452 2.7077 4.4710 4.1388 0.7724 \n",
"77 3.02 NaN NaN NaN 2.3735 2.4518 NaN \n",
"108 0.56 NaN NaN 5.3358 13.4080 9.7500 0.4770 \n",
"111 2.82 NaN NaN 27.9422 7.0938 8.9069 NaN \n",
"127 1.37 NaN NaN 3.2661 3.2762 4.0899 NaN \n",
"... ... ... ... ... ... ... ... \n",
"27165 0.97 NaN NaN 12.5588 4.0907 4.7109 NaN \n",
"27244 0.95 NaN NaN 4.9828 2.9693 6.5620 NaN \n",
"27270 1.21 NaN NaN 9.0126 3.3586 4.2436 NaN \n",
"27281 0.87 NaN NaN 29.0833 22.9884 26.1834 NaN \n",
"27297 1.30 NaN NaN NaN 2.8840 4.2972 NaN \n",
"21722 0.61 NaN NaN 14.1532 2.9075 3.3288 NaN \n",
"21751 0.62 NaN NaN 2.2278 14.3426 20.5492 NaN \n",
"21808 0.95 NaN NaN 3.9295 1.1041 1.1752 NaN \n",
"21813 0.54 101.3839 NaN 19.0447 16.2904 19.2344 NaN \n",
"21882 2.01 NaN NaN 35.8237 35.5848 28.2125 NaN \n",
"\n",
" dv_ttm total_share float_share free_share total_mv \\\n",
"5 NaN 7750.5022 7750.5022 2634.9858 224377.0387 \n",
"14 0.9066 41362.8185 26346.4874 26007.0037 301121.3187 \n",
"34 NaN 64170.6416 63999.4166 35333.5001 119999.0998 \n",
"67 NaN 80963.5372 37055.6486 23092.8156 587795.2801 \n",
"81 NaN 26375.8491 26375.8491 21407.3042 286441.7212 \n",
"7 0.7724 96029.5304 96029.5304 74596.8648 919962.9012 \n",
"77 NaN 68040.8797 68040.8797 53950.9653 310266.4114 \n",
"108 0.4770 13067.3200 13067.3200 4263.2200 224627.2308 \n",
"111 NaN 62343.6888 62343.6888 41926.6552 218826.3477 \n",
"127 NaN 71491.6351 71491.6351 45201.8751 264519.0499 \n",
"... ... ... ... ... ... \n",
"27165 NaN 82986.8769 78987.6719 73061.8561 206637.3235 \n",
"27244 NaN 195094.2200 107059.0368 107059.0368 688682.5966 \n",
"27270 NaN 66127.9045 65739.8353 50798.8432 624247.4185 \n",
"27281 NaN 355000.0000 354646.9206 274646.9206 766800.0000 \n",
"27297 NaN 37749.4000 31536.0303 22251.3747 225741.4120 \n",
"21722 NaN 69962.3237 69962.3237 49817.1582 395986.7521 \n",
"21751 NaN 22562.6095 20830.4044 16901.0873 237133.0258 \n",
"21808 NaN 193484.4410 192026.1648 127011.9255 522407.9907 \n",
"21813 NaN 17740.8000 17740.8000 12000.1709 280836.8640 \n",
"21882 NaN 28025.3733 27995.3733 16788.3130 783869.6912 \n",
"\n",
" circ_mv is_st \n",
"5 224377.0387 True \n",
"14 191802.4283 True \n",
"34 119678.9090 True \n",
"67 269024.0088 True \n",
"81 286441.7212 True \n",
"7 919962.9012 True \n",
"77 310266.4114 True \n",
"108 224627.2308 True \n",
"111 218826.3477 True \n",
"127 264519.0499 True \n",
"... ... ... \n",
"27165 196679.3030 True \n",
"27244 377918.3999 True \n",
"27270 620584.0452 True \n",
"27281 766037.3485 True \n",
"27297 188585.4612 True \n",
"21722 395986.7521 True \n",
"21751 218927.5502 True \n",
"21808 518470.6450 True \n",
"21813 280836.8640 True \n",
"21882 783030.5912 True \n",
"\n",
"[870 rows x 19 columns]\n"
"[692 rows x 19 columns]\n"
]
}
],
@@ -407,7 +402,7 @@
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Index: 9656995 entries, 0 to 27354\n",
"Index: 9678882 entries, 0 to 21886\n",
"Data columns (total 3 columns):\n",
" # Column Dtype \n",
"--- ------ ----- \n",
@@ -415,7 +410,7 @@
" 1 trade_date object\n",
" 2 is_st bool \n",
"dtypes: bool(1), object(2)\n",
"memory usage: 230.2+ MB\n",
"memory usage: 230.8+ MB\n",
"None\n"
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -34,17 +34,17 @@
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Index: 9413748 entries, 0 to 25875\n",
"Index: 9439640 entries, 0 to 25891\n",
"Data columns (total 2 columns):\n",
" # Column Dtype \n",
"--- ------ ----- \n",
" 0 ts_code object\n",
" 1 trade_date object\n",
"dtypes: object(2)\n",
"memory usage: 215.5+ MB\n",
"memory usage: 216.1+ MB\n",
"None\n",
"20260206\n",
"start_date: 20260209\n"
"20260213\n",
"start_date: 20260224\n"
]
}
],
@@ -94,12 +94,7 @@
"任务 20260227 完成\n",
"任务 20260226 完成\n",
"任务 20260225 完成\n",
"任务 20260224 完成\n",
"任务 20260213 完成\n",
"任务 20260212 完成\n",
"任务 20260211 完成\n",
"任务 20260210 完成\n",
"任务 20260209 完成\n"
"任务 20260224 完成\n"
]
}
],
@@ -189,71 +184,71 @@
"output_type": "stream",
"text": [
" ts_code trade_date buy_sm_vol buy_sm_amount sell_sm_vol \\\n",
"0 300587.SZ 20260213 154110 9661.44 160598 \n",
"1 601000.SH 20260213 150959 6301.54 197344 \n",
"2 002338.SZ 20260213 9215 5012.78 8260 \n",
"3 688373.SH 20260213 29166 1845.78 30329 \n",
"4 002226.SZ 20260213 101435 6137.98 79302 \n",
"0 002968.SZ 20260227 21302 2803.57 22552 \n",
"1 600822.SH 20260227 20371 2267.76 18994 \n",
"2 688003.SH 20260227 10527 8037.01 11183 \n",
"3 300894.SZ 20260227 15100 1751.27 16491 \n",
"4 603026.SH 20260227 35310 23574.59 36976 \n",
"... ... ... ... ... ... \n",
"25887 603713.SH 20260209 9898 6481.74 10208 \n",
"25888 300004.SZ 20260209 41923 5934.14 50255 \n",
"25889 300975.SZ 20260209 198244 30367.70 159191 \n",
"25890 603381.SH 20260209 85934 22581.16 95505 \n",
"25891 002836.SZ 20260209 27160 4238.25 22047 \n",
"20704 002587.SZ 20260224 114009 8175.31 115996 \n",
"20705 002474.SZ 20260224 132136 11662.67 104912 \n",
"20706 002742.SZ 20260224 9048 381.92 6158 \n",
"20707 601298.SH 20260224 95226 8736.97 102361 \n",
"20708 301413.SZ 20260224 11648 17813.73 7614 \n",
"\n",
" sell_sm_amount buy_md_vol buy_md_amount sell_md_vol sell_md_amount \\\n",
"0 10061.76 183752 11498.51 186971 11701.15 \n",
"1 8233.85 84549 3527.41 71932 3003.18 \n",
"2 4495.09 9488 5163.47 9035 4920.33 \n",
"3 1918.49 10043 635.49 10005 633.64 \n",
"4 4796.49 104000 6296.98 78239 4741.21 \n",
"0 2971.99 12991 1715.40 11827 1560.91 \n",
"1 2114.45 11869 1321.48 13242 1474.72 \n",
"2 8535.14 6168 4707.52 5857 4472.05 \n",
"3 1914.17 12204 1416.49 10014 1161.98 \n",
"4 24680.03 25979 17356.95 23472 15689.34 \n",
"... ... ... ... ... ... \n",
"25887 6683.01 6735 4413.49 7402 4854.70 \n",
"25888 7133.88 53004 7510.03 58384 8274.31 \n",
"25889 24423.94 164520 25222.01 193044 29612.42 \n",
"25890 25109.67 65977 17316.88 71008 18669.88 \n",
"25891 3438.16 21123 3293.94 20955 3271.07 \n",
"20704 8318.63 70581 5059.80 77960 5594.40 \n",
"20705 9262.36 65247 5760.34 70730 6242.71 \n",
"20706 259.97 12268 517.35 10575 446.72 \n",
"20707 9387.51 17890 1640.43 21755 1995.51 \n",
"20708 11690.25 18481 28263.21 16404 25116.12 \n",
"\n",
" buy_lg_vol buy_lg_amount sell_lg_vol sell_lg_amount buy_elg_vol \\\n",
"0 139274 8711.00 168037 10519.91 60907 \n",
"1 57471 2398.28 37552 1567.23 21177 \n",
"2 5873 3195.64 5312 2890.59 514 \n",
"3 8238 521.88 7113 451.02 0 \n",
"4 50394 3048.72 69021 4177.39 9335 \n",
"0 4640 616.17 5428 716.74 873 \n",
"1 7412 824.96 7836 871.98 420 \n",
"2 5007 3817.18 4258 3252.13 792 \n",
"3 5426 629.63 6225 721.24 0 \n",
"4 14372 9614.17 12027 8050.76 2859 \n",
"... ... ... ... ... ... \n",
"25887 3515 2307.87 4056 2660.17 2867 \n",
"25888 49767 7060.10 39566 5596.12 8820 \n",
"25889 116306 17856.14 144536 22152.02 51550 \n",
"25890 46270 12156.66 38176 10028.63 11944 \n",
"25891 9676 1508.43 11383 1772.18 1000 \n",
"20704 59178 4247.14 57492 4122.70 13717 \n",
"20705 28382 2504.08 47970 4231.98 8727 \n",
"20706 8183 345.88 10348 436.35 2869 \n",
"20707 15594 1429.59 14207 1303.96 12463 \n",
"20708 11245 17223.41 14418 22047.20 2604 \n",
"\n",
" buy_elg_amount sell_elg_vol sell_elg_amount net_mf_vol \\\n",
"0 3816.45 22437 1404.58 142435 \n",
"1 882.70 7328 305.66 -48700 \n",
"2 280.52 2483 1346.40 -483 \n",
"3 0.00 0 0.00 982 \n",
"4 565.27 38602 2333.86 -103058 \n",
"0 114.50 0 0.00 8754 \n",
"1 46.96 0 0.00 -2636 \n",
"2 604.59 1196 906.98 -2186 \n",
"3 0.00 0 0.00 -2514 \n",
"4 1908.59 6045 4034.17 -2211 \n",
"... ... ... ... ... \n",
"25887 1885.53 1349 890.75 1237 \n",
"25888 1251.47 5309 751.42 8180 \n",
"25889 7924.73 33850 5182.21 -41375 \n",
"25890 3157.32 5436 1403.84 -11696 \n",
"25891 155.40 4574 714.61 1257 \n",
"20704 987.82 6038 434.35 32850 \n",
"20705 770.48 10880 960.53 -24208 \n",
"20706 120.50 5287 222.60 -5084 \n",
"20707 1140.48 2850 260.49 4058 \n",
"20708 3986.99 5543 8433.77 -7520 \n",
"\n",
" net_mf_amount \n",
"0 8918.59 \n",
"1 -2025.73 \n",
"2 -250.58 \n",
"3 64.60 \n",
"4 -6231.26 \n",
"0 1160.00 \n",
"1 -291.18 \n",
"2 -1656.29 \n",
"3 -289.80 \n",
"4 -1416.49 \n",
"... ... \n",
"25887 814.61 \n",
"25888 1173.63 \n",
"25889 -6267.77 \n",
"25890 -3055.51 \n",
"25891 191.86 \n",
"20704 2367.64 \n",
"20705 -2127.88 \n",
"20706 -213.09 \n",
"20707 379.12 \n",
"20708 -11475.67 \n",
"\n",
"[25892 rows x 20 columns]\n"
"[20709 rows x 20 columns]\n"
]
}
],
@@ -278,7 +273,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.2"
"version": "3.12.11"
}
},
"nbformat": 4,

View File

@@ -34,23 +34,23 @@
"output_type": "stream",
"text": [
" ts_code trade_date\n",
"4979 600202.SH 20260206\n",
"4980 600203.SH 20260206\n",
"4981 600206.SH 20260206\n",
"4969 600189.SH 20260206\n",
"7454 920964.BJ 20260206\n",
"4990 600201.SH 20260213\n",
"4991 600202.SH 20260213\n",
"4992 600203.SH 20260213\n",
"4980 600188.SH 20260213\n",
"7466 920946.BJ 20260213\n",
"<class 'pandas.core.frame.DataFrame'>\n",
"Index: 11812821 entries, 0 to 37293\n",
"Index: 11850195 entries, 0 to 37373\n",
"Data columns (total 2 columns):\n",
" # Column Dtype \n",
"--- ------ ----- \n",
" 0 ts_code object\n",
" 1 trade_date object\n",
"dtypes: object(2)\n",
"memory usage: 270.4+ MB\n",
"memory usage: 271.2+ MB\n",
"None\n",
"20260206\n",
"20260209\n"
"20260213\n",
"20260224\n"
]
}
],
@@ -101,12 +101,7 @@
"任务 20260227 完成\n",
"任务 20260226 完成\n",
"任务 20260225 完成\n",
"任务 20260224 完成\n",
"任务 20260213 完成\n",
"任务 20260212 完成\n",
"任务 20260211 完成\n",
"任务 20260210 完成\n",
"任务 20260209 完成\n"
"任务 20260224 完成\n"
]
}
],
@@ -158,71 +153,58 @@
"output_type": "stream",
"text": [
"[ trade_date ts_code up_limit down_limit\n",
"0 20260213 000001.SZ 12.06 9.86\n",
"1 20260213 000002.SZ 5.41 4.43\n",
"2 20260213 000004.SZ 8.36 7.56\n",
"3 20260213 000006.SZ 10.12 8.28\n",
"4 20260213 000007.SZ 13.44 11.00\n",
"0 20260227 000001.SZ 11.96 9.78\n",
"1 20260227 000002.SZ 5.30 4.34\n",
"2 20260227 000004.SZ 7.52 6.80\n",
"3 20260227 000006.SZ 10.25 8.39\n",
"4 20260227 000007.SZ 14.48 11.84\n",
"... ... ... ... ...\n",
"7476 20260213 920978.BJ 39.09 21.05\n",
"7477 20260213 920981.BJ 41.61 22.41\n",
"7478 20260213 920982.BJ 284.06 152.96\n",
"7479 20260213 920985.BJ 11.34 6.12\n",
"7480 20260213 920992.BJ 21.77 11.73\n",
"7481 20260227 920978.BJ 39.63 21.35\n",
"7482 20260227 920981.BJ 43.95 23.67\n",
"7483 20260227 920982.BJ 284.68 153.30\n",
"7484 20260227 920985.BJ 10.79 5.81\n",
"7485 20260227 920992.BJ 21.69 11.69\n",
"\n",
"[7481 rows x 4 columns], trade_date ts_code up_limit down_limit\n",
"0 20260212 000001.SZ 12.18 9.96\n",
"1 20260212 000002.SZ 5.38 4.40\n",
"2 20260212 000004.SZ 8.80 7.96\n",
"3 20260212 000006.SZ 10.29 8.42\n",
"4 20260212 000007.SZ 13.31 10.89\n",
"[7486 rows x 4 columns], trade_date ts_code up_limit down_limit\n",
"0 20260226 000001.SZ 11.95 9.77\n",
"1 20260226 000002.SZ 5.50 4.50\n",
"2 20260226 000004.SZ 7.92 7.16\n",
"3 20260226 000006.SZ 10.65 8.71\n",
"4 20260226 000007.SZ 13.87 11.35\n",
"... ... ... ... ...\n",
"7476 20260212 920978.BJ 39.93 21.51\n",
"7477 20260212 920981.BJ 41.60 22.40\n",
"7478 20260212 920982.BJ 284.29 153.09\n",
"7479 20260212 920985.BJ 11.01 5.93\n",
"7480 20260212 920992.BJ 21.86 11.78\n",
"7480 20260226 920978.BJ 40.09 21.59\n",
"7481 20260226 920981.BJ 42.57 22.93\n",
"7482 20260226 920982.BJ 285.33 153.65\n",
"7483 20260226 920985.BJ 11.08 5.98\n",
"7484 20260226 920992.BJ 21.74 11.72\n",
"\n",
"[7481 rows x 4 columns], trade_date ts_code up_limit down_limit\n",
"0 20260211 000001.SZ 12.17 9.95\n",
"1 20260211 000002.SZ 5.37 4.39\n",
"2 20260211 000004.SZ 9.26 8.38\n",
"3 20260211 000006.SZ 10.18 8.33\n",
"4 20260211 000007.SZ 13.37 10.94\n",
"[7485 rows x 4 columns], trade_date ts_code up_limit down_limit\n",
"0 20260225 000001.SZ 12.00 9.82\n",
"1 20260225 000002.SZ 5.41 4.43\n",
"2 20260225 000004.SZ 8.34 7.54\n",
"3 20260225 000006.SZ 10.20 8.34\n",
"4 20260225 000007.SZ 13.97 11.43\n",
"... ... ... ... ...\n",
"7469 20260211 920978.BJ 41.02 22.10\n",
"7470 20260211 920981.BJ 41.91 22.57\n",
"7471 20260211 920982.BJ 286.35 154.19\n",
"7472 20260211 920985.BJ 11.34 6.12\n",
"7473 20260211 920992.BJ 22.04 11.88\n",
"7477 20260225 920978.BJ 39.75 21.41\n",
"7478 20260225 920981.BJ 41.96 22.60\n",
"7479 20260225 920982.BJ 284.15 153.01\n",
"7480 20260225 920985.BJ 11.15 6.01\n",
"7481 20260225 920992.BJ 21.52 11.60\n",
"\n",
"[7474 rows x 4 columns], trade_date ts_code up_limit down_limit\n",
"0 20260210 000001.SZ 12.18 9.96\n",
"1 20260210 000002.SZ 5.46 4.46\n",
"2 20260210 000004.SZ 9.74 8.82\n",
"3 20260210 000006.SZ 10.32 8.44\n",
"4 20260210 000007.SZ 13.53 11.07\n",
"[7482 rows x 4 columns], trade_date ts_code up_limit down_limit\n",
"0 20260224 000001.SZ 12.00 9.82\n",
"1 20260224 000002.SZ 5.47 4.47\n",
"2 20260224 000004.SZ 8.78 7.94\n",
"3 20260224 000006.SZ 10.37 8.49\n",
"4 20260224 000007.SZ 13.65 11.17\n",
"... ... ... ... ...\n",
"7466 20260210 920978.BJ 41.71 22.47\n",
"7467 20260210 920981.BJ 42.05 22.65\n",
"7468 20260210 920982.BJ 289.90 156.10\n",
"7469 20260210 920985.BJ 11.83 6.37\n",
"7470 20260210 920992.BJ 22.33 12.03\n",
"7477 20260224 920978.BJ 39.05 21.03\n",
"7478 20260224 920981.BJ 41.52 22.36\n",
"7479 20260224 920982.BJ 282.77 152.27\n",
"7480 20260224 920985.BJ 11.08 5.98\n",
"7481 20260224 920992.BJ 21.32 11.48\n",
"\n",
"[7471 rows x 4 columns], trade_date ts_code up_limit down_limit\n",
"0 20260209 000001.SZ 12.16 9.95\n",
"1 20260209 000002.SZ 5.29 4.33\n",
"2 20260209 000004.SZ 10.26 9.28\n",
"3 20260209 000006.SZ 9.88 8.08\n",
"4 20260209 000007.SZ 13.00 10.64\n",
"... ... ... ... ...\n",
"7462 20260209 920978.BJ 42.45 22.87\n",
"7463 20260209 920981.BJ 41.40 22.30\n",
"7464 20260209 920982.BJ 291.70 157.08\n",
"7465 20260209 920985.BJ 11.32 6.10\n",
"7466 20260209 920992.BJ 22.13 11.93\n",
"\n",
"[7467 rows x 4 columns]]\n"
"[7482 rows x 4 columns]]\n"
]
}
],
@@ -290,7 +272,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.2"
"version": "3.12.11"
}
},
"nbformat": 4,

View File

@@ -18,10 +18,10 @@
"Please upgrade to Gymnasium, the maintained drop-in replacement of Gym, or contact the authors of your software and request that they upgrade.\n",
"Users of this version of Gym should be able to simply replace 'import gym' with 'import gymnasium as gym' in the vast majority of cases.\n",
"See the migration guide at https://gymnasium.farama.org/introduction/migration_guide/ for additional information.\n",
"[206406:MainThread](2025-12-05 23:38:39,028) INFO - qlib.Initialization - [config.py:452] - default_conf: client.\n",
"[206406:MainThread](2025-12-05 23:38:39,028) WARNING - qlib.Initialization - [config.py:459] - Unrecognized config freq\n",
"[206406:MainThread](2025-12-05 23:38:39,034) INFO - qlib.Initialization - [__init__.py:75] - qlib successfully initialized based on client settings.\n",
"[206406:MainThread](2025-12-05 23:38:39,035) INFO - qlib.Initialization - [__init__.py:77] - data_path={'__DEFAULT_FREQ': PosixPath('/mnt/d/PyProject/NewStock/data/qlib')}\n"
"[177513:MainThread](2026-02-25 22:33:43,460) INFO - qlib.Initialization - [config.py:452] - default_conf: client.\n",
"[177513:MainThread](2026-02-25 22:33:43,461) WARNING - qlib.Initialization - [config.py:459] - Unrecognized config freq\n",
"[177513:MainThread](2026-02-25 22:33:43,467) INFO - qlib.Initialization - [__init__.py:75] - qlib successfully initialized based on client settings.\n",
"[177513:MainThread](2026-02-25 22:33:43,469) INFO - qlib.Initialization - [__init__.py:77] - data_path={'__DEFAULT_FREQ': PosixPath('/mnt/d/PyProject/NewStock/data/qlib')}\n"
]
},
{
@@ -96,7 +96,7 @@
"cyq perf\n",
"left merge on ['ts_code', 'trade_date']\n",
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 9367000 entries, 0 to 9366999\n",
"RangeIndex: 9436343 entries, 0 to 9436342\n",
"Data columns (total 33 columns):\n",
" # Column Dtype \n",
"--- ------ ----- \n",
@@ -134,7 +134,7 @@
" 31 weight_avg float64 \n",
" 32 winner_rate float64 \n",
"dtypes: bool(1), datetime64[ns](1), float64(30), object(1)\n",
"memory usage: 2.2+ GB\n",
"memory usage: 2.3+ GB\n",
"None\n"
]
}
@@ -172,6 +172,38 @@
"print(df.info())"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "5f3847ec",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" trade_date return_5_rank\n",
"6527870 2024-06-03 0.523969\n",
" trade_date ma5 ma10 close\n",
"6527870 2024-06-03 10.526 10.216 10.37\n"
]
}
],
"source": [
"\n",
"df['return_5'] = df.groupby('ts_code')['close'].pct_change(periods=5)\n",
"\n",
"df['return_5_rank'] = df.groupby('trade_date')['return_5'].transform(\n",
" lambda x: (x.rank(method='average') - 1) / (x.count() - 1) if x.count() > 1 else 0.5\n",
" )\n",
"\n",
"df['ma5'] = df.groupby('ts_code')['close'].transform(lambda x: x.rolling(window=5, min_periods=1).mean())\n",
"df['ma10'] = df.groupby('ts_code')['close'].transform(lambda x: x.rolling(window=10, min_periods=1).mean())\n",
"\n",
"print(df[(df['ts_code'] == '601117.SH') & (df['trade_date'] == '2024-06-03')][['trade_date', 'return_5_rank']])\n",
"print(df[(df['ts_code'] == '601117.SH') & (df['trade_date'] == '2024-06-03')][['trade_date', 'ma5', 'ma10', 'close']])"
]
},
{
"cell_type": "code",
"execution_count": 3,
@@ -9338,7 +9370,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.11"
"version": "3.13.2"
}
},
"nbformat": 4,

View File

@@ -78,7 +78,7 @@
"cyq perf\n",
"left merge on ['ts_code', 'trade_date']\n",
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 9436343 entries, 0 to 9436342\n",
"RangeIndex: 9456764 entries, 0 to 9456763\n",
"Data columns (total 33 columns):\n",
" # Column Dtype \n",
"--- ------ ----- \n",
@@ -465,7 +465,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"id": "92d84ce15a562ec6",
"metadata": {
"ExecuteTime": {
@@ -490,17 +490,6 @@
"因子 AR, BR 计算成功。\n",
"因子 AR, BR 计算流程结束。\n"
]
},
{
"ename": "NameError",
"evalue": "name 'cashflow_df' is not defined",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[10]\u001b[39m\u001b[32m, line 43\u001b[39m\n\u001b[32m 41\u001b[39m calculate_arbr(df, N=\u001b[32m26\u001b[39m)\n\u001b[32m 42\u001b[39m df[\u001b[33m'\u001b[39m\u001b[33mlog_circ_mv\u001b[39m\u001b[33m'\u001b[39m] = np.log(df[\u001b[33m'\u001b[39m\u001b[33mcirc_mv\u001b[39m\u001b[33m'\u001b[39m])\n\u001b[32m---> \u001b[39m\u001b[32m43\u001b[39m df = calculate_cashflow_to_ev_factor(df, \u001b[43mcashflow_df\u001b[49m, balancesheet_df)\n\u001b[32m 44\u001b[39m df = caculate_book_to_price_ratio(df, fina_indicator_df)\n\u001b[32m 46\u001b[39m df = turnover_rate_n(df, n=\u001b[32m5\u001b[39m)\n",
"\u001b[31mNameError\u001b[39m: name 'cashflow_df' is not defined"
]
}
],
"source": [
@@ -551,7 +540,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 13,
"id": "da8d7a30",
"metadata": {},
"outputs": [
@@ -670,7 +659,7 @@
"Calculating cs_rank_size...\n",
"Finished cs_rank_size.\n",
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 5087384 entries, 0 to 5087383\n",
"RangeIndex: 5099462 entries, 0 to 5099461\n",
"Columns: 181 entries, ts_code to cs_rank_size\n",
"dtypes: bool(10), datetime64[ns](1), float64(165), int64(3), object(2)\n",
"memory usage: 6.5+ GB\n",
@@ -741,7 +730,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 14,
"id": "b87b938028afa206",
"metadata": {
"ExecuteTime": {
@@ -779,7 +768,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 15,
"id": "f4f16d63ad18d1bc",
"metadata": {
"ExecuteTime": {
@@ -1005,7 +994,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 16,
"id": "40e6b68a91b30c79",
"metadata": {
"ExecuteTime": {
@@ -1325,7 +1314,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 17,
"id": "47c12bb34062ae7a",
"metadata": {
"ExecuteTime": {
@@ -1359,7 +1348,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 18,
"id": "29221dde",
"metadata": {},
"outputs": [
@@ -1402,7 +1391,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 19,
"id": "03ee5daf",
"metadata": {},
"outputs": [],
@@ -1415,7 +1404,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 20,
"id": "b76ea08a",
"metadata": {},
"outputs": [
@@ -1424,9 +1413,9 @@
"output_type": "stream",
"text": [
" ts_code trade_date log_circ_mv\n",
"5087381 605599.SH 2026-02-11 14.480487\n",
"5087382 605599.SH 2026-02-12 14.482485\n",
"5087383 605599.SH 2026-02-13 14.493206\n",
"5099459 605599.SH 2026-02-25 14.472051\n",
"5099460 605599.SH 2026-02-26 14.452910\n",
"5099461 605599.SH 2026-02-27 14.472455\n",
"['vol', 'pct_chg', 'turnover_rate', 'volume_ratio', 'winner_rate', 'undist_profit_ps', 'ocfps', 'AR', 'BR', 'AR_BR', 'cashflow_to_ev_factor', 'book_to_price_ratio', 'turnover_rate_mean_5', 'variance_20', 'bbi_ratio_factor', 'daily_deviation', 'lg_elg_net_buy_vol', 'flow_lg_elg_intensity', 'sm_net_buy_vol', 'total_buy_vol', 'lg_elg_buy_prop', 'flow_struct_buy_change', 'lg_elg_net_buy_vol_change', 'flow_lg_elg_accel', 'chip_concentration_range', 'chip_skewness', 'floating_chip_proxy', 'cost_support_15pct_change', 'cat_winner_price_zone', 'flow_chip_consistency', 'profit_taking_vs_absorb', 'cat_is_positive', 'upside_vol', 'downside_vol', 'vol_ratio', 'return_skew', 'return_kurtosis', 'volume_change_rate', 'cat_volume_breakout', 'turnover_deviation', 'cat_turnover_spike', 'avg_volume_ratio', 'cat_volume_ratio_breakout', 'vol_spike', 'vol_std_5', 'atr_14', 'atr_6', 'obv', 'maobv_6', 'rsi_3', 'return_5', 'return_20', 'std_return_5', 'std_return_90', 'std_return_90_2', 'act_factor1', 'act_factor2', 'act_factor3', 'act_factor4', 'rank_act_factor1', 'rank_act_factor2', 'rank_act_factor3', 'cov', 'delta_cov', 'alpha_22_improved', 'alpha_003', 'alpha_007', 'alpha_013', 'vol_break', 'weight_roc5', 'smallcap_concentration', 'cost_stability', 'high_cost_break_days', 'liquidity_risk', 'turnover_std', 'mv_volatility', 'volume_growth', 'mv_growth', 'momentum_factor', 'resonance_factor', 'log_close', 'cat_vol_spike', 'up', 'down', 'obv_maobv_6', 'std_return_5_over_std_return_90', 'std_return_90_minus_std_return_90_2', 'cat_af2', 'cat_af3', 'cat_af4', 'act_factor5', 'act_factor6', 'active_buy_volume_large', 'active_buy_volume_big', 'active_buy_volume_small', 'buy_lg_vol_minus_sell_lg_vol', 'buy_elg_vol_minus_sell_elg_vol', 'ctrl_strength', 'low_cost_dev', 'asymmetry', 'lock_factor', 'cat_vol_break', 'cost_atr_adj', 'cat_golden_resonance', 'mv_turnover_ratio', 'mv_adjusted_volume', 'mv_weighted_turnover', 'nonlinear_mv_volume', 'mv_volume_ratio', 'mv_momentum', 'lg_flow_mom_corr_20_60', 'lg_flow_accel', 'profit_pressure', 'underwater_resistance', 'cost_conc_std_20', 'profit_decay_20', 'vol_amp_loss_20', 'vol_drop_profit_cnt_5', 'lg_flow_vol_interact_20', 'cost_break_confirm_cnt_5', 'atr_norm_channel_pos_14', 'turnover_diff_skew_20', 'lg_sm_flow_diverge_20', 'pullback_strong_20_20', 'vol_wgt_hist_pos_20', 'vol_adj_roc_20', 'cs_rank_net_lg_flow_val', 'cs_rank_elg_buy_ratio', 'cs_rank_rel_profit_margin', 'cs_rank_cost_breadth', 'cs_rank_dist_to_upper_cost', 'cs_rank_winner_rate', 'cs_rank_intraday_range', 'cs_rank_close_pos_in_range', 'cs_rank_pos_in_hist_range', 'cs_rank_vol_x_profit_margin', 'cs_rank_lg_flow_price_concordance', 'cs_rank_turnover_per_winner', 'cs_rank_volume_ratio', 'cs_rank_elg_buy_sell_sm_ratio', 'cs_rank_cost_dist_vol_ratio', 'cs_rank_size', 'cat_up_limit', 'industry_obv', 'industry_return_5', 'industry_return_20', 'industry__ema_5', 'industry__ema_13', 'industry__ema_20', 'industry__ema_60', 'industry_act_factor1', 'industry_act_factor2', 'industry_act_factor3', 'industry_act_factor4', 'industry_act_factor5', 'industry_act_factor6', 'industry_rank_act_factor1', 'industry_rank_act_factor2', 'industry_rank_act_factor3', 'industry_return_5_percentile', 'industry_return_20_percentile', '000852.SH_MACD', '000905.SH_MACD', '399006.SZ_MACD', '000852.SH_MACD_hist', '000905.SH_MACD_hist', '399006.SZ_MACD_hist', '000852.SH_RSI', '000905.SH_RSI', '399006.SZ_RSI', '000852.SH_Signal_line', '000905.SH_Signal_line', '399006.SZ_Signal_line', '000852.SH_amount_change_rate', '000905.SH_amount_change_rate', '399006.SZ_amount_change_rate', '000852.SH_amount_mean', '000905.SH_amount_mean', '399006.SZ_amount_mean', '000852.SH_daily_return', '000905.SH_daily_return', '399006.SZ_daily_return', '000852.SH_up_ratio_20d', '000905.SH_up_ratio_20d', '399006.SZ_up_ratio_20d', '000852.SH_volatility', '000905.SH_volatility', '399006.SZ_volatility', '000852.SH_volume_change_rate', '000905.SH_volume_change_rate', '399006.SZ_volume_change_rate']\n",
"去除极值\n",
"开始截面 MAD 去极值处理 (k=3.0)...\n"
@@ -1436,7 +1425,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"MAD Filtering: 100%|██████████| 131/131 [00:15<00:00, 8.70it/s]\n"
"MAD Filtering: 100%|██████████| 131/131 [00:13<00:00, 9.58it/s]\n"
]
},
{
@@ -1451,7 +1440,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"MAD Filtering: 100%|██████████| 131/131 [00:15<00:00, 8.47it/s]\n"
"MAD Filtering: 100%|██████████| 131/131 [00:15<00:00, 8.43it/s]\n"
]
},
{
@@ -1491,13 +1480,13 @@
"截面 MAD 去极值处理完成。\n",
"feature_columns: ['vol', 'pct_chg', 'turnover_rate', 'volume_ratio', 'winner_rate', 'undist_profit_ps', 'ocfps', 'AR', 'BR', 'AR_BR', 'cashflow_to_ev_factor', 'book_to_price_ratio', 'turnover_rate_mean_5', 'variance_20', 'bbi_ratio_factor', 'daily_deviation', 'lg_elg_net_buy_vol', 'flow_lg_elg_intensity', 'sm_net_buy_vol', 'total_buy_vol', 'lg_elg_buy_prop', 'flow_struct_buy_change', 'lg_elg_net_buy_vol_change', 'flow_lg_elg_accel', 'chip_concentration_range', 'chip_skewness', 'floating_chip_proxy', 'cost_support_15pct_change', 'cat_winner_price_zone', 'flow_chip_consistency', 'profit_taking_vs_absorb', 'cat_is_positive', 'upside_vol', 'downside_vol', 'vol_ratio', 'return_skew', 'return_kurtosis', 'volume_change_rate', 'cat_volume_breakout', 'turnover_deviation', 'cat_turnover_spike', 'avg_volume_ratio', 'cat_volume_ratio_breakout', 'vol_spike', 'vol_std_5', 'atr_14', 'atr_6', 'obv', 'maobv_6', 'rsi_3', 'return_5', 'return_20', 'std_return_5', 'std_return_90', 'std_return_90_2', 'act_factor1', 'act_factor2', 'act_factor3', 'act_factor4', 'rank_act_factor1', 'rank_act_factor2', 'rank_act_factor3', 'cov', 'delta_cov', 'alpha_22_improved', 'alpha_003', 'alpha_007', 'alpha_013', 'vol_break', 'weight_roc5', 'smallcap_concentration', 'cost_stability', 'high_cost_break_days', 'liquidity_risk', 'turnover_std', 'mv_volatility', 'volume_growth', 'mv_growth', 'momentum_factor', 'resonance_factor', 'log_close', 'cat_vol_spike', 'up', 'down', 'obv_maobv_6', 'std_return_5_over_std_return_90', 'std_return_90_minus_std_return_90_2', 'cat_af2', 'cat_af3', 'cat_af4', 'act_factor5', 'act_factor6', 'active_buy_volume_large', 'active_buy_volume_big', 'active_buy_volume_small', 'buy_lg_vol_minus_sell_lg_vol', 'buy_elg_vol_minus_sell_elg_vol', 'ctrl_strength', 'low_cost_dev', 'asymmetry', 'lock_factor', 'cat_vol_break', 'cost_atr_adj', 'cat_golden_resonance', 'mv_turnover_ratio', 'mv_adjusted_volume', 'mv_weighted_turnover', 'nonlinear_mv_volume', 'mv_volume_ratio', 'mv_momentum', 'lg_flow_mom_corr_20_60', 'lg_flow_accel', 'profit_pressure', 'underwater_resistance', 'cost_conc_std_20', 'profit_decay_20', 'vol_amp_loss_20', 'vol_drop_profit_cnt_5', 'lg_flow_vol_interact_20', 'cost_break_confirm_cnt_5', 'atr_norm_channel_pos_14', 'turnover_diff_skew_20', 'lg_sm_flow_diverge_20', 'pullback_strong_20_20', 'vol_wgt_hist_pos_20', 'vol_adj_roc_20', 'cs_rank_net_lg_flow_val', 'cs_rank_elg_buy_ratio', 'cs_rank_rel_profit_margin', 'cs_rank_cost_breadth', 'cs_rank_dist_to_upper_cost', 'cs_rank_winner_rate', 'cs_rank_intraday_range', 'cs_rank_close_pos_in_range', 'cs_rank_pos_in_hist_range', 'cs_rank_vol_x_profit_margin', 'cs_rank_lg_flow_price_concordance', 'cs_rank_turnover_per_winner', 'cs_rank_volume_ratio', 'cs_rank_elg_buy_sell_sm_ratio', 'cs_rank_cost_dist_vol_ratio', 'cs_rank_size', 'cat_up_limit', 'industry_obv', 'industry_return_5', 'industry_return_20', 'industry__ema_5', 'industry__ema_13', 'industry__ema_20', 'industry__ema_60', 'industry_act_factor1', 'industry_act_factor2', 'industry_act_factor3', 'industry_act_factor4', 'industry_act_factor5', 'industry_act_factor6', 'industry_rank_act_factor1', 'industry_rank_act_factor2', 'industry_rank_act_factor3', 'industry_return_5_percentile', 'industry_return_20_percentile', '000852.SH_MACD', '000905.SH_MACD', '399006.SZ_MACD', '000852.SH_MACD_hist', '000905.SH_MACD_hist', '399006.SZ_MACD_hist', '000852.SH_RSI', '000905.SH_RSI', '399006.SZ_RSI', '000852.SH_Signal_line', '000905.SH_Signal_line', '399006.SZ_Signal_line', '000852.SH_amount_change_rate', '000905.SH_amount_change_rate', '399006.SZ_amount_change_rate', '000852.SH_amount_mean', '000905.SH_amount_mean', '399006.SZ_amount_mean', '000852.SH_daily_return', '000905.SH_daily_return', '399006.SZ_daily_return', '000852.SH_up_ratio_20d', '000905.SH_up_ratio_20d', '399006.SZ_up_ratio_20d', '000852.SH_volatility', '000905.SH_volatility', '399006.SZ_volatility', '000852.SH_volume_change_rate', '000905.SH_volume_change_rate', '399006.SZ_volume_change_rate']\n",
"df最小日期: 2019-01-02\n",
"df最大日期: 2026-02-13\n",
"2055886\n",
"df最大日期: 2026-02-27\n",
"2055833\n",
"train_data最小日期: 2020-01-02\n",
"train_data最大日期: 2022-12-30\n",
"2312688\n",
"2324725\n",
"test_data最小日期: 2023-01-03\n",
"test_data最大日期: 2026-02-13\n",
"test_data最大日期: 2026-02-27\n",
" ts_code trade_date log_circ_mv\n",
"0 000001.SZ 2019-01-02 16.574219\n",
"1 000001.SZ 2019-01-03 16.583965\n",
@@ -1633,7 +1622,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 21,
"id": "3ff2d1c5",
"metadata": {},
"outputs": [],
@@ -1774,17 +1763,17 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 22,
"id": "a5bbb8be",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<catboost.core.CatBoostClassifier at 0x71335a72d1c0>"
"<catboost.core.CatBoostClassifier at 0x735a75be3050>"
]
},
"execution_count": 21,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -1799,7 +1788,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 26,
"id": "5d1522a7538db91b",
"metadata": {
"ExecuteTime": {
@@ -1838,7 +1827,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 27,
"id": "09b1799e",
"metadata": {},
"outputs": [
@@ -1860,7 +1849,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 28,
"id": "e53b209a",
"metadata": {},
"outputs": [
@@ -1868,7 +1857,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"5584 2055886\n",
"5584 2055833\n",
" ts_code trade_date turnover_rate\n",
"0 000001.SZ 2023-01-03 1.1307\n",
"1 000001.SZ 2023-01-04 1.1284\n",
@@ -1876,13 +1865,13 @@
"3 000001.SZ 2023-01-06 0.6162\n",
"4 000001.SZ 2023-01-09 0.5450\n",
"... ... ... ...\n",
"2312683 605599.SH 2026-02-09 2.6607\n",
"2312684 605599.SH 2026-02-10 2.5722\n",
"2312685 605599.SH 2026-02-11 2.1806\n",
"2312686 605599.SH 2026-02-12 1.4513\n",
"2312687 605599.SH 2026-02-13 1.5153\n",
"2324720 605599.SH 2026-02-13 1.5153\n",
"2324721 605599.SH 2026-02-24 1.1366\n",
"2324722 605599.SH 2026-02-25 1.2631\n",
"2324723 605599.SH 2026-02-26 0.9249\n",
"2324724 605599.SH 2026-02-27 0.8492\n",
"\n",
"[2312688 rows x 3 columns]\n"
"[2324725 rows x 3 columns]\n"
]
}
],

File diff suppressed because it is too large Load Diff

View File

@@ -49,6 +49,19 @@ class ConfigResponse(BaseModel):
reconnect_time: str
auto_reconnect_enabled: bool
class MessageItem(BaseModel):
"""消息项模型"""
message_id: str
data: Dict[str, Any]
timestamp: str
is_processed: bool = False
class MessagesResponse(BaseModel):
"""消息响应模型"""
messages: List[MessageItem]
total: int
strategy_name: str
class FileConfigResponse(BaseModel):
"""配置文件响应模型"""
@@ -325,6 +338,116 @@ class QMTAPIServer:
raw_config=f"读取配置文件失败: {str(e)}",
config_path=config_path
)
@self.app.get("/api/messages", response_model=MessagesResponse, summary="获取Redis消息")
def get_messages(
strategy: str = Query("all", description="策略名称all表示所有策略"),
count: int = Query(50, ge=1, le=200, description="获取消息数量"),
is_backtest: bool = Query(False, description="是否为回测消息")
):
"""从Redis Stream获取消息列表"""
messages = []
try:
# 从manager获取redis连接
if hasattr(self.manager, 'pos_manager') and self.manager.pos_manager:
r = self.manager.pos_manager.r
elif hasattr(self.manager, 'stream_processor') and self.manager.stream_processor:
r = self.manager.stream_processor.r
else:
# 尝试从配置创建连接
import redis
redis_config = getattr(self.manager.config, 'redis', {})
r = redis.Redis(
host=redis_config.get('host', 'localhost'),
port=redis_config.get('port', 6379),
password=redis_config.get('password'),
db=redis_config.get('db', 0),
decode_responses=True
)
if strategy == "all":
# 获取所有策略的消息
pattern = f"qmt:*:{'backtest' if is_backtest else 'real'}"
stream_keys = []
for key in r.scan_iter(match=pattern):
stream_keys.append(key)
else:
# 获取指定策略的消息
stream_key = f"qmt:{strategy}:{'backtest' if is_backtest else 'real'}"
stream_keys = [stream_key]
# 从每个stream读取消息
for stream_key in stream_keys:
try:
# 使用XREVRANGE获取最新消息
stream_msgs = r.xrevrange(stream_key, max="+", min="-", count=count)
for msg_id, msg_fields in stream_msgs:
# 解析消息数据
data_str = msg_fields.get("data", "{}")
try:
data = json.loads(data_str)
except json.JSONDecodeError:
data = {"raw_data": data_str}
# 解析消息ID获取时间戳
# Redis消息ID格式: timestamp-sequence
timestamp_ms = int(msg_id.split("-")[0])
timestamp = datetime.datetime.fromtimestamp(
timestamp_ms / 1000
).strftime('%Y-%m-%d %H:%M:%S')
# 检查消息是否已处理通过检查pending列表
is_processed = True
try:
# 获取消费者组的pending消息
pending_info = r.xpending(
stream_key,
"qmt_consumers"
)
# 如果消息在pending列表中说明还未确认
if pending_info and pending_info.get('pending', 0) > 0:
# 获取具体的pending消息ID
pending_range = r.xpending_range(
stream_key,
"qmt_consumers",
min="-",
max="+",
count=100
)
pending_ids = [item['message_id'] for item in pending_range] if pending_range else []
is_processed = msg_id not in pending_ids
except:
# 如果没有消费者组或出错,默认认为已处理
is_processed = True
messages.append(MessageItem(
message_id=msg_id,
data=data,
timestamp=timestamp,
is_processed=is_processed
))
except Exception as e:
logging.error(f"读取stream {stream_key}失败: {e}")
continue
# 按时间戳倒序排序
messages.sort(key=lambda x: x.timestamp, reverse=True)
return MessagesResponse(
messages=messages[:count],
total=len(messages),
strategy_name=strategy
)
except Exception as e:
logging.error(f"获取消息失败: {e}")
return MessagesResponse(
messages=[],
total=0,
strategy_name=strategy
)
def get_app(self) -> FastAPI:
"""获取FastAPI应用实例"""

View File

@@ -131,6 +131,28 @@
</n-gi>
</n-grid>
<!-- 消息列表 -->
<n-card title="消息列表" style="margin-top: 20px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);">
<template #header-extra>
<div style="display: flex; align-items: center; gap: 12px;">
<n-select v-model:value="messageFilter.strategy" :options="strategyOptions" size="small" style="width: 120px;" @update:value="fetchMessages" />
<n-tag :type="messageStats.unprocessed > 0 ? 'error' : 'success'">
{{ messageStats.unprocessed }} 未处理 / {{ messages.length }} 总计
</n-tag>
<n-button type="primary" size="small" @click="fetchMessages" :loading="messageLoading">刷新</n-button>
</div>
</template>
<n-data-table
:columns="messageColumns"
:data="messages"
size="small"
:bordered="false"
:single-line="false"
:pagination="messagePagination"
:loading="messageLoading"
/>
</n-card>
<!-- 日志 -->
<n-card title="系统日志" style="margin-top: 20px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);">
<template #header-extra>
@@ -212,8 +234,8 @@
</div>
<script>
const { createApp, ref, onMounted, onUnmounted, computed, watch } = Vue;
const { NCard, NButton, NTag, NGrid, NGi, NDescriptions, NDescriptionsItem, NDataTable, NStatistic, NConfigProvider, NMessageProvider, NNotificationProvider, NDialogProvider, NModal, NTabs, NTabPane, NEmpty } = naive;
const { createApp, ref, onMounted, onUnmounted, computed, watch, h } = Vue;
const { NCard, NButton, NTag, NGrid, NGi, NDescriptions, NDescriptionsItem, NDataTable, NStatistic, NConfigProvider, NMessageProvider, NNotificationProvider, NDialogProvider, NModal, NTabs, NTabPane, NEmpty, NSelect } = naive;
const app = createApp({
setup() {
@@ -230,6 +252,74 @@
const showConfigModal = ref(false);
const fileConfig = ref({ redis: {}, qmt_terminals: [], strategies: {}, raw_config: "", config_path: "" });
const configLoading = ref(false);
// 消息相关
const messages = ref([]);
const messageLoading = ref(false);
const messageFilter = ref({ strategy: 'all' });
const messagePagination = ref({ page: 1, pageSize: 10, showSizePicker: true, pageSizes: [10, 20, 50] });
// 消息表格列
const messageColumns = [
{ title: '时间', key: 'timestamp', width: 150, fixed: 'left' },
{
title: '策略',
key: 'strategy',
width: 120,
render: (row) => row.data.strategy_name || '-'
},
{
title: '股票代码',
key: 'stock_code',
width: 100,
render: (row) => row.data.stock_code || '-'
},
{
title: '动作',
key: 'action',
width: 80,
render: (row) => {
const action = row.data.action;
if (action === 'BUY') return h(NTag, { type: 'error', size: 'small' }, { default: () => '买入' });
if (action === 'SELL') return h(NTag, { type: 'success', size: 'small' }, { default: () => '卖出' });
return action || '-';
}
},
{
title: '价格',
key: 'price',
width: 100,
render: (row) => row.data.price ? '¥' + row.data.price.toFixed(2) : '-'
},
{ title: '状态', key: 'is_processed', width: 100, render: (row) => {
return row.is_processed
? h(NTag, { type: 'success', size: 'small' }, { default: () => '已处理' })
: h(NTag, { type: 'warning', size: 'small' }, { default: () => '待处理' });
}},
{
title: '消息ID',
key: 'message_id',
width: 180,
ellipsis: { tooltip: true }
},
];
// 策略选项
const strategyOptions = computed(() => {
const options = [{ label: '全部策略', value: 'all' }];
if (fileConfig.value.strategies) {
Object.keys(fileConfig.value.strategies).forEach(name => {
options.push({ label: name, value: name });
});
}
return options;
});
// 消息统计
const messageStats = computed(() => {
const unprocessed = messages.value.filter(m => !m.is_processed).length;
return { unprocessed, total: messages.value.length };
});
// 表格列(使用简单 render不依赖 h 函数)
const realPosColumns = [
@@ -326,6 +416,23 @@
}
};
// 获取消息列表
const fetchMessages = async () => {
messageLoading.value = true;
try {
const strategy = messageFilter.value.strategy;
const url = `${API_BASE}/api/messages?strategy=${strategy}&count=50`;
const res = await fetch(url).then(r => r.ok ? r.json() : { messages: [] });
messages.value = res.messages || [];
console.log('[DEBUG] 消息已更新', messages.value.length);
} catch (e) {
console.error('[MESSAGES] 获取消息失败:', e);
messages.value = [];
} finally {
messageLoading.value = false;
}
};
// 复制配置到剪贴板
const copyConfig = () => {
if (fileConfig.value.raw_config) {
@@ -353,7 +460,7 @@
}
});
onMounted(() => { fetchData(); timer = setInterval(fetchData, 30000); });
onMounted(() => { fetchData(); fetchMessages(); timer = setInterval(() => { fetchData(); fetchMessages(); }, 30000); });
onUnmounted(() => { if (timer) clearInterval(timer); unwatch(); });
return {
@@ -366,7 +473,10 @@
realPosColumns, virtualPosColumns,
// 配置相关
showConfigModal, fileConfig, configLoading,
fetchConfig, copyConfig
fetchConfig, copyConfig,
// 消息相关
messages, messageLoading, messageFilter, messagePagination,
messageColumns, strategyOptions, messageStats, fetchMessages
};
}
});
@@ -375,4 +485,4 @@
app.mount('#app');
</script>
</body>
</html>
</html>

View File

@@ -725,11 +725,15 @@ class MultiEngineManager:
)
if is_trading:
for s_name in self.config.strategies.keys():
self.process_route(s_name)
self.process_route(s_name)
self.process_route(s_name, is_trading_hours=True)
self.process_route(s_name, is_trading_hours=True)
else:
# 休盘后:消费消息但不下单
for s_name in self.config.strategies.keys():
self.process_route(s_name, is_trading_hours=False)
# --- 收盘结算与标志位重置 ---
elif "150500" <= curr_hms <= "151500":
if "150500" <= curr_hms <= "151500":
for unit in self.units.values():
if unit.settler and not unit.settler.has_settled:
unit.settler.run_settlement()
@@ -744,19 +748,20 @@ class MultiEngineManager:
self.logger.error(traceback.format_exc())
time.sleep(10)
def process_route(self, strategy_name):
def process_route(self, strategy_name, is_trading_hours=True):
"""处理策略消息路由 - 使用 Redis Stream
从 Redis Stream 消费消息,处理成功后 ACK失败则进入失败队列。
Args:
strategy_name: 策略名称
is_trading_hours: 是否在交易时间内False 表示休盘后只消费消息不下单
"""
strat_cfg = self.config.get_strategy(strategy_name)
if not strat_cfg:
self.logger.warning(f"[{strategy_name}] 策略配置不存在")
return
unit = self.units.get(strat_cfg.qmt_id)
if not unit or not unit.callback or not unit.callback.is_connected:
return
unit = self.units.get(strat_cfg.get("qmt_id"))
if not unit or not unit.callback or not unit.callback.is_connected:
return
@@ -808,19 +813,37 @@ class MultiEngineManager:
result=True,
)
# 3. 执行交易动作
# 3. 执行交易动作(仅在交易时间内执行实际下单)
action = data.get("action")
# 获取策略配置,确定下单模式
# 获取策略配置,确定下单模式
strat_cfg = self.config.get_strategy(strategy_name)
if not strat_cfg:
self.logger.warning(f"[{strategy_name}] 策略配置不存在")
continue
order_mode = strat_cfg.order_mode
order_mode = strat_cfg.order_mode
order_mode = strat_cfg.get("order_mode", "slots")
if action == "BUY":
if not is_trading_hours:
# 休盘后:只记录日志,不下单
self.logger.info(
f"[{strategy_name}] [休盘后消息处理] "
f"action={action}, code={data.get('stock_code')}, "
f"order_mode={order_mode}, msg_time={data.get('timestamp')} - "
f"仅消费消息,跳过实际下单"
)
self.qmt_logger.log_validation(
validation_type="market_hours_check",
strategy_name=strategy_name,
details={
"action": action,
"code": data.get("stock_code"),
"order_mode": order_mode,
"msg_time": data.get("timestamp"),
"skip_reason": "休盘后只消费消息不下单"
},
result=True,
)
elif action == "BUY":
self.qmt_logger.log_validation(
validation_type="action_check",
strategy_name=strategy_name,