Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(china-a): apply board price limits to 301, 689 and Beijing 920 codes

Rudy Celekli3d7b5d17265a
diff --git a/agent/backtest/engines/china_a.py b/agent/backtest/engines/china_a.py
index 7d10e4239..8831c568a 100644
--- a/agent/backtest/engines/china_a.py
+++ b/agent/backtest/engines/china_a.py
@@ -164,12 +164,13 @@ def _price_limit(symbol: str) -> float:
Limit as fraction (0.10, 0.20, or 0.05).
"""
code = symbol.split(".")[0] if "." in symbol else symbol
- # ChiNext (300xxx) / STAR (688xxx): ±20%
- if code.startswith("300") or code.startswith("688"):
+ # ChiNext (300xxx/301xxx) / STAR (688xxx, 689xxx CDRs): ±20%
+ if code.startswith(("300", "301", "688", "689")):
return 0.20
# ST stocks: ±5% (heuristic: can't fully detect from code alone)
- # Beijing exchange (8xxxxx): ±30% — simplified to 0.30
- if code.startswith("8") and len(code) == 6:
+ # Beijing exchange: ±30%. Current codes are 920xxx; legacy 4xxxxx/8xxxxx
+ # codes remain in historical data.
+ if len(code) == 6 and code.startswith(("4", "8", "920")):
return 0.30
# Main board: ±10%
return 0.10
diff --git a/agent/tests/test_china_a_engine.py b/agent/tests/test_china_a_engine.py
index dcd5061a1..356cb0778 100644
--- a/agent/tests/test_china_a_engine.py
+++ b/agent/tests/test_china_a_engine.py
@@ -253,6 +253,12 @@ class TestPriceLimit:
("300750.SZ", 0.20), # ChiNext
("688001.SH", 0.20), # STAR Market
("830799.BJ", 0.30), # Beijing
+ ("301269.SZ", 0.20), # ChiNext 301 segment
+ ("689009.SH", 0.20), # STAR Market CDR
+ ("430047.BJ", 0.30), # Beijing legacy 43 segment
+ ("920002.BJ", 0.30), # Beijing current 920 segment
+ ("002594.SZ", 0.10), # SZSE main board
+ ("900901.SH", 0.10), # SSE B-share stays on the default band
],
)
def test_price_limits(self, symbol: str, expected: float) -> None: