Reference / Trade execution

Cancelling a trade

The route a cancellation takes from the moment a caller asks for it to the moment that caller is told what happened. Each step hands off to the article that owns it: this page owns the order they happen in and nothing else.

Contents

Starts from a caller asking Praxis to stop a request it has already submitted.

Ends with the request reported cancelled, reported expired, or — on several of the forks below — with no report reaching the caller.

Before anything is queued

  1. The host refuses outright while it is shutting down, before it has been started, and while the named account is not ready — so the route below begins only on a running account — What the host refuses first.

  2. The asking is then checked: an unknown account or request, one belonging to another account, an account whose start failed, and a worker that has exited are each refused here — Cancellation.

  3. A request already finished is answered as doing nothing, before it is queued at all — Cancellation.

  4. Anything still live joins the priority line.

  5. The account's worker takes the venue's own news first, then that line, and only then its ordinary queue — The priority line.

One arm of three, never two

  1. A request that finished while it waited is answered as doing nothing — Cancellation.

  2. Arm one — work being fed out. A run or a ladder the account is working is wound up, and nothing below applies to it — Where an abandonment lands. Winding up cancels its children and waits for them rather than answering at once — Work already under way.

  3. Arm two — no order was ever sent. The request is marked, and the mark is read when its turn to start comes: it is then dropped unsent and reported cancelled with nothing filled — Cancellation. A ladder marked before its first rung is the case whose report will not build, and the caller hears a rejection only after the next start — Cancellation, What startup does with orphaned work. A run or a ladder found past its deadline is reported expired instead — Deadlines. An account poisoned meanwhile refuses the marked work outright when its turn comes, so the mark is not always what answers it — When an account is reconciling or poisoned.

  4. Arm three — an order is resting. The venue is asked to cancel it — What a venue must be able to do. That call is one the adapter will send again, so a failure it counts as temporary is retried before anything here sees it — When Praxis retries a venue call.

What that one call comes back as

  1. The venue cancels it, or has no such order. Both count as confirmed, and a cancellation is written down — Cancellation, What a refusal says.

  2. The venue refuses it. The order's record is left untouched and the reason carries the failure — Cancellation. The request is still reported cancelled, with the order still resting there — Cancellation.

  3. The reply cannot be read. A missing id, or a status the adapter has no name for, leaves this route before anything is written — A reply that cannot be read. The worker logs it and no report is built — Cancellation.

What the caller is told

  1. On the results that stay on the route, whatever had already been counted as filled is reported with the cancellation, and no fresh count is fetched — Cancellation, The figures an outcome carries.

  2. A request whose trade cannot be named is logged and left without a report, past the venue call and past any write it made — Cancellation.

  3. A report the figures will not let build leaves the caller empty-handed too — The figures an outcome carries.

  4. Otherwise the report is handed over, and handing it over can fail in its own right — How an outcome crosses back, How an outcome is delivered.

Where this route is not taken

  • A host stopping sends its own abandonment for every command in flight, which joins the same line and takes the same three arms from step 6 on. What it skips is the caller-facing refusals of step 1 — Where an abandonment lands, What becomes of work still open.
  • An order found past its deadline is cancelled by a route that settles its report first — The expiry cancel.
  • A price change cancels the resting order as one step of replacing it — How a price change is carried out.
  • A lost protection does not cancel the request: where the account's policy is to flatten and halt it attempts a closing order instead, and the other policy leaves the position standing — When protection is lost.

Created 2026-10-14 14:00 UTC · Last modified 2026-10-23 07:08 UTC

Source evidence
---
row: S-01
baseline: 49aa659
created: 2026-10-14 14:00 UTC
modified: 2026-10-23 07:08 UTC
evidence:
  - claim: "The host's own refusals run before the manager is reached at all"
    source: "`trading.py` 1904-1907 before 1908, handed on at `trading_inbound.py` 248 into `execution_manager.py` 2996"
  - claim: "A request already ended is answered before anything is queued"
    source: "`execution_manager.py` 3014-3025 before 3027"
  - claim: "The worker takes the venue's news, then the priority line, then its ordinary queue"
    source: "`execution_manager.py` 3907, 3910 and 3984"
  - claim: "A command already ended is guarded out before the arms are reached"
    source: "`execution_manager.py` 8482-8487"
  - claim: "Past that guard a cancellation takes one of three arms and returns from each, so none follows another"
    source: "`execution_manager.py` 8489-8491, 8493-8512 and 8568-8576"
  - claim: "The answers to the venue call are arms of one attempt, not stages"
    source: "`execution_manager.py` 8519-8531, 8532-8533 and 8534-8536"
  - claim: "A status the adapter has no name for raises past both its handlers"
    source: "`binance_adapter.py` 896-897, read at 1691"
  - claim: "A confirmed cancellation is written down before the report is built, and a refused one reaches the report with no such write"
    source: "`execution_manager.py` 8538-8547 before 8568"
  - claim: "A request whose trade cannot be named is left without a report, past both"
    source: "`execution_manager.py` 8558-8566"
---

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