Skip to content

Commit b171487

Browse files
committed
Tests: full-surface equivalence and completeness suites for the DecomposedStrategy migration
Two complementary suites pin the migration from the monolith Strategy to DecomposedStrategy with no relaxations and no vacuous green. StrategyReferenceSurfaceTests - the SAME completeness checks applied to both implementations over the same combined deterministic backtest scenario (SMA trading, 0.2% stop protection, raw tick/level1/depth subscriptions, a forced off-step register fail with connector CheckSteps, a scripted resting order that is edited, re-registered, canceled and canceled again, cancel-on-stop, final Reset). Shared crossover decision and shared order-maintenance script guarantee identical inputs. For each side: every drivable event must fire at least once, structurally undrivable events must stay silent (each with the reason documented), aggregate properties must carry real data (position moved, PnL/commission/slippage accumulated, collections and statistics non-empty), and every order/trade must be fully stamped (ids, times, final states, ownership marks, per-trade commission). The monolith passes except for genuine reference data gaps it reproduces (the CheckSteps-rejected order keeps TransactionId=0 and default Time; a registered order keeps default Time); the decomposed side is red across the board: 35 events never fire, properties stay zero/null, no entities are produced. StrategyDecomposedFullEquivalenceTests - strict 1:1 stream equivalence: both implementations run the same shared SMA-crossover logic in real deterministic HistoryEmulationConnector backtests (seed 42, fixed ids, PassThroughMessageChannel, MatchOnTouch, deterministic commission and slippage), every externally observable event is recorded into normalized ordered streams (64 families: subscriptions with criteria and lifecycle at connector and strategy level, states, candles, signals, market-data relays, connector-boundary order/trade/fail/position/portfolio traffic, new/registering/registered/changed/canceling/re-registering/edited orders and all fail relays, mass-cancel and lookup-result relays, trades, all position surfaces, PnL with realized/unrealized split plus PnLReceived/PnLReceived2, commission, slippage, latency, errors, infra notifications including PropertyChanged and CurrentTimeChanged, drawing surface) and compared 1:1 - per family, then as one interleaved master stream. The compared window is configure..Reset, and a synthetic "Final" record compares the end-of-run property state of both sides. Eleven scenarios: storage candles, candles from ticks, candles from level1, protection on candles and tick-built candles, forced register-fail, mid-run stop with resting orders, foreign connector-level order, scripted edit/re-register/cancel flow, LongOnly trading mode with comment stamping, and raw market-data relays - each with data-substance guards so empty-vs-empty can never pass, with per-family count diagnostics on guard failures. All tests are deterministic across reruns. The intentionally red tests reproduce genuine product divergences, primarily: DecomposedStrategy.RegisterOrder/ReRegisterOrder pre-assign Order.TransactionId, which Connector.CheckOnNew rejects, so on a real connector the decomposed side registers zero orders (mock-based tests never exercised this path); DecomposedStrategy attaches a foreign order while it has no own transactions; no Stopping->Stopped transition in StrategyEngine; register-fail relays never reach the strategy due to the subscription CanProcess gate; no order stamping, no IsOnline tracking, no strategy-position or subscription-scoped events, no edit/cancel-fail/relay surfaces, dead TradingMode/CommentMode properties, silent Reset and PnL notification gating differences.
1 parent d36df90 commit b171487

2 files changed

Lines changed: 2025 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)