Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(backtest): charge the 30-year treasury future the treasury fee

Rudy Celekliaf7e2d19ee0d
diff --git a/agent/backtest/engines/china_futures.py b/agent/backtest/engines/china_futures.py
index 9e7c8c2be..63cdd9b80 100644
--- a/agent/backtest/engines/china_futures.py
+++ b/agent/backtest/engines/china_futures.py
@@ -95,6 +95,7 @@ _COMMISSION: dict[str, tuple[str, float]] = {
"IH": ("rate", 0.000023), "IM": ("rate", 0.000023),
# CFFEX bonds
"T": ("fixed", 3.0), "TF": ("fixed", 3.0), "TS": ("fixed", 3.0),
+ "TL": ("fixed", 3.0),
# Metals
"au": ("fixed", 10.0), "ag": ("fixed", 3.0), "cu": ("fixed", 5.0),
"al": ("fixed", 3.0), "zn": ("fixed", 3.0), "ni": ("fixed", 3.0),
diff --git a/agent/tests/test_china_futures_engine.py b/agent/tests/test_china_futures_engine.py
index baf454996..59fa5a529 100644
--- a/agent/tests/test_china_futures_engine.py
+++ b/agent/tests/test_china_futures_engine.py
@@ -207,6 +207,14 @@ class TestCommission:
expected = 2 * 5000 * 300 * 0.000023
assert comm == pytest.approx(expected, rel=0.01)
+ @pytest.mark.parametrize("symbol", ["T2412.CFFEX", "TF2412.CFFEX", "TS2412.CFFEX", "TL2412.CFFEX"])
+ def test_every_treasury_future_pays_the_treasury_fee(self, symbol: str) -> None:
+ """The 30-year TL is charged per lot like T/TF/TS, not the generic default."""
+ engine = _make_engine(codes=[symbol])
+ comm = engine.calc_commission_for_symbol(symbol, 2, 100.0, is_open=True)
+ assert comm == pytest.approx(2 * 3.0)
+ assert "pricing_assumptions" not in engine._engine_diagnostics()
+
def test_commission_override(self) -> None:
engine = _make_engine(commission_override=0.001)
comm = engine.calc_commission(5, 4000.0, 1, is_open=True)