Reference / Trade execution

The kept book

The kept book is Praxis's own copy of the latest order book for a trading pair, held in memory with the time it arrived, so a check can read a price without waiting on the venue.

Contents

One background task is meant to run for each trading pair the paper accounts name, fetching five levels every couple of seconds and overwriting that symbol's copy. None of them starts unless a venue was handed to the host, which the ordinary start does not do.

What reads it

Two readers use the copy, and neither talks to the venue.

One serves the checks a request passes before it is accepted. It always builds the gap between the best buy and sell prices, and hands back both moments — its own and the copy's — which the decision side subtracts. It builds a third figure — how far the middle of that gap sits from the price the request expected — only when a strategy price came with the request and is above zero.

The other reads the middle of the gap alone, to turn an amount of money into an amount of coin.

Both return nothing in the same four cases: no copy has arrived, one side is empty, the best buy price is at or below zero, or the best buy price stands above the best sell price.

When polling fails

The store begins empty, and only a successful poll puts anything in it.

So where that background task fails to start, neither check can answer for that pair for as long as the host runs. A poll that fails after earlier ones succeeded is different: it is logged, the loop carries on, and both checks go on answering from a copy that is growing older.

Source evidence
---
row: P2-26
baseline: 49aa659
created: 2026-09-25 19:08 UTC
modified: 2026-11-09 10:25 UTC
evidence:
  - claim: "A copy of the latest book per symbol, held in memory with its arrival time"
    source: "`book_cache.py` 38 for the store, 44-45 for the write, 29-31 for what a copy holds"
  - claim: "One poller per symbol among the paper accounts, where a venue was handed in, which the ordinary start does not do"
    source: "`launcher.py` 3819-3831, the asking bound at 628-641 into 641, reached only past 3799-3800, the ordinary start handing none in at 4984-4991"
  - claim: "Each poll overwrites the copy for that symbol"
    source: "`book_poller.py` 76-77 into `book_cache.py` 44-45"
  - claim: "One reader builds the gap and hands back the two moments an age is taken from"
    source: "`book_cache.py` 124-125 and 134-139, subtracted by Nexus `price_stage.py` 281"
  - claim: "It builds the drift only when a strategy price was supplied and is above zero"
    source: "`book_cache.py` 130-132"
  - claim: "The other reads the middle of the gap alone"
    source: "`book_cache.py` 82"
  - claim: "Either returns nothing with no copy, an empty side, a best buy price at or below zero, or a crossed book"
    source: "`book_cache.py` 110-122, matching 66-80"
  - claim: "A poller that will not start is logged and the host trades on"
    source: "`launcher.py` 3805-3810"
  - claim: "The store begins empty"
    source: "`book_cache.py` 38"
  - claim: "A failed poll leaves the copy as it was"
    source: "`book_poller.py` 85-88"
---

Edit this sourceCheckout revision · 7381aa49
Reference / keep your place
Find a passage