"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(tools): lockup free_shares is the unlock, not the float (#1513)
Haozhe Wubc7abd14fd11
diff --git "a/agent/src/skills/eastmoney/references/\345\217\202\350\200\203\346\225\260\346\215\256/\351\231\220\345\224\256\350\247\243\347\246\201.md" "b/agent/src/skills/eastmoney/references/\345\217\202\350\200\203\346\225\260\346\215\256/\351\231\220\345\224\256\350\247\243\347\246\201.md"index 2bb075fad..0dbc54b98 100644--- "a/agent/src/skills/eastmoney/references/\345\217\202\350\200\203\346\225\260\346\215\256/\351\231\220\345\224\256\350\247\243\347\246\201.md"+++ "b/agent/src/skills/eastmoney/references/\345\217\202\350\200\203\346\225\260\346\215\256/\351\231\220\345\224\256\350\247\243\347\246\201.md"@@ -45,13 +45,14 @@ SECURITY_CODE | code | str | 代码SECURITY_NAME_ABBR | name | str | 简称FREE_DATE | free_date | str | 解禁日(取 `YYYY-MM-DD`)FREE_SHARES_TYPE | share_type | str | 解禁股份类型-FREE_SHARES | free_shares | float | 解禁股数-ABLE_FREE_SHARES | able_free_shares | float | 实际可流通股数-LIFT_MARKET_CAP | lift_market_cap | float | 解禁市值-FREE_RATIO | free_ratio | float | 占流通股比-TOTAL_RATIO | total_ratio | float | 占总股本比--无 code 或 free_date 的行被丢弃;记录上限 200。信封:`{"ok": true, "market": "a_share", "source": "eastmoney", "data": {"scope": "single_code"|"market_calendar", "count", "records":[...], ("code") | ("horizon_days","as_of"), ("truncated")}}`。+CURRENT_FREE_SHARES | free_shares | float | 解禁股数(万股)+ABLE_FREE_SHARES | able_free_shares | float | 实际可流通股数(万股)+FREE_SHARES | float_shares | float | 流通股数(万股);`FREE_RATIO` 的分母,不是解禁股数+LIFT_MARKET_CAP | lift_market_cap | float | 解禁市值(万元)+FREE_RATIO | free_ratio | float | 占流通股比(小数,= 解禁股数 / 流通股数)+TOTAL_RATIO | total_ratio | float | 占总股本比(小数)++无 code 或 free_date 的行被丢弃;记录上限 200。信封:`{"ok": true, "market": "a_share", "source": "eastmoney", "data": {"scope": "single_code"|"market_calendar", "count", "records":[...], "units", ("code") | ("horizon_days","as_of"), ("truncated")}}`,`units` 注明各字段单位。<br>diff --git a/agent/src/tools/lockup_expiry_tool.py b/agent/src/tools/lockup_expiry_tool.pyindex dcc4307ce..2d02631d2 100644--- a/agent/src/tools/lockup_expiry_tool.py+++ b/agent/src/tools/lockup_expiry_tool.py@@ -148,14 +148,28 @@ def _shape_record(raw: Any) -> dict[str, Any] | None:"name": raw.get("SECURITY_NAME_ABBR"),"free_date": str(free_date)[:10],"share_type": raw.get("FREE_SHARES_TYPE"),- "free_shares": _to_float(raw.get("FREE_SHARES")),+ # RPT_LIFT_STAGE's FREE_SHARES is the float the unlock is measured+ # against (FREE_RATIO = CURRENT_FREE_SHARES / FREE_SHARES), not the+ # unlock: 603162 on 2026-09-21 unlocked 232.88 of 42,489.17 (万股).+ "free_shares": _to_float(raw.get("CURRENT_FREE_SHARES")),"able_free_shares": _to_float(raw.get("ABLE_FREE_SHARES")),+ "float_shares": _to_float(raw.get("FREE_SHARES")),"lift_market_cap": _to_float(raw.get("LIFT_MARKET_CAP")),"free_ratio": _to_float(raw.get("FREE_RATIO")),"total_ratio": _to_float(raw.get("TOTAL_RATIO")),}+# Eastmoney reports share counts in 万股 and market value in 万元.+_UNITS = {+ "free_shares": "10k shares (万股)",+ "able_free_shares": "10k shares (万股)",+ "float_shares": "10k shares (万股)",+ "lift_market_cap": "10k CNY (万元)",+ "free_ratio": "fraction of float_shares",+ "total_ratio": "fraction of total shares",+}+_EMPTY_RESULT_MESSAGES = ("返回数据为空",)@@ -284,6 +298,7 @@ def get_lockup_expiry(code: str | None, horizon_days: int) -> str:"scope": scope,"count": len(records),"records": records,+ "units": _UNITS,}if bare_code is not None:data["code"] = bare_codediff --git a/agent/tests/test_lockup_expiry_tool.py b/agent/tests/test_lockup_expiry_tool.pyindex 0cfd03a95..9537fb138 100644--- a/agent/tests/test_lockup_expiry_tool.py+++ b/agent/tests/test_lockup_expiry_tool.py@@ -8,6 +8,8 @@ this tool's parsing both run while nothing hits the network.from __future__ import annotations+import pytest+import jsonfrom datetime import datefrom unittest.mock import patch@@ -30,6 +32,7 @@ def _row(code: str, free_date: str) -> dict:"FREE_DATE": f"{free_date} 00:00:00","FREE_SHARES_TYPE": "首发原股东限售股份","FREE_SHARES": 1000000.0,+ "CURRENT_FREE_SHARES": 900000.0,"ABLE_FREE_SHARES": 900000.0,"LIFT_MARKET_CAP": 1.7e9,"FREE_RATIO": 0.8,@@ -190,3 +193,30 @@ class TestEndToEndHttpMocked:assert kwargs["params"]["reportName"] == "RPT_LIFT_STAGE"assert out["ok"] is Trueassert out["data"]["records"][0]["name"] == "贵州茅台"+++def test_free_shares_is_the_unlock_not_the_float() -> None:+ """RPT_LIFT_STAGE's FREE_SHARES is the float FREE_RATIO divides by (#1513).++ Row as served live for 603162 on 2026-09-21.+ """+ from src.tools.lockup_expiry_tool import _shape_record++ record = _shape_record(+ {+ "SECURITY_CODE": "603162",+ "SECURITY_NAME_ABBR": "海通发展",+ "FREE_DATE": "2026-09-21 00:00:00",+ "FREE_SHARES_TYPE": "股权激励限售股份",+ "FREE_SHARES": 42489.1666,+ "CURRENT_FREE_SHARES": 232.8832,+ "ABLE_FREE_SHARES": 232.8832,+ "LIFT_MARKET_CAP": 3355.846912,+ "FREE_RATIO": 0.005481001833,+ "TOTAL_RATIO": 0.001693562627,+ }+ )++ assert record["free_shares"] == 232.8832+ assert record["float_shares"] == 42489.1666+ assert record["free_ratio"] == pytest.approx(record["free_shares"] / record["float_shares"], rel=1e-6)