Skip to content

Resume paper sessions after a restart; flag bot downtime - #8

Open
devam2001 wants to merge 1 commit into
mainfrom
feature/resume-session
Open

devam2001 wants to merge 1 commit into
mainfrom
feature/resume-session

Conversation

@devam2001

Copy link
Copy Markdown
Owner

Why

The last go-live gate needs 4+ weeks of continuous paper trading. Until now, a reboot, crash or sleep ended the test: the panel could only start a new session, and the paper-vs-replay check couldn't see that the bot had been offline.

What

  • Resume (panel button, POST /api/paper/resume):
    • Restarts the last session's bot on the same database, so the wallet, open trades and history carry on.
    • Uses the same dry-run guard as Start.
    • Is enabled only when a stopped session exists.
  • Pinned pair lists:
    • New sessions save their pair list in their own config, so the monthly config.json update can't change a running test.
    • Older sessions get their list back from the bot log when resumed.
  • Downtime detection: the paper-vs-replay check reports any stretch of 10+ minutes without log output (the bot logs a heartbeat every minute). The replay trades straight through those gaps.
  • Docs: README panel section and the runbook's paper-vs-replay notes.

Testing

  • ruff check . clean; pytest 73 passed. New tests cover:
    • resume, including that pairs are pinned to the session's own list
    • the dry-run guard on resume
    • that the risk-control resume (/api/bot/resume) stays separate from session resume
    • gap detection
  • Checked live in the panel:
    • Resumed a real October 11 session. It came back as the same session, in dry-run mode, with its 100 USDT wallet and its 25 original pairs recovered from the log. Then stopped it.
    • Downtime detection on that session found the one 10-day offline period.

A 4-week paper test was lost to any reboot, crash or sleep: the panel could
only start a new session.

- Resume restarts the last session's bot on the same database, so the wallet,
  open trades and history carry on. Sessions pin their pair list in their own
  config, so the monthly config.json update can't change a running test;
  older sessions get theirs back from the bot log.
- The paper-vs-replay check finds periods with no log output for 10+ minutes
  and reports the downtime, since the replay trades straight through them.
- Tests: resume, pinned pairs, the dry-run guard on resume, the risk-control
  resume staying separate, and gap detection.
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