fix: unify backtest execution and add forward validation candidates
Share point-in-time signals and a cash-funded order ledger across backtests and trading. Correct eligibility, missing-price fills, quality factors, regime inputs, warmup windows, and cash-injection accounting. Add reproducible registered-strategy comparisons and paired forward candidates with a 20% resize band. Validation: 125 Python tests, 23 web tests, TypeScript/Vite build, 87 strategy causality checks, and real-data target/order/equity parity for 10 strategies.
This commit is contained in:
@@ -3,6 +3,7 @@ kept to their own columns, shares that drift like separate accounts, and the
|
||||
live trader's session timing."""
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
@@ -82,6 +83,17 @@ class SleevePortfolioTests(unittest.TestCase):
|
||||
got = trader.bar_session_weights(strat, bars, days)
|
||||
pd.testing.assert_frame_equal(got, full)
|
||||
|
||||
def test_trader_truncates_all_bar_fields_before_padding_sleeves(self):
|
||||
bars = _bars()
|
||||
days = bars["close"].index[-4:-2]
|
||||
stocks = [c for c in bars["close"] if c not in ETF_UNIVERSE]
|
||||
member = pd.DataFrame(True, index=bars["close"].index, columns=stocks)
|
||||
expected = us_three_sleeve().generate_signals({f: b.loc[:days[-1]] for f, b in bars.items()}).loc[days]
|
||||
with mock.patch.object(trader, "index_members", lambda m, d: member.reindex(d)):
|
||||
actual = trader.session_signals("us", "us_three_sleeve", list(bars["close"]), days,
|
||||
bars["close"], bars["open"])
|
||||
pd.testing.assert_frame_equal(actual, expected.reindex(columns=actual.columns))
|
||||
|
||||
def test_registered_as_a_us_mixed_strategy(self):
|
||||
self.assertIsInstance(trader.STRATEGY_REGISTRY["us_three_sleeve"](), SleevePortfolioStrategy)
|
||||
self.assertEqual(set(trader.strategy_extra_tickers("us_three_sleeve")), set(ETF_UNIVERSE))
|
||||
|
||||
Reference in New Issue
Block a user