Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(alpha): stop filling missing prices

xkam7ar22867b01d96b
diff --git a/agent/src/tools/alpha_bench_tool.py b/agent/src/tools/alpha_bench_tool.py
index 861fd87db..1e7b475a1 100644
--- a/agent/src/tools/alpha_bench_tool.py
+++ b/agent/src/tools/alpha_bench_tool.py
@@ -529,7 +529,7 @@ def _compute_forward_returns(panel: dict[str, pd.DataFrame]) -> pd.DataFrame:
if close is None:
raise ValueError("panel missing 'close' — cannot derive forward returns")
# Next-period return aligned to current row (use t+1 close, shift back).
- fwd = close.pct_change().shift(-1)
+ fwd = close.pct_change(fill_method=None).shift(-1)
return fwd
diff --git a/agent/tests/test_alpha_bench_forward_returns.py b/agent/tests/test_alpha_bench_forward_returns.py
new file mode 100644
index 000000000..66b2085cc
--- /dev/null
+++ b/agent/tests/test_alpha_bench_forward_returns.py
@@ -0,0 +1,18 @@
+"""Regression tests for alpha-bench forward-return missing-data handling."""
+
+from __future__ import annotations
+
+import pandas as pd
+
+from src.tools.alpha_bench_tool import _compute_forward_returns
+
+
+def test_forward_returns_preserve_missing_close_boundaries() -> None:
+ close = pd.DataFrame(
+ {"AAA": [100.0, None, 121.0]},
+ index=pd.date_range("2026-01-01", periods=3, freq="D"),
+ )
+
+ forward = _compute_forward_returns({"close": close})
+
+ assert forward["AAA"].isna().all()