"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix: Use authoritative A-share exchange suffixes when choosing the strategy benchmark for any source.
Rudy Celeklie4c1419c8a35
diff --git a/README.md b/README.mdindex b359b3ac8..f4902943d 100644--- a/README.md+++ b/README.md@@ -817,6 +817,8 @@ Run `vibe-trading alpha list` to browse, `vibe-trading alpha show <id>` for form| **Composite** | cross-market | one shared capital pool across markets (`source="auto"`) || **options_portfolio** | options | multi-leg, Greeks, payoff/scenario |+Benchmark selection honors `.SH`, `.SZ`, and `.BJ` A-share suffixes independently of the chosen loader, including offline local sources.+Bars: 1m / 5m / 15m / 30m / 1H / 4H / 1D, plus weekly / monthly (1W / 1M, built from daily bars). 15 metrics + benchmark comparison, **5 portfolio optimizers** (equal-volatility / risk-parity / mean-variance / max-diversification / turnover-aware), and 3 validation tools (Monte Carlo / Bootstrap / Walk-Forward).The turnover-aware optimizer validates per-name and group caps for single-assetdiff --git a/agent/backtest/benchmark.py b/agent/backtest/benchmark.pyindex 8658c5d35..c5b2440ba 100644--- a/agent/backtest/benchmark.py+++ b/agent/backtest/benchmark.py@@ -165,6 +165,8 @@ def _infer_market(codes: list[str], source: str) -> str:first = codes[0].upper()+ if first.endswith((".SH", ".SZ", ".BJ")):+ return "a_share"if first.endswith(".US"):return "us_equity"if first.endswith(".HK"):diff --git a/agent/tests/test_benchmark_exchange_suffix_regressions.py b/agent/tests/test_benchmark_exchange_suffix_regressions.pynew file mode 100644index 000000000..8e95927a3--- /dev/null+++ b/agent/tests/test_benchmark_exchange_suffix_regressions.py@@ -0,0 +1,29 @@+import pandas as pd+import pytest+from backtest.benchmark import resolve_benchmark++[email protected]("symbol", ["600000.SH", "000001.SZ", "830799.BJ"])[email protected]("source", ["local", "baostock", "yfinance"])+def test_explicit_ashare_suffix_selects_csi300_benchmark(symbol, source):+ seen = []++ class Loader:+ name = source++ def fetch(self, codes, *args, **kwargs):+ seen.extend(codes)+ return {+ codes[0]: pd.DataFrame(+ {"close": [100.0, 110.0]},+ index=pd.date_range("2025-01-01", periods=2),+ )+ }++ result = resolve_benchmark(+ [symbol], source, "2025-01-01", "2025-01-02", loader=Loader()+ )+ assert seen == ["000300.SH"]+ assert result is not None+ assert result.ticker == "000300.SH"+ assert result.total_ret == pytest.approx(0.1)