Errors and exit codes¶
Exit codes, reject reasons, kill reasons and venue error actions. Log messages with causes and fixes: Troubleshooting.
Exit codes¶
Each program defines its own exit codes. 1 from fastmm-live means the process crashed.
fastmm-live¶
"Orders cancelled" is the REST cancel-all at shutdown. cancel_all FAILED turns any code into 5 (reading the last lines).
| Code | Meaning | Orders cancelled | Restart without a human |
|---|---|---|---|
| 0 | stopped by --duration, SIGINT, SIGTERM or fastmm-ctl stop with cancel_all ok; also after a kill with on_kill = "stay"; --help, --version, --list-strategies |
yes | yes |
| 2 | bad command line; an unset ${VAR} in [venues.*] |
nothing started | no: fix the invocation |
| 3 | the configuration, strategy or a parameter does not load; a session with keys has no [risk] position or loss limit (allow_unlimited); a [storage] backend is unknown or cannot open; a venue refuses an account setting, such as Bybit linear in hedge mode |
nothing started | no: fix the config or the account |
| 4 | a venue's reference data failed to load, or --gateway could not attach |
nothing started | retry once; a repeat means the venue or the network |
| 5 | cancel_all FAILED; the journal cannot be opened or written; an order-event ring overflowed; the gateway closed the attachment; the engine thread stalled past [engine] stall_ms; an uncaught error |
not certain | no: check the venue for open orders first |
| 6 | the engine tripped the kill switch with on_kill = "exit" and cancel_all ok; or, at start, a latched max_loss trip in [engine] kill_file, or no kill file while the store's newest session ended on one |
yes; at start nothing started | no: find the kill reason in the log; a latched trip needs --clear-kill |
| 7 | a Python strategy's slow tier failed, cancel_all ok; returned by python -m fastmm run and fastmm.run_live only |
yes | no: fix the slow method |
| 8 | another process holds [engine] instance_lock, or --takeover failed: the holder refused, did not answer, or kept the lock past handoff_timeout_ms |
nothing started | no: another session trades this engine (hand over) |
| 9 | the carried-over state is gone or wrong: [engine] epoch_file is missing while the store holds sessions, or the newest session booked executions twice |
nothing started | no: a start refuses the state it carries over |
The systemd unit does not restart after 5, 6, 7 or 9 (Deploy). What a restart carries over: Run in production.
fastmm-gateway uses codes 0, 2, 3, 4, 5 and 6 with the same meanings. Code 3 also covers an invalid [gateway] limit; 6 is a latched [gateway] max_loss trip at start.
The other programs¶
| Code | fastmm-backtest |
fastmm-replay |
fastmm-sim-exchange |
fastmm-sim-itch |
fastmm-top |
|---|---|---|---|---|---|
| 0 | ran | matched, or no --verify |
stopped | stopped | quit, or --once printed a frame |
| 1 | — | verification mismatch | — | — | — |
| 2 | bad command line | bad command line | bad command line | bad command line | bad command line |
| 3 | bad config, strategy or parameter | unreadable config or journal, unknown strategy | bad config | bad config, CPU pinning, or the summary file | --once with no status file, or one from another build |
| 4 | the market data cannot be read | — | cannot listen on a port | cannot open a socket | — |
| 5 | the run failed | — | — | — | — |
| Code | fastmm-data |
fastmm-pnl |
fastmm-ctl |
|---|---|---|---|
| 1 | — | — | the session answered error |
| 2 | bad command line | bad command line, or the store cannot be opened | bad command line |
| 3 | bad config | recover found no session |
no session answered |
| 4 | the market data cannot be read | — | — |
| 5 | the output cannot be written | — | — |
Reject reasons¶
RejectReason (include/fastmm/core/enums.hpp): the order was not sent, or the venue refused it, and nothing else changed. The strategy reads it in the Result of ctx.send. fastmm-top and the shutdown summary count rejects per reason.
Pre-trade checks (engine)¶
Checked in the order listed, not numeric order; the first failure decides. A limit of 0 or omitted turns its check off (Risk model). These orders never reach the venue.
| # | Name | Setting | Clears when |
|---|---|---|---|
| 1 | KillSwitch |
— | fastmm-ctl unkill or SIGHUP (with on_kill = "stay"), or a restart |
| 2 | VenueKilled |
— | as KillSwitch |
| 3 | InstrumentDisabled |
[[instruments]] enabled |
the config changes, or the venue re-enables the symbol |
| 4 | InvalidTick |
tick |
the strategy rounds prices with inst.round_price |
| 5 | InvalidLot |
lot, min_qty, max_qty |
the strategy rounds quantities with inst.round_qty |
| 6 | BelowMinNotional |
min_notional |
the order is larger |
| 7 | StaleMarketData |
[risk] stale_md_ms |
the book updates; age is on the engine clock from when it applied the update |
| 20 | FeedLag |
[risk] max_feed_lag_ms |
100 ms pass with no venue message lagging past the limit; IOC, FOK, market and position-reducing orders pass (feed-lag gate) |
| 8 | PriceCollar |
[risk] price_collar_bps, or the venue's own price band (Binance PERCENT_PRICE, USDⓈ-M -4131, OKX 51006) |
the mid moves to the price, or the price moves to the mid |
| 9 | FatFinger |
[risk] fat_finger_bps |
a trade prints nearer the price |
| 10 | MaxOrderQty |
[risk] max_order_qty |
the order is smaller |
| 11 | MaxOrderNotional |
[risk] max_order_notional |
the order is smaller |
| 25 | PricedOut |
[capacity] |
the order's value covers the price of its slot: the account's window rolls over, a fill gives a slot back, or the order is worth more (Price order capacity) |
| 24 | ReduceOnly |
fastmm-ctl reduce-only, [risk] reduce_only |
the order leaves the position nearer zero, or the mode is switched off (Reduce-only mode) |
| 12 | MaxPosition |
[risk] max_position |
the position or the same-side open orders shrink |
| 19 | FxRateUnknown |
[accounting] |
the settlement currency's source book updates within [accounting] stale_fx_ms; position-reducing orders pass |
| 17 | MaxGrossNotional |
[risk] max_gross_notional |
the portfolio's |position| shrinks, or the order only takes its instrument's position towards zero (what goes past zero counts) |
| 18 | MaxNetNotional |
[risk] max_net_notional |
the signed sum moves back, or the order only takes its instrument's position towards zero |
| 22 | UnderlyingMarkUnknown |
[risk.underlying] |
every inverse contract of the underlying with a position or open orders has a book no older than stale_md_ms |
| 21 | MaxUnderlyingNet |
[risk.underlying.<BASE>] max_net |
the underlying's position or same-side open orders shrink, or the order brings the net towards zero |
| 23 | BalanceShort |
[risk] check_balance |
the venue reports more free balance, or our orders on that asset end or fill (Balance check) |
| 13 | MaxOpenOrders |
[risk] max_open_orders |
an order of that instrument terminates |
| 14 | SelfTradePrevention |
[risk] stp |
our resting order on the other side moves or is cancelled |
| 15 | RateLimit |
[risk] orders_per_sec, burst |
the token bucket refills |
| 16 | MaxLoss |
— | never produced: a max-loss breach arrives as KillSwitch with KillReason::MaxLoss |
Cancels skip every check, including the kill switch.
OMS and transport¶
| Value | Name | Cause |
|---|---|---|
| 32 | PoolExhausted |
the order pool or the id map is full: more than 4096 working orders (kMaxOpenOrders, include/fastmm/core/oms.hpp) |
| 33 | UnknownOrder |
a cancel or replace for an id the OMS does not hold |
| 34 | InvalidState |
a cancel or replace for an order that is no longer working |
| 35 | DuplicateId |
the client order id is already in use, locally or at the venue |
| 36 | TransportFull |
the connector's outbound or REST queue was full; the message was dropped |
| 37 | NotReconciled |
never produced by the current code |
| 38 | InvalidTag |
ctx.send used a user_tag inside the quote manager's reserved range |
| 39 | OrderTableFull |
the connector's table of sent orders was full: 7168 working orders and replaces in flight, over every strategy behind a gateway |
| 40 | InvalidAccount |
NewOrderRequest::account named a venue outside the instrument's pool ([venues.<x>] pool_of) |
| 41 | HomeUnavailable |
placement = "home": the order goes to the instrument's home, whose order link is down or whose kill switch is engaged (Keep each position on one account) |
Gateway¶
A strategy attached to fastmm-gateway gets these back from the gateway's account guards (Run behind a gateway); the order never reached the connector.
| Value | Name | Cause |
|---|---|---|
| 48 | GatewayRateLimit |
[gateway] orders_per_sec, burst: the venue's order rate, shared by every attached strategy |
| 49 | GatewayOpenNotional |
[gateway] max_open_notional: the notional working at the venue, over every attached strategy |
| 50 | GatewayNotOwner |
the order's instrument is not one this strategy claimed when it attached |
| 51 | GatewayAccountKilled |
[gateway] max_loss tripped the account's kill switch |
| 52 | GatewayGrossNotional |
[gateway] max_gross_notional: the account's positions at the marks plus what this order opens; the part of it that takes its instrument's position towards zero passes |
| 53 | GatewayNetNotional |
[gateway] max_net_notional: the same for the signed sum |
| 54 | GatewayFxRateUnknown |
[accounting]: the order adds exposure in a currency whose source book is missing or older than [accounting] stale_fx_ms |
| 55 | GatewayUnderlyingNet |
[gateway.underlying.<BASE>] max_net: the account's net in the base asset over every venue, with same-side working orders and this one, would move further past the limit |
| 56 | GatewayUnderlyingMarkUnknown |
[gateway.underlying]: an inverse contract with a position or working orders has no book newer than [risk] stale_md_ms |
| 57 | GatewaySelfTrade |
[gateway.shared]: the order would trade with a resting order of another attached strategy on the same instrument |
| 58 | GatewayBalanceShort |
[gateway] check_balance: the account's balance on the venue, less the orders of every attached strategy, does not cover the order |
Venue-originated¶
Each connector maps its venue's error codes onto these; the code tables are on each venue's page under Venue connectors.
| Value | Name | Transient | What to do |
|---|---|---|---|
| 64 | VenueReject |
unknown | the code was not in the venue's table; read the message in the log |
| 65 | PostOnlyWouldCross |
yes | the quote would have taken; expected when quoting at the touch, and excluded from [engine] reject_backoff_ms |
| 66 | InsufficientBalance |
no | fund the account or shrink the quote |
| 67 | VenueRateLimit |
yes | the connector cools down; lower the request rate |
| 68 | VenueUnknownOrder |
no | the order is gone at the venue; most codes also trigger a reconciliation |
A quote the venue refuses, as a new order or as a replace, pauses its side for [engine] reject_backoff_ms, doubling with each further refusal up to reject_backoff_max_ms; a post-only cross or VenueUnknownOrder does not. So does a quote the engine's own PriceCollar or FatFinger check refuses. An accepted order on the side resets the doubling.
During the pause a requote cancels the side's resting order instead of replacing it, and the side's last quotes go out again when the pause ends. A price outside the collar or the venue's band during a move (PriceCollar) is therefore tried once a pause, not on every requote. Orders sent with ctx.send are the strategy's to retry.
Kill reasons¶
KillReason (include/fastmm/core/enums.hpp) is the first reason each kill-switch bit was set for. fastmm-top shows it per venue; the status file carries it in kill_reason.
| Value | Name | Scope | on_kill applies |
First thing to check |
|---|---|---|---|---|
| 0 | None |
— | — | not killed |
| 1 | Requested |
global | no, it always shuts down | why the shutdown started: signal, --duration, slow tier |
| 2 | MaxLoss |
global | yes | the PnL and the market before restarting |
| 3 | TransportFull |
global | yes | [engine] order_ring_bytes, and whether the network thread is starved |
| 4 | JournalOverflow |
global | yes | [engine] journal_ring_bytes, and disk write throughput |
| 5 | AllVenuesKilled |
global | yes | each venue's own kill reason |
| 6 | VenueFatal |
one venue | when it is the last venue | the key, its permissions and its environment |
| 7 | VenueHardStop |
one venue | when it is the last venue | a Binance 418 IP ban; terminal until the process restarts |
| 8 | OrderRingOverflow |
global | no, it always shuts down (exit 5) | [engine] order_ring_bytes, engine thread pinning |
| 9 | StrategyError |
global | yes | a Python hot hook raised, called ctx.fail or produced a non-finite value |
| 10 | FeedLost |
one venue | when it is the last venue | a nasdaq_itch feed that cannot rebuild its books |
| 11 | OrderIdsExhausted |
global | yes | the session's 32-bit order id sequence ran out; restart |
| 12 | DeadMansSwitchLost |
one venue | when it is the last venue | the venue refused the countdown refresh for a whole window |
| 13 | GatewayMaxLoss |
every venue | yes | the gateway's account: [gateway] max_loss over every strategy |
| 14 | GatewayOperator |
every venue | yes | an operator's kill on the gateway's control socket |
| 15 | StoreFailure |
global | yes | with [storage] kill_on_failure = true, a failed or dropped store write: the disk, the store file, [storage] ring_bytes |
fastmm-ctl unkill or SIGHUP clears a running session's kill switch. A latched max_loss trip refuses the next start (exit 6) until --clear-kill. What each reason does to orders: Kill switch and shutdown.
Venue actions¶
VenueAction (include/fastmm/venues/error_action.hpp) is what the connector does beyond reporting the reject. Every venue's error map returns one.
| Value | Name | Connector behaviour |
|---|---|---|
| 0 | None |
reports the reject and nothing else |
| 1 | Backoff |
retries later |
| 2 | RateLimit |
enters the rate limiter's cooldown, honouring Retry-After when the venue sends one, else 10 s |
| 3 | ResyncClock |
fetches the venue's server time and recomputes the offset (a no-op on Deribit) |
| 4 | Reconcile |
requests the venue's open orders |
| 5 | DisableInstrument |
the configured tick, lot or minimum is wrong for that symbol |
| 6 | HardStop |
stops REST until the process restarts, and trips the venue's kill switch with VenueHardStop |
| 7 | Fatal |
disables order entry and trips the venue's kill switch with VenueFatal |
Journal errors¶
tools/journal_dump.py and fastmm-replay report these:
| Symptom | Meaning |
|---|---|
trailer MISSING |
the session did not shut down cleanly; events before the damaged block are readable; fastmm-replay needs --allow-incomplete |
| a CRC failure on a block | the block is damaged; --no-crc reads past it |
replay MISMATCH |
the replayed order stream differs from the recorded one; only the first difference means anything (Determinism) |
| a what-if warning | --config or --strategy differs from the recording, so a match is not expected |
Related¶
- Troubleshooting: every log message with its cause and fix.
- Status file: where the counters and reasons are published.
- Storage:
sessions.clean_shutdown,journal_completeandrecords_droppedsay what a session's record is missing. - Run in production: restarts, venue-side switches, monitoring and accounting.