Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(strategy-discovery): a row may not claim evidence it cannot point at

Haozhe Wue90e82a2dc2f
diff --git a/README_es.md b/README_es.md
index 8bbb3534c..032a2ad43 100644
--- a/README_es.md
+++ b/README_es.md
@@ -427,9 +427,9 @@ Más allá del OHLCV, **22 herramientas de datos de solo lectura** alcanzan fund
Los inventarios detallados se pliegan a continuación para mantener el README principal fácil de escanear. Ábrelos cuando quieras inspeccionar los bloques de construcción disponibles.
<details>
-<summary><b>Biblioteca de Skills Financieras</b> <sub>89 skills en 9 categorías</sub></summary>
+<summary><b>Biblioteca de Skills Financieras</b> <sub>90 skills en 9 categorías</sub></summary>
-- 📊 89 skills financieras especializadas organizadas en 9 categorías
+- 📊 90 skills financieras especializadas organizadas en 9 categorías
- 🌐 Cobertura completa desde mercados tradicionales hasta cripto y DeFi
- 🔬 Capacidades integrales que abarcan desde el sourcing de datos hasta la investigación cuantitativa
@@ -567,7 +567,7 @@ Ejecuta `vibe-trading alpha list` para explorar, `vibe-trading alpha show <id>`
</details>
<details>
-<summary><b>Motores de Backtest</b> <sub>9 motores + cartera de opciones, composite cross-market</sub></summary>
+<summary><b>Motores de Backtest</b> <sub>10 motores + cartera de opciones, composite cross-market</sub></summary>
| Motor | Mercado | Notas |
|--------|--------|-------|
@@ -1205,7 +1205,7 @@ Enviar `{}` programa una plantilla con su propia cadencia sugerida y sus valores
## 🔌 MCP Plugin
-Vibe-Trading expone 70 MCP tools para cualquier cliente compatible con MCP. Se ejecuta como un subproceso stdio — no requiere configuración de servidor. Las herramientas de investigación principales funcionan sin ninguna API key para HK/US/crypto; las herramientas del conector de trading usan el perfil de conector seleccionado, y `run_swarm` necesita una LLM key.
+Vibe-Trading expone 73 MCP tools para cualquier cliente compatible con MCP. Se ejecuta como un subproceso stdio — no requiere configuración de servidor. Las herramientas de investigación principales funcionan sin ninguna API key para HK/US/crypto; las herramientas del conector de trading usan el perfil de conector seleccionado, y `run_swarm` necesita una LLM key.
**Variables de entorno:** el cliente lanza el servidor él mismo, así que un `export` de shell nunca le llega — configúralas en el bloque `env` del cliente. El código de backtest generado está confinado a los run roots permitidos, así que para escribir resultados en un workspace propio necesitas `VIBE_TRADING_ALLOWED_RUN_ROOTS`:
@@ -1276,7 +1276,7 @@ dirección de bind con `--host` / `--port`.
</details>
-**MCP tools expuestas (70):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
+**MCP tools expuestas (73):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `alpha_zoo`, `alpha_bench`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_strategies`, `query_strategies`, `get_strategy_evidence`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `qveris_search`, `qveris_inspect`, `qveris_execute`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `quantlib_call`, `cashflow_performance`, `orderbook_depth`, `sentiment`, `technical_indicators`, `get_fundamentals`.
### SWARM external MCP tools
@@ -1300,7 +1300,7 @@ Explora en ClawHub: [clawhub.ai/skills/vibe-trading](https://clawhub.ai/skills/v
<details>
<summary><b>OpenSpace — self-evolving skills</b></summary>
-Los 89 skills de finanzas están publicados en [open-space.cloud](https://open-space.cloud) y evolucionan de forma autónoma mediante el motor de auto-evolución de OpenSpace.
+Los 90 skills de finanzas están publicados en [open-space.cloud](https://open-space.cloud) y evolucionan de forma autónoma mediante el motor de auto-evolución de OpenSpace.
Para usarlo con OpenSpace, añade ambos servidores MCP a la configuración de tu agente:
@@ -1322,7 +1322,7 @@ Para usarlo con OpenSpace, añade ambos servidores MCP a la configuración de tu
}
```
-OpenSpace descubrirá automáticamente los 89 skills, habilitando auto-fix, auto-improve y compartición comunitaria. Busca skills de Vibe-Trading mediante `search_skills("finance backtest")` en cualquier agente conectado a OpenSpace.
+OpenSpace descubrirá automáticamente los 90 skills, habilitando auto-fix, auto-improve y compartición comunitaria. Busca skills de Vibe-Trading mediante `search_skills("finance backtest")` en cualquier agente conectado a OpenSpace.
</details>
@@ -1649,13 +1649,13 @@ Vibe-Trading/
├── agent/ # Backend (Python)
│ ├── cli/ # Paquete CLI — TUI interactiva + subcomandos
│ ├── api_server.py # Servidor FastAPI — runs, sesiones, carga, swarm, SSE
-│ ├── mcp_server.py # Servidor MCP — 70 herramientas para OpenClaw / Claude Desktop
+│ ├── mcp_server.py # Servidor MCP — 73 herramientas para OpenClaw / Claude Desktop
│ │
│ ├── src/
│ │ ├── agent/ # Núcleo del agente ReAct
│ │ │ ├── loop.py # compresión de 5 capas + agrupación de herramientas de lectura/escritura
│ │ │ ├── context.py # system prompt + auto-recuperación desde memoria persistente
-│ │ │ ├── skills.py # cargador de skills (89 incluidas + creadas por el usuario vía CRUD)
+│ │ │ ├── skills.py # cargador de skills (90 incluidas + creadas por el usuario vía CRUD)
│ │ │ ├── tools.py # clase base de herramientas + registro
│ │ │ ├── memory.py # estado ligero del workspace por ejecución
│ │ │ ├── frontmatter.py # parser de frontmatter YAML compartido
@@ -1664,7 +1664,7 @@ Vibe-Trading/
│ │ ├── memory/ # Memoria persistente entre sesiones
│ │ │ └── persistent.py # memoria basada en archivos (~/.vibe-trading/memory/)
│ │ │
-│ │ ├── tools/ # 94 herramientas de agente autodescubiertas
+│ │ ├── tools/ # 97 herramientas de agente autodescubiertas
│ │ │ ├── backtest_tool.py # ejecuta backtests
│ │ │ ├── remember_tool.py # memoria entre sesiones (save/recall/forget)
│ │ │ ├── skill_writer_tool.py # CRUD de skills (save/patch/delete/file)
@@ -1682,7 +1682,7 @@ Vibe-Trading/
│ │ ├── api/ # Módulos de rutas FastAPI
│ │ │ └── alpha_routes.py # /alpha/list, /alpha/{id}, /alpha/bench, flujo SSE
│ │ │
-│ │ ├── skills/ # 89 skills financieras en 9 categorías (un SKILL.md cada una)
+│ │ ├── skills/ # 90 skills financieras en 9 categorías (un SKILL.md cada una)
│ │ ├── swarm/ # Motor de ejecución de DAG swarm
│ │ │ └── presets/ # 30 definiciones YAML de presets swarm
│ │ ├── session/ # Chat multi-turno + búsqueda de sesiones FTS5
diff --git a/agent/src/strategy_discovery/models.py b/agent/src/strategy_discovery/models.py
index e2322a8aa..db44f6d61 100644
--- a/agent/src/strategy_discovery/models.py
+++ b/agent/src/strategy_discovery/models.py
@@ -42,6 +42,15 @@ EVIDENCE_STAGES = (
"retired",
)
+#: Stages that assert a computed result. A row at one of these stages claims
+#: evidence that something reproduced it, so it must name that something:
+#: ``__post_init__`` refuses to build one with an empty ``provenance``.
+#: ``hypothesis`` (nothing computed yet) and ``retired`` (withdrawn) are
+#: exempt — neither claims a current result.
+STAGES_REQUIRING_PROVENANCE = frozenset(
+ {"backtest", "holdout", "shadow", "live_canary"}
+)
+
# ---------------------------------------------------------------------------
# Evidence-quality ladder
# ---------------------------------------------------------------------------
@@ -114,7 +123,9 @@ class EvidenceRow:
#: ISO date string ("YYYY-MM-DD") of the last harness verification.
last_verified: str = ""
#: Pipeline stage that produced this row; one of ``EVIDENCE_STAGES``.
- evidence_stage: str = "backtest"
+ #: Defaults to the weakest claim: a row that says nothing about how it was
+ #: produced must not read as though a backtest stood behind it.
+ evidence_stage: str = "hypothesis"
#: Reproducible artifact reference: the backtest run directory whose
#: ``artifacts/`` this row was computed from.
provenance: str = ""
@@ -132,6 +143,13 @@ class EvidenceRow:
f"invalid evidence_stage {self.evidence_stage!r}; "
f"expected one of {EVIDENCE_STAGES}"
)
+ if self.evidence_stage in STAGES_REQUIRING_PROVENANCE and not self.provenance:
+ raise ValueError(
+ f"evidence_stage {self.evidence_stage!r} claims a computed "
+ f"result, so provenance must name the run it was computed "
+ f"from; got an empty provenance for strategy "
+ f"{self.strategy_id!r} / regime {self.regime!r}"
+ )
@dataclass(frozen=True)
diff --git a/agent/tests/test_readme_counts.py b/agent/tests/test_readme_counts.py
index a4118fe44..579d2514a 100644
--- a/agent/tests/test_readme_counts.py
+++ b/agent/tests/test_readme_counts.py
@@ -48,6 +48,7 @@ READMES = (
"README_ja.md",
"README_ko.md",
"README_ar.md",
+ "README_es.md",
)
# Feature badges in the order they appear in every README. Each entry is the
@@ -439,7 +440,7 @@ def test_the_skill_category_table_matches_the_frontmatter() -> None:
assert sum(int(n) for _, n in rows) == _bundled_skill_count()
-def test_all_five_readmes_agree_with_each_other() -> None:
+def test_all_readmes_agree_with_each_other() -> None:
"""No locale may drift from the others, whatever the code count is."""
per_file = {name: [_numbers(b) for b in _badges(_read(name))] for name in READMES}
counts = _counts()
diff --git a/agent/tests/test_strategy_discovery_models.py b/agent/tests/test_strategy_discovery_models.py
index 144cae885..d0d1e625e 100644
--- a/agent/tests/test_strategy_discovery_models.py
+++ b/agent/tests/test_strategy_discovery_models.py
@@ -82,7 +82,7 @@ class TestEvidenceRow:
assert row.evidence_quality == "insufficient"
assert row.warnings == ()
assert row.last_verified == ""
- assert row.evidence_stage == "backtest"
+ assert row.evidence_stage == "hypothesis"
assert row.provenance == ""
assert row.regime_definition == ""
with pytest.raises(dataclasses.FrozenInstanceError):
@@ -110,9 +110,38 @@ class TestEvidenceRow:
regime="bear_market",
trades_in_regime=12,
evidence_stage=stage,
+ # A computed stage must name what computed it; supplying it for
+ # every stage keeps this test about the vocabulary alone.
+ provenance="/runs/run-1",
)
assert row.evidence_stage == stage
+ def test_a_computed_stage_cannot_be_claimed_without_provenance(self) -> None:
+ """A row may not assert a result it cannot point at.
+
+ ``evidence_stage`` names what produced the row, so a stage that claims a
+ computed result has to name the run. Without this the cheapest possible
+ row — three positional fields — used to assert backtest-grade evidence
+ with nothing behind it.
+ """
+ for stage in sorted(sd_models.STAGES_REQUIRING_PROVENANCE):
+ with pytest.raises(ValueError, match="provenance"):
+ sd_models.EvidenceRow(
+ strategy_id="s",
+ regime="bear_market",
+ trades_in_regime=12,
+ evidence_stage=stage,
+ )
+
+ def test_stages_that_claim_nothing_need_no_provenance(self) -> None:
+ """``hypothesis`` and ``retired`` assert no current result."""
+ for stage in set(sd_models.EVIDENCE_STAGES) - sd_models.STAGES_REQUIRING_PROVENANCE:
+ row = sd_models.EvidenceRow(
+ strategy_id="s", regime="bear_market", trades_in_regime=12,
+ evidence_stage=stage,
+ )
+ assert row.provenance == ""
+
def test_full_construction_roundtrip(self) -> None:
row = sd_models.EvidenceRow(
strategy_id="sdm:abc",