Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(backtest): apply the equity-index price limit to MYM and M2K

Rudy Celeklia98b8dc423a0
diff --git a/agent/backtest/engines/global_futures.py b/agent/backtest/engines/global_futures.py
index 29aec77cf..d0e4590b5 100644
--- a/agent/backtest/engines/global_futures.py
+++ b/agent/backtest/engines/global_futures.py
@@ -84,7 +84,7 @@ _MARGIN_PER_CONTRACT: dict[str, float] = {
_PRICE_LIMIT: dict[str, float] = {
# Equity index: 7% (Level 1), simplified to single level
"ES": 0.07, "NQ": 0.07, "YM": 0.07, "RTY": 0.07,
- "MES": 0.07, "MNQ": 0.07,
+ "MES": 0.07, "MNQ": 0.07, "MYM": 0.07, "M2K": 0.07,
# Energy: varies, typically ~$10-15 for CL
# Not easily expressed as %, skip for most commodities
}
diff --git a/agent/tests/test_global_futures_engine.py b/agent/tests/test_global_futures_engine.py
index 6b32218c6..b42967f9e 100644
--- a/agent/tests/test_global_futures_engine.py
+++ b/agent/tests/test_global_futures_engine.py
@@ -138,6 +138,15 @@ class TestPriceLimits:
bar = _make_bar(close=5200.0, pre_close=5000.0) # +4%
assert engine.can_execute("ESZ4", 1, bar) is True
+ @pytest.mark.parametrize("symbol", ["MYMZ4", "M2KZ4"])
+ def test_every_micro_equity_index_carries_the_limit(self, symbol: str) -> None:
+ """Micro Dow and micro Russell share the E-mini price limit, as MES/MNQ do."""
+ engine = _make_engine(codes=[symbol])
+ up = _make_bar(close=5400.0, pre_close=5000.0) # +8% > 7%
+ down = _make_bar(close=4600.0, pre_close=5000.0) # -8% > 7%
+ assert engine.can_execute(symbol, 1, up) is False
+ assert engine.can_execute(symbol, -1, down) is False
+
def test_commodity_no_limit(self) -> None:
"""CL has no configured price limit; always allowed."""
engine = _make_engine(codes=["CLF25"])