The paper venue keeps nothing

The paper engine trades against NautilusTrader’s sandbox venue: live Binance market data, simulated fills, and our own cost and funding models. The sandbox keeps everything in memory. And every push to the platform that passes its checks deploys itself, which, at the time, restarted the engine.

On every start, the sandbox builds a fresh exchange: the starting balance and no positions at all.

What a restart did

After a restart the engine compares its ledger with the venue before it may trade again. For a real exchange that is exactly right: if the exchange says you are flat, you are flat, and the engine adopts the exchange’s view. Adopting flat can never create exposure.

Against the sandbox, the same rule did quiet damage. The venue had forgotten the book, so the engine found it flat and adopted that. The ledger kept the entry fees and dropped the positions, so the costs of every trade were counted and the price moves never were. The commit that fixed it put it plainly: not a neutral reset, but a systematic bias against the strategy.

How we found it

Eduard asked a plain question: does the dashboard’s data reset on every push? Before touching anything, we measured it on the server. In the week measured, the paper engine started 63 times. 5 of those restarts found open legs to adopt, and 103 legs were closed in the ledger with no exit fill. The only stretch with no restart was also the only one in which the account’s value carried across a daily close.

The behaviour was older than that week. Our own specification had once called the mismatch after a restart normal, which was true about safety and false about evidence. It only became visible once the book held positions every day.

Why not the obvious fix

NautilusTrader can persist its state, but only through Redis: a new process running all the time on a small server. And it saves the engine’s cache, not the exchange. The sandbox would still reset its account on start, and we would have had a cache that says “held” over a venue that says “flat”.

The fix: hand the venue its ledger back

Before the comparison, the engine now restores the paper venue from the ledger.

  1. Wait for the account and the instruments They arrive on different clients, at different times.
  2. Restore only a paper venue Decided by the venue's own client, never by a setting a person could get wrong.
  3. Replay every open leg as a fill {instrument}-{strategy} At the ledger's quantity and average price, with no fee.
  4. Move the account's cash By what the ledger has already realised.
  5. Rebuild the venue's positions, and record it VenueRestored
  6. Compare the ledger with the venue, as before Now they agree, so nothing is adopted.

FIG. 1 What the engine does on start, before it compares its ledger with a paper venue.

Source: BillionArch platform code.As of 19 October 2026.

The position id in the third step is the part that is easy to get wrong. The engine’s matching code looks a position up by that id; seed it under any other id and the next fill opens a second position beside the first.

What it still does not do

  • A real exchange still wins. On a live venue, the engine still adopts the exchange’s view; the restore applies to the paper venue only.
  • The damaged week stays damaged. The event log is never edited, so that week is still in it, and the paper run’s clock counts it.
  • A restored leg has no price until its first bar. That briefly halted new entries after each restart, until a later fix.

Later, a deploy also stopped restarting the engine unless engine code had changed. That was for a different reason, a real exchange left unguarded during a restart, and it is not what fixed this.

The tests that hold it

Two tests pin the fix. One checks that a fill after the restore nets into the ledger’s leg rather than opening a second one. The other starts the engine twice and checks that the second start adopts nothing and reports no mismatch.