Skip to content

Paper vs replay reconciliation: the last go-live gate - #4

Merged
devam2001 merged 1 commit into
mainfrom
feature/paper-vs-replay
Oct 10, 2026
Merged

devam2001 merged 1 commit into
mainfrom
feature/paper-vs-replay

Conversation

@devam2001

@devam2001 devam2001 commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Why

The go-live rules say a strategy must paper-trade for 4+ weeks "with results close to a replay of the same weeks", but nothing checked that. This adds the check.

What

  • Replays a paper session's exact period:

    • same strategy, pairs, starting balance and max open trades
    • starts at the candle the session's first decision used
    • tops up candle data first
  • Matches trades: same pair, entries at most 1.5 candles apart.

  • Checks: the session is "close to the replay" only if all four pass.

    Check Target
    Length ≥ 28 days
    Trades in both ≥ 80%
    Realised return gap ≤ 2 percentage points
    Fill cost vs replay ≤ 0.3% per side
  • Explains the gap: splits it into matched-trade execution, paper-only trades and replay-only trades. It also flags what a replay can't reproduce:

    • manual pause, resume and flatten (from the audit trail)
    • drawdown halts
    • strategy code or parameters changed mid-session
    • paper trades newer than the latest closed candle
  • Records what each session ran. New panel sessions write <session>.meta.json with pairs, balance, start and a code fingerprint. config.json's pair list changes monthly; existing sessions already traded 15-, 26- and 25-pair lists. Older sessions and the Docker bot fall back to the bot log and database.

Where

  • ridgeline/reconcile.py: session discovery, matching, checks (no Freqtrade import at module load)
  • panel/replay.py: data top-up, session replay, one-at-a-time background jobs
  • Panel:
    • a Paper vs replay card on the Paper trading tab
    • the Research tab's last gate shows the newest real result per strategy instead of "(manual)"
  • scripts/reconcile.py: CLI for panel sessions (<session-id>) and the Docker bot (--db/--log)
  • Docs: README go-live section, docs/OPERATIONS.md (new "Paper vs replay" section), RESEARCH.md next steps
  • *.reconcile.json added to .gitignore

Testing

  • ruff check . clean; pytest: 63 passed (11 new):
    • matching
    • gap breakdown
    • checks
    • stale data and early-session handling
    • session discovery from meta, log and database
    • left-open backtest trades
    • API validation
    • Research summary
  • Ran a real end-to-end replay (data download + backtest + comparison) on an existing session with a made-up 30-day window.
  • Checked the card and the Research gate in the browser, including the error state and phone width.

The four targets are a first proposal and live in CHECKS in ridgeline/reconcile.py.

Replays the exact period a paper session ran (same strategy, pairs, balance,
max open trades), matches trades by pair and entry time, and checks that paper
results are close to the replay: 28+ days, 80%+ of trades in both, realised
return within 2 points, fills within 0.3% per side. The return gap is split
into matched-trade execution, paper-only and replay-only trades, and anything
the replay can't reproduce (manual pause/resume/flatten, halts, code changed
mid-session) is flagged.

- ridgeline/reconcile.py: session discovery, trade matching, checks
- panel/replay.py: data top-up, session replay, background jobs
- panel: Paper vs replay card; the Research tab's last gate shows real results
- scripts/reconcile.py: CLI for panel sessions and the Docker bot
- panel sessions now record their pairs, balance, start and a code
  fingerprint in <session>.meta.json (config.json's pair list changes monthly)
@devam2001
devam2001 force-pushed the feature/paper-vs-replay branch from 19eaeeb to fcd05b6 Compare October 10, 2026 15:49
@devam2001
devam2001 merged commit e79c277 into main Oct 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant