Runtime Parity
runtime-parity compares live/runtime entry records with a deterministic
backtest replay over the same recent window.
Use it after promoting backtest results into runtime config or after changing strategy runtime behavior. It answers a narrow question:
Did the shared runtime and the backtest replay produce comparable entry orders for the selected strategies and symbols?
Run It
npx @tradejs/cli runtime-parity --user root --connector bybit --days 3
Useful variants:
npx @tradejs/cli runtime-parity --user root --connector bybit --days 3 --details
npx @tradejs/cli runtime-parity --user root --connector bybit --strategy TrendLine --tickers BTC,ETH
npx @tradejs/cli runtime-parity --user root --connector bybit --startTime 1714000000000 --endTime 1714260000000
npx @tradejs/cli runtime-parity --user root --connector bybit --days 3 --notify
What It Replays
The command builds replay targets from:
- saved runtime trade records
- runtime signal/evaluation universe
- explicit
--tickers - latest strategy results when available
For each target it resolves the effective runtime config:
- user strategy config from Redis
- per-symbol
resultspatch when available - replay runtime fields such as
ENV
By default the replay runs with ENV=BACKTEST, so it checks core/runtime
execution parity without calling live AI/ML gates.
Use --runtimeGates only when you intentionally want parity replay to execute
configured runtime gates. This may call external AI providers and ML inference.
Matching Rules
Runtime and backtest entries are matched by:
- strategy
- symbol
- direction
- timestamp within the configured tolerance
The default timestamp tolerance is one 15m bar. Change it with:
npx @tradejs/cli runtime-parity --toleranceBars 2
Entry price is reported as drift for diagnostics, but it is not the primary match key.
Output
The console and Telegram report include:
- replay window, connector, replay env, runtime-gates status, tolerance
- target counts, compared targets, replay errors, and target sources
- runtime entries, deduped runtime entries, duplicate entries, backtest entries
- matched, runtime-only, and backtest-only counts
- average/max entry price delta and timestamp drift for matched entries
- per-strategy target and entry breakdown
- backtest-only classifications when runtime signals/evaluations explain why an entry did not become a runtime trade
- warnings when AI/ML gates are configured but
--runtimeGatesis not enabled
When --notify is used, the same summary is sent to Telegram through the
current user's saved Telegram settings.
Interpreting Results
matched should be close to runtime entries when the replay window has enough
market data and the runtime config matches what was live.
runtimeOnly means a runtime trade record exists but the deterministic replay
did not produce a comparable entry.
backtestOnly means replay produced an entry that was not found in runtime
trade records. The report classifies these when possible:
gated_out— runtime signal/evaluation existed but AI/ML or policy blocked the tradeorder_failed— runtime tried but order placement failedcore_skipped— runtime evaluated but core skippednot_evaluated— no comparable runtime evaluation was foundtrue_mismatch— no known runtime-side explanation was found
If a strategy has runtime=0 and backtest=0, the selected targets produced no
comparable entries in that window. It does not mean AI/ML would approve a live
trade every day.
Flags
--userselects the Redis user config and runtime journal.--connectorselects the connector provider/name for replay.--dayssets a recent replay window.--startTimeand--endTimeset an explicit replay window.--strategylimits replay to one strategy.--tickersreplays comma-separated symbols for all configured strategies.--cacheOnlyskips market history refresh before replay.--toleranceBarschanges timestamp matching tolerance.--runtimeGatesenables configured runtime AI/ML gates during replay.--detailsprints unmatched entry details to stdout.--notifysends the parity summary to Telegram.