Skip to content

Configuration

Every FastMM program reads one TOML file passed with --config <file.toml>. Examples: configs/.

General rules

  • An unknown key or section is an error that names the key and its line; so is a [venues.<name>] key the connector its kind names does not have, and a [strategy.params] key the strategy does not declare.
  • A key with the wrong type is an error, reported with its line and column.
  • Decimal keys (tick, lot, max_order_qty, max_loss, ...) accept "0.01" or 0.01; both are parsed as decimal text into fixed point, not through a double.
  • fastmm-live and fastmm-gateway replace ${NAME} tokens in [venues.<name>] values: ws_url, ws_api_url, rest_url, ca_file, api_key, api_secret, api_passphrase and every connector key. A variable that is not set is an error, except that --dry-run clears an unset api_key, api_secret or api_passphrase.
  • A literal api_key, api_secret or api_passphrase longer than 32 characters is refused with venues.<name>.<key> looks like an inline secret; use ${ENV_VAR} or --allow-inline-secrets; --allow-inline-secrets accepts it.
  • Logs and journals contain the configuration with api_key, api_secret and api_passphrase masked.
  • Types: decimal values are marked in the meaning; any keys accept a string or a number.

[engine]

Key Type Required Meaning
name string session name, used in logs, journal file names and the status file (default "fastmm")
cpu integer CPU core of the engine thread; -1 = not pinned (default -1)
net_cpus integer array CPU cores of the network threads, one per venue in order; venues given the same core run on one thread when it polls (spin_mode = "busy", or net_spin_dedicated) and the core is not the engine's; otherwise, with spin_mode = "adaptive", a thread whose core it shares with the engine or another network thread blocks when idle instead of spinning (default [])
aux_cpus integer array fastmm-live, fastmm-gateway: CPU cores of the threads that are not the engine's or a network thread's (journal, store, audit, treasury, resolvers, main); empty = every core but cpu, net_cpus and the venues' md_copy_cpus, or, when those take every core, every core but cpu and the cores of network threads that never block, with a warning (default [])
spin_mode string busy (spin forever) | adaptive (spin briefly, then block until work arrives; use on WSL2 and laptops) (default adaptive)
net_backend string event loop of fastmm-live and fastmm-sim-exchange: epoll | io_uring (Linux 5.13 or newer; falls back to epoll with a warning) (default epoll)
threading string fastmm-live: split (engine and network threads, rings between them) | single (one venue; its network loop, the engine and order sending run on the engine thread, cpu; net_cpus is ignored) (default split)
journal boolean record every consumed event to a .fmj journal (default true)
journal_dir string directory for journals (default "runs")
journal_sync string how far a journal write is pushed: async (the kernel writes it back; survives the process dying) | fdatasync (fdatasync every 100 ms; survives power loss) (default async)
journal_max_bytes integer roll the journal over to the next part at this size, bytes; each part is a complete journal ("x.fmj", "x.1.fmj", ...); 0 = one file per session (default 0)
journal_retention_days integer delete journals (.fmj and .fmj.zst) in journal_dir last written more than this many days ago, at start and, in fastmm-live, every minute while it runs; 0 = keep everything (default 0)
journal_compress string fastmm-live: none | zstd: compress each journal in journal_dir nobody is writing to x.fmj.zst on a background thread, a minute after it was last written; the replay, backtest and tools read either form (default none)
journal_max_total_bytes integer cap on the journals in journal_dir, bytes, compressed or not: the oldest go first, at start and, in fastmm-live, every minute; a part being written is never deleted; 0 = no cap (default 0)
checkpoint_s integer with a journal, how often the engine writes a checkpoint to it: the strategy's state() (a strategy that keeps state), the positions and the open orders, seconds of engine time; a backtest can start from any of them (default 0: never)
epoch_file string session epoch file, keeps client order ids unique across restarts (default "runs/session_epoch")
kill_file string latched kill switch and cumulative PnL, so [risk] max_loss is a budget across restarts (default "/.kill")
instance_lock boolean fastmm-live: take an exclusive lock on lock_file before touching the account and refuse to start (exit code 8) while another process holds it; --standby and --takeover take it whatever this says (default false)
lock_file string the instance lock's file (default "/.lock")
handoff_timeout_ms integer fastmm-live --takeover: how long to wait for the running session to release the instance lock once it accepted the handoff, ms (default 75000)
markout_ms integer array with a store, the mid at each fill and this many ms after it, up to 4 horizons, in the store's markouts table (fastmm-pnl ab); e.g. [1000, 10000, 60000] (default: none)
stall_ms integer fastmm-live: an engine thread that has not finished a turn of its loop for this long (a strategy hook that never returns) is given up: every venue cancels all its orders and the process exits with code 5, ms; 0 = never (default 10000)
ack_timeout_ms integer force-cancel an order whose ack has not arrived within this long, ms; 0 = off (default 0)
queue_conservatism number the queue position estimate ctx.queue_ahead, from 0 to 1: at 0 a level's shrink is shared between cancels ahead of and behind our order, at 1 cancels never move it up (default 1.0; a backtest uses [backtest] queue_conservatism when set)
flatten_interval_ms integer how often an operator flatten looks at the position left and sends the next reduce-only slice, ms (default 500)
flatten_timeout_ms integer how long an operator flatten keeps trying before it gives up and leaves the position, ms; 0 = until it is flat or an operator stops it (default 60000)
flatten_slippage_bps integer how far through the touch a flatten prices its orders when the command gives no --max-slippage-bps, basis points (default 25)
rng_seed integer seed of the strategy random generator ctx.rng() (default 1)
md_ring_bytes integer market-data ring per venue, bytes, a power of two (default 4194304)
order_ring_bytes integer order-event ring per venue, bytes, a power of two (default 1048576)
journal_ring_bytes integer engine-to-journal ring, bytes, a power of two (default 16777216)
max_events_per_step integer events taken from each ring per engine iteration (default 64)
feed_budget_per_ring integer fastmm-live: events the engine takes from one input ring before the next ring's turn; 1 interleaves the rings, so a burst of one account's order events does not hold up the market data behind it (default 64)
net_spin_dedicated boolean with spin_mode = "adaptive": a network thread pinned to a core of its own (net_cpus, shared with neither the engine nor another network thread) polls without ever blocking, as with "busy", and so does the one thread of the venues net_cpus gives one core; threads on the engine's core or unpinned still block when idle (default false)
crossed_grace_ms integer tolerate a crossed book this long before pulling its quotes, ms (default 100)
latency_publish_ms integer latency histogram publish interval, ms (default 1000)
tsc_recalibrate_s integer fastmm-live: TSC recalibration period, s; 0 = off (default 10)
timer_slack_ns integer fastmm-live: timer slack of its threads, ns; how late a timed wait may end (adaptive spin_mode: the engine's idle wait, at most 1 ms, and with threading = "single" a 50 us sleep); 0 = the kernel's, 50000 (default 0)
restore_position boolean carry the previous session's positions over from the store and replay the venue's executions since its last recorded fill (venues that can replay executions); default true
lock_memory boolean fastmm-live: mlockall() the process, so no page is swapped out or faulted in on the hot path; needs ulimit -l above the process size, a warning otherwise (default false)
cpu_dma_latency_us integer fastmm-live: holds /dev/cpu_dma_latency at this many us for the session, so no CPU enters an idle state that takes longer to wake; 0 keeps every CPU polling in C0; needs write access to the device, a warning otherwise; -1 = no request (default -1)
rt_priority integer fastmm-live: SCHED_FIFO priority 1..99 of the engine thread (with threading = "single" it also runs the network loop); needs CAP_SYS_NICE or ulimit -r at least as high, a warning otherwise; a busy-spinning FIFO thread starves the kernel's threads on its core unless the core is isolated; 0 = the default scheduler (default 0)
net_rt_priority integer fastmm-live: SCHED_FIFO priority 1..99 of the network threads, as rt_priority; ignored with threading = "single"; 0 = the default scheduler (default 0)
log_irq_affinity boolean fastmm-live: at start, log each network interface's queue interrupts with the CPUs they may run on and which of them are cpu or net_cpus, and warn about any that may run on the engine's CPU; read only (default false)
endpoint_select boolean fastmm-live, fastmm-gateway: connect to the fastest of each venue host's addresses, as measured by TCP connects to every address the lookups return; the default of every [venues.] endpoint_select (default false)
endpoint_probe_interval_s integer with endpoint selection: how often a background thread looks the hosts in use up again and probes their addresses, s; connections also probe whenever they connect; 0 = only then (default 300)
endpoint_probe_samples integer with endpoint selection: TCP connects to each address per probe, ranked by their median, 1 to 100 (default 8)
endpoint_spread_us integer with endpoint selection: addresses this close to the fastest count as fast, and a new connection takes the one of them with the fewest connections, so a venue's md_copies spread over them, us (default 20)
endpoint_switch_us integer with endpoint selection: a live connection that rolls over (Binance) moves to the fastest address, make-before-break, once its own is this much slower or no lookup returns it; others move when they next connect; 0 = never moves, us (default 50)
min_requote_ticks integer keep a resting quote whose price is within this many ticks of the desired price (default 1)
min_requote_interval_ms integer change the same quote slot at most this often, ms (default 50)
min_qty_bps integer keep a resting quote whose remaining quantity covers this share of the desired quantity, bps (default 8000 = 80 %)
post_only boolean send quotes as post-only orders (default true)
supports_replace boolean let the quote manager amend orders in place where the venue supports it (default true)
reject_backoff_ms integer after the venue refuses a quote's new order or replace, other than a post-only cross or an order it no longer has, or the price collar or fat-finger band refuses it, no new orders or replaces on that side for this long, doubling with each further refusal, then the side quotes again, ms; 0 = off (default 1000)
reject_backoff_max_ms integer cap of the doubling reject backoff, ms (default 60000)
quote_token_reserve integer order tokens of [risk] orders_per_sec a quote that does not reduce the position leaves for the strategy's own orders and for quotes that do; quotes short of a token wait and are placed in turn as tokens return, not refused (default 0)
send_token_reserve integer order tokens of [risk] orders_per_sec every quote leaves for the orders the strategy sends itself, which are refused without a token where quotes wait for one; a quote that does not reduce the position leaves quote_token_reserve on top of it (default 0)
quote_room_reserve integer orders an account's venue order windows keep for quotes into empty levels and moves away from the touch: with no more left, a resting quote is not moved towards the touch and stays where it is; -1 = off (default 0: only when none is left)
on_kill string fastmm-live after a kill switch the engine trips itself ([risk] max_loss, a full ring, every venue killed): exit (normal shutdown, exit code 6) | stay (keep running with quoting off) (default exit)
cancel_unknown string open orders the engine does not know, found on its symbols at start-up and after a reconnect: all (cancel every one; the account must be FastMM's alone) | own (cancel only those with a FastMM client order id of this engine's epochs) (default all)
base_flows string a change of a spot instrument's base asset on its accounts that no fill and no transfer of the engine's made (a token dividend, an airdrop, a deposit): off | report (log and journal it) | adjust (and book it to the position at the mid) (default off)
base_flows_settle_s integer how long such a change must hold before it counts, s (default 30)
base_flows_from string what base_flows measures the accounts' balance against the position from: session (the difference when the session's balances first settle) | zero (the position is to equal the balance, a difference at the start included) (default session)

io_uring is blocked by some seccomp profiles, including Docker's default (Network reactor). tsc_recalibrate_s: the engine clock stays continuous and slews each measured offset away over one period (at most 500 ppm); it steps, with a warning, only when it was more than 1 ms off. on_kill: Kill switch and shutdown.

cancel_unknown: on its first connect and after every reconnect a connector reads the account's open orders on the session's symbols, and the engine cancels each one it does not know. With the default, all, that includes orders placed by hand or by another program, so give the session an account (or subaccount) of its own. own cancels only orders whose client order id FastMM wrote (fm and 12 hex digits) with a session epoch from 1 to this session's, which covers the orders an earlier session of this engine left behind, and leaves the rest. own does not make a shared account safe: the cancel-all of a kill or a shutdown, cancel_on_order_channel_loss and the venues' dead man's switches cancel every order on the symbol, whoever placed it.

base_flows: a spot instrument's position and its accounts' balance of the base asset move together, since a fill moves both and a transfer of the engine's between pool accounts leaves their total alone. A token dividend paid in tokens, an airdrop, a venue's correction, a deposit or a withdrawal moves the balance alone, and the venue may report it on no endpoint. Once a second the engine takes, for each base asset, the pool accounts' total less the position of its instruments; a change of that difference which holds for base_flows_settle_s is a flow. report logs it as a warning and journals it (BaseFlow in tools/journal_dump.py); adjust also books it to the instrument's position at the mid, so the PnL does not move and the position stays equal to what the accounts hold. With base_flows_from = "zero" the position is held to the whole balance, so a difference already there at the start is booked once the first balances settle; with session that first difference is left as it is. Nothing is measured while a venue reconciles, while an account's order link is down or one of its balances is unreported, or while a transfer of the asset is in flight, and an asset that is also an instrument's quote or settlement currency on the venue is not watched. A fill the engine missed looks like a flow until its execution arrives; the position then follows the balance back. Behind fastmm-gateway, other strategies' trades on the same account move the balance too: leave it off there.

[venues.<name>]

One table per venue; <name> is how instruments refer to it.

Key Type Required Meaning
kind string yes name of a registered connector; the keys it adds to this section are its own (see Connectors below)
ws_url string market-data WebSocket URL
ws_api_url string order-entry WebSocket API URL, where the venue has one
rest_url string REST base URL
api_key string API key, written as "${VARIABLE}"
api_secret string API secret, written as "${VARIABLE}"
api_passphrase string API key passphrase where the venue has one (OKX, Coinbase Exchange), written as "${VARIABLE}"
testnet boolean the endpoints are a testnet or demo environment (default true)
supports_replace boolean the venue can amend an order in place (default false)
insecure_tls boolean skip TLS certificate verification; local simulator only (default false)
ca_file string extra CA certificate, for example tests/fixtures/tls/cert.pem for the local simulator
public_only boolean market data only: no keys, no private sessions, no orders on this venue (default false)
pool_of string name of another [venues.] of the same kind whose instruments this account takes orders for, with its own keys, balances and order-count windows; no instruments or market data of its own (default none)
reduce_only boolean start in reduce-only mode for this venue's instruments: orders that would take a position further from zero are refused until fastmm-ctl reduce-only off --venue (default false)
recv_window_ms integer validity window of signed requests, ms (default 3000)
source_ip string the venue's connections leave this host from this address, IPv4 or IPv6; it must be one of the host's (default: the kernel chooses)
source_interface string the venue's connections leave this host from this network interface's address; exclusive with source_ip (default: the kernel chooses)
endpoint_select boolean connect to the fastest of each of the venue's host's addresses ([engine] endpoint_probe_interval_s and the other endpoint_ keys tune it); the connections keep the host name for TLS and HTTP (default: [engine] endpoint_select)
md_copies integer redundant market-data connections carrying the venue's top-of-book streams again; each update reaches the engine once, from whichever connection delivered it first (connectors with copies: binance, binance_usdm; 0 to 8, default 0)
md_copy_cpus integer array fastmm-live: CPU cores of network threads of their own for the copies, one per copy in order; copies given the same core share a thread, -1 = a thread not pinned; copies past the end of the list run on the venue's network thread (default [], all of them do)
fill_audit_interval_s integer fastmm-live compares the venue's trade history with the stored fills this often, s; 0 = off (default 0, at least 10)
fill_audit_lag_s integer a fill audit reads up to this long ago, s, so the execution replay has booked what it will (default 180)
fill_audit_mode string "report" logs and counts what differs; "book" also books the executions the engine missed (default "report")
rules_mismatch string a tick, lot, min_qty, max_qty or min_notional of [[instruments]] that differs from the venue's at start-up: "adopt" the venue's (default), "warn" and keep the configured one, or "refuse" to start
fees table [venues..fees] table: maker_bps and taker_bps, used for PnL
treasury table [venues..treasury] table: transfers that keep one asset spread over the accounts of the pool this venue is the primary of (fastmm-live)
pool table [venues..pool] table: where the pool this venue is the primary of keeps each instrument's position (home placement) and the planner that spreads the homes
transfers table [venues..transfers] table: the budget and breaker of the transfers the engine makes for the pool's sweep

[venues.<name>.fees]

Key Type Required Meaning
maker_bps number maker fee, bps; negative = rebate (default 0)
taker_bps number taker fee, bps (default 0)

Account pools

An exchange counts orders per account (Binance Spot: 100 new orders per 10 s and 200,000 per day). pool_of puts several accounts behind one venue: the primary carries the instruments and the market data as any venue does, and each member is another account of the same kind that takes orders for the primary's instruments with its own keys, balances and order-count windows.

[venues.binance]            # the primary: market data and orders
kind = "binance_spot"
api_key = "${K1}"
api_secret = "${S1}"

[venues.binance_b]          # a member: orders only, its own key and balances
kind = "binance_spot"
pool_of = "binance"
api_key = "${K2}"
api_secret = "${S2}"

A member's kind is the primary's; a member is nobody's primary, lists no [[instruments]] of its own and is not public_only; a pool holds at most 8 accounts, the primary included; the connector must run as a pool member (Binance Spot and USDⓈ-M do). The engine routes each new order to one account and the order stays there (Account pools); in a backtest, [venues.<member>] kind = "sim" with [backtest.venues.<member>.balances] gives the member its own simulated account ([backtest.venues.<name>]).

Binance counts request weight per IP, so a pool's accounts share the IP's window (6000 a minute on Spot, 2400 on USDⓈ-M): each request of any account counts against it, and a 429 or 418 answered to one account pauses or stops them all. Order counts stay each account's. Accounts that leave from different addresses (Source address) count apart.

Source address

On a host with several addresses, source_ip or source_interface sends every connection of a venue (market data, user stream, order entry, REST, and the blocking requests of start-up and the kill switch) from one of them, so that a venue counting request weight per IP sees each account's address:

[venues.binance_b]
kind = "binance_spot"
pool_of = "binance"
source_ip = "10.0.1.21"       # or: source_interface = "eth1"

The socket is bound to the address before it connects; source_interface binds to the interface's first address in the family of the venue's address. Binding chooses the source address only: the route, and with it the network device, follows the host's routing table, so no privilege is needed, and on a host with several devices the routing must send traffic from each address out of its device (source-based routing rules, as clouds set up for secondary interfaces). The operating system must hold the address already: fastmm-live and fastmm-gateway refuse to start when it is not one of the host's (source_ip 10.0.1.21 is not an address of this host) or the interface does not exist; any address in a loopback interface's network counts (127.0.0.2 on Linux). Only the venue's addresses of a family the source has are tried.

The two are exclusive; neither: the kernel chooses, as before. Binance Spot and USDⓈ-M accounts of a pool count request weight per source address: those leaving from one address (or all without one) share a window, cooldown and ban, as above. Every connector except nasdaq_itch binds; that one refuses the keys.

Fill audit

fill_audit_interval_s makes fastmm-live compare, every so many seconds, the account's executions as the venue reports them with the fills the store holds for that venue (every session of the engine), one by one by the venue's trade id: quantity, price, commission, side and order.

[venues.binance]
kind = "binance_spot"
fill_audit_interval_s = 600   # 0: off (default)
fill_audit_lag_s = 180        # read up to 3 minutes ago
fill_audit_mode = "report"    # or "book"

Each audit reads the window from where the last one ended to fill_audit_lag_s ago, the first from the session's start; a window that could not be read is read again with the next. The lag leaves the execution replay (once a minute) and the store time to book what they will. The venue's side is the same trade history the execution replay reads (myTrades, userTrades), read apart from it on the venue's network thread: one request per subscribed symbol and page (on Binance Spot, per symbol with executions in the window: a fill heard of or replayed, a cancel that found the order traded or gone), within the bulk share of the request weight and after the orders; nothing it reads reaches the engine. A difference is logged (fill audit: missing execution ..., phantom, differs in qty,fee, booked more than once, then an ERROR summary) and counted in the status file and the metrics (fastmm_venue_fill_audit_*), once per execution.

fill_audit_mode = "book" also books what the engine missed: the execution replay reads again from the first missing execution, the OMS keeps the executions it has not seen, and the next audit reads again from there to confirm. An execution is asked for once.

The audit needs the store ([storage]) and the venue in this process (not behind fastmm-gateway, where the key is ignored with a warning); a connector without it refuses to start. Binance Spot and USDⓈ-M have it. To audit after the fact, against a file the venue exported, use fastmm-pnl audit (Query what you traded).

[venues.<primary>.pool]

Where a pool keeps each instrument's position (Keep each position on one account). Without the table the pool routes by balance and keeps no homes.

Key Type Required Meaning
placement string "balance": each new order to the account whose balance covers it with the most order window left; "home": each instrument's position on one account, its home: an order goes there unless it takes a piece on another account towards zero (default "balance")
reduce_accounts integer accounts that may carry reducing orders of one instrument and side at once; 1 offers a piece alone until it is gone (default 1)
spill string "never": an order for a home that is down is refused HomeUnavailable; "flat": an instrument flat over the pool and not pinned moves to the usable account with the most order window first; "busy": a spot order that adds goes to the account the balance routing picks when its home is down, past spill_at of its 10 s window, short of the balance or priced out by [capacity], and the home stays (default "never")
spill_at number spill = "busy": the share of the home's 10 s order window, as its connector admits it, from which adding orders go to another account (default 0.8)
plan_interval_s integer how often the planner moves homes to spread the orders the homes carry over the accounts' 10 s windows, s; 0 = no planner (default 30)
plan_lookback_h number hours of the engine's own orders the planner plans from (default 1)
plan_max_moves integer instruments the planner moves at most per plan (default 3)
homes table { = "", ... }: pinned homes the planner and a spill never move (default none)
sweep any true: the engine moves a spot instrument's free base on another account of the pool to its home by internal transfer, and sends reducing orders to the home; "auto": true when the primary's connector has a transfer key (default false)
sweep_delay_ms integer a piece is swept once its holding and the free part of it have not changed for this long, ms (default 3000)
sweep_dust_s integer an amount below the tradable minimum is swept after this long, or with the delay when the home holds a tradable amount, s (default 3600)
sweep_retry_s integer after a refused transfer the payer's asset waits this long, s (default 30)
[venues.binance.pool]
placement = "home"
plan_interval_s = 30
homes = { BTCUSDT = "binance_b" }

The table goes on the pool's primary; homes names the primary's instruments and the pool's accounts. The planner runs in fastmm-live on the treasury's thread (fm-treasury), not in a dry run or behind fastmm-gateway, and in a backtest on simulated time.

[venues.<primary>.transfers]

The budget and breaker of the internal transfers a pool's sweep makes (sweep above, Sweep pieces home). Without the table the defaults apply.

Key Type Required Meaning
max_in_flight integer transfers unresolved at once, at most 16; one per asset (default 8)
per_minute integer transfers created in any minute (default 20)
per_hour integer transfers created in any hour (default 300)
per_day integer transfers created in any 24 h; once used, pieces trade off on their accounts (default 3000)
breaker_s integer the sweep pauses this long after 5 failures, 3 unknown answers or 10 refusals for want of balance in 10 minutes, or a rate-limit answer; a second trip turns it off until fastmm-ctl pool sweep on, s (default 900)
timeout_s integer an unresolved transfer this old is reported late, and one the venue has no record of fails, s (default 60)
status_interval_s integer a transfer not confirmed by both accounts' flows is asked for this often, s (default 10)
dry_run boolean journal and count the transfers the sweep would make; hold and send nothing, and route as without the sweep (default false)
state_file string the transfers in flight across restarts (default /..transfers)
[venues.binance.pool]
placement = "home"
spill = "busy"
sweep = true

[venues.binance.transfers]
per_hour = 60
per_day = 600

The table needs the pool's [venues.<primary>.pool]. The sweep runs in fastmm-live with a transfer key on the primary's connector (transfer_api_key_env), or with dry_run = true without one; a backtest simulates it on the pool's simulated accounts.

[venues.<primary>.treasury]

Each account of a pool has its own balance, so one can run short of the quote asset (or the margin) while another holds more than it needs. The pool treasury moves one asset between the pool's accounts by internal transfers, in fastmm-live, off by default.

Key Type Required Meaning
enabled boolean move the asset between the pool's accounts (default false)
dry_run boolean log and journal the planned transfers without sending them; needs no transfer key (default false)
asset string the asset kept spread, for example USDT; required when enabled
targets string "weights": each account's target is its weight's share of the pool's free balance; "demand": what the strategy's funding needs of the instruments homed there add up to (ctx.set_funding_need), needs a [venues..pool] table (default "weights")
headroom number demand targets: each account's need times (1 + headroom) (default 0.15)
reserve boolean the engine holds a planned transfer out of the payer's free balance until it resolves, so no order spends it first (default false)
weights table { = , ... }: each account's share of the pool's free balance (default 1 each)
min_free table { = "", ... }: free balance an account is topped up to and never gives below (default 0)
threshold number an account is short below its target times (1 - threshold), 0 to 1 (default 0.2)
min_amount any smallest transfer, decimal (default 0)
max_amount any largest transfer, decimal; 0 = no cap (default 0)
step any transfer amounts round down to a multiple of it, decimal (default 0.01)
interval_s integer how often the balances are looked at and a transfer in flight is asked for, s (default 10)
min_interval_s integer least time between two transfers sent, s (default 60)
max_per_hour integer transfers sent in any hour; 0 = no limit (default 12)
cooldown_s integer no transfer for this long after one failed or timed out, s (default 300)
timeout_s integer a transfer unresolved this long times out (cooldown_s; still asked for), and one the venue has no record of fails, s (default 60)
settle_s integer longest wait after a transfer for both accounts' balances to report it, s (default 30)
state_file string the transfers in flight, the id counter and the limiter across restarts (default /..treasury)
[venues.binance]
kind = "binance_spot"
transfer_api_key_env = "MASTER_TRANSFER_KEY"        # the master account's key, internal transfer only
transfer_api_secret_env = "MASTER_TRANSFER_SECRET"  # an Ed25519 key: transfer_key_type = "ed25519"
                                                    # and transfer_private_key_file instead
sub_account_email = "${ACCOUNT_A_EMAIL}"

[venues.binance_b]
kind = "binance_spot"
pool_of = "binance"
sub_account_email = "${ACCOUNT_B_EMAIL}"

[venues.binance.treasury]
enabled = true
asset = "USDT"
weights = { binance = 2, binance_b = 1 }   # default: equal shares
min_free = { binance_b = "200" }
max_amount = "5000"

The plan, every interval_s: each account's target is the pool's free balance of asset shared by weights. An account is short below max(target × (1 − threshold), min_free) and asks for max(target, min_free) less what it has; an account gives what it holds above max(target, min_free), and no more than the venue lets leave it (BalanceMsg::kWithdrawable: on Binance USDⓈ-M the asset's maxWithdrawAmount, which leaves unrealised profit out; other connectors say nothing and the free balance can leave). The largest need is matched with the largest giver first (ties: the account listed first), each transfer at most max_amount, rounded down to step, none below min_amount. The free balance is the engine's estimate (the venue's report less what the engine's own orders have held since), so a transfer never takes what an order holds; an account whose balance has not been reported stops the plan.

With targets = "demand" each account's target is instead what the strategy's funding needs of its home instruments add up to (ctx.set_funding_need), times 1 + headroom, plus min_free, measured against its free balance plus what its own orders hold; reserve = true has the engine hold each payout out of the payer's balance until it resolves (Fund each account of a pool).

One transfer at a time per pool, and at most one per min_interval_s and max_per_hour. After a transfer is done, both accounts' balances are asked for again and nothing new is planned until both have reported after it (at most settle_s). A failure, or a transfer still unresolved after timeout_s, holds the pool for cooldown_s; a failed transfer is never sent again, the next one is planned from the balances then. dry_run = true logs and journals what would be sent, needs no transfer key, and repeats the same plan only after min_interval_s.

Every transfer has a client id (fm + the primary's venue id + the time in base 36 + a counter) and is written to state_file before it is sent. A process that stops with a transfer unanswered asks the venue for it by that id when it starts again, before it plans anything; a transfer the venue has no record of after timeout_s failed. Each step (planned, sent, done, failed, timed out) is logged and reaches the engine as a ControlCommand::Transfer message (ControlTransferMsg), which the journal records; tools/journal_dump.py prints them. The status file and fastmm-top's Prometheus endpoint carry the counters (fastmm_treasury_*).

The primary's connector carries the transfers out and must have internal transfers (VenueCapabilities::internal_transfer; Binance Spot and USDⓈ-M do, with transfer_api_key_env, see Venues); each account's connector names its account (sub_account_email). The treasury runs on a thread of its own (fm-treasury) and does not run in a dry run of the whole session or in a strategy attached to fastmm-gateway. A backtest runs every enabled treasury on simulated time against the pool's simulated accounts ([backtest.venues.<member>.balances]): it looks at the venue's free amounts every interval_s, a transfer is carried out [backtest] transfer_latency_ms after it is sent (sim::SimTreasuryPort), the engine hears the new balances on each account's link, and nothing is written to state_file. The run stays deterministic; the result counts the transfers (BacktestResult::treasury, "treasury" in summary.json, a line in the summary table) and transfers.csv lists them.

Connectors

The connector kind names owns the rest of the section: it declares its keys, validates them and reports an unknown one with its line. The central schema (include/fastmm/config/schema.hpp) knows only the generic keys above. A project can register its own connector and keys (Add a venue). The built-in connectors:

kind Aliases Connector API keys Order entry Replace Positions
alpaca Alpaca US stocks (paper or live account, IEX data) yes yes yes yes
binance_spot binance, sim Binance Spot (testnet, Demo Mode, or the Binance-compatible simulator with kind = "sim") yes yes yes yes
binance_usdm Binance USDⓈ-M perpetual futures (Demo Trading) yes yes yes yes
bybit bybit_spot Bybit v5 spot and linear perpetuals (testnet) yes yes yes yes
coinbase_advanced Coinbase Advanced Trade spot (production, CDP API key) yes yes no no
coinbase_exchange Coinbase Exchange spot (sandbox) yes yes no no
deribit Deribit options and futures (testnet) yes yes yes yes
gate_usdt gate, gate_futures Gate APIv4 USDT-settled perpetual futures yes yes yes yes
gemini Gemini perpetuals and spot (sandbox) yes yes no yes
hyperliquid hl Hyperliquid perpetuals, main and builder-deployed dexes yes yes yes yes
lighter zklighter Lighter (zkLighter) perpetuals yes yes yes yes
nasdaq_itch Nasdaq TotalView-ITCH market data, with OUCH order entry to fastmm-sim-itch no yes yes no
okx OKX v5 USDT-margined perpetual swaps and spot (demo trading) yes yes yes yes

Replace and Order entry are what the connector can do; a session may not, depending on its configuration (a dry run, order_entry = "none", missing credentials).

alpaca

Key Type Required Meaning
ws_private_url string WebSocket URL of trade_updates (order states and executions); empty = wss://paper-api.alpaca.markets/stream
stale_ms integer no traffic, pongs included, for this long marks the feed stale and pulls the venue's quotes, ms (default 15000)
dead_ms integer no traffic for this long forces a reconnect, ms (default 30000; pings go every 5 s)
requests_per_minute integer client-side cap on new orders and replaces, per minute; the venue allows 200 requests a minute (default 200, 80 % of it used)
time_in_force string what a resting order is sent as: day (default) | gtc
extended_hours boolean resting limit orders may trade before and after the regular session (default false)
trades boolean subscribe to trades as well as quotes (default true)
allow_offline_reference_data boolean start without the asset endpoint, using the configured tick and lot (default false)
cancel_on_order_channel_loss boolean cancel the session's open orders over REST when trade_updates drops (default true)

binance_spot

Key Type Required Meaning
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 2000)
dead_ms integer no traffic for this long forces a reconnect, ms; raised to at least 45000
order_api string order entry: ws (default) | rest
allow_offline_reference_data boolean start without REST reference data, using the configured tick and lot (default false)
rules_refresh_s integer read exchangeInfo again this often while running, s, and adopt a changed tick, lot, limit or trading status; 0 = only after the venue refuses an order for them (default 60, at least 10)
cancel_on_order_channel_loss boolean cancel all orders over REST when order entry drops (default true)
emit_ack_from_response boolean acknowledge orders from the request response, not the event stream (default true)
amend_keep_priority boolean reduce size with order.amend.keepPriority, which keeps the queue position, instead of order.cancelReplace (default true)
order_rate_threshold number share of the venue's order-count limits (10 s, 1 d) the connector fills before it refuses an order; the request weight stays at 0.9 (default 0.9)
max_order_amends integer keepPriority amendments allowed on one order before falling back to cancelReplace (default 10, the venue's MAX_NUM_ORDER_AMENDS filter)
depth_limit integer REST snapshot depth, 5 to 5000 (weight 5 up to 100, 25 up to 500, 50 up to 1000, 250 above); default: 1000 with up to 10 subscribed symbols, else 100
key_type string hmac (default) | ed25519
private_key_file string Ed25519 private key file (PKCS#8 PEM), with key_type = ed25519
private_key_env string environment variable holding the Ed25519 private key PEM (instead of private_key_file)
md_format string json (default) | sbe (binary market data; needs an Ed25519 api_key)
sbe_ws_url string SBE stream URL; empty = ws_url with stream. -> stream-sbe.
user_stream string ws_api (default) | listen_key | none
position_from_balance boolean derive positions from account balances
fetch_fees boolean fastmm-live: fetch the account's maker and taker rates per symbol at start-up (GET /api/v3/account/commission) and use them instead of the configured fees; start-up fails when the request does (default false)
transfer_api_key_env string pool treasury: environment variable holding the master account's API key with internal transfer enabled, used for transfers between the pool's accounts only (default none: no transfers)
transfer_api_secret_env string environment variable holding that key's HMAC secret
transfer_key_type string the transfer key: hmac (default) | ed25519
transfer_private_key_file string the transfer key's Ed25519 private key file (PKCS#8 PEM), with transfer_key_type = ed25519
transfer_private_key_env string environment variable holding the transfer key's Ed25519 private key PEM (instead of transfer_private_key_file)
transfer_rest_url string host of the transfer endpoint, /sapi/v1/sub-account/universalTransfer (default https://api.binance.com)
sub_account_email string this account's sub-account email in a transfer; empty: the master account (default empty)

binance_usdm

Key Type Required Meaning
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 2000)
dead_ms integer no traffic for this long forces a reconnect, ms; raised to at least 45000 for market data and 240000 for the other channels
order_api string order entry: ws (default) | rest
allow_offline_reference_data boolean start without REST reference data, using the configured tick and lot (default false)
dead_mans_switch_ms integer venue-side countdownCancelAll window in ms; the venue cancels every open order of a symbol if the connector goes quiet for this long. 0 disables it (default 60000)
post_only_rpi boolean send post-only orders as RPI (matched only against app and web orders, hidden from the API depth) instead of GTX; needs supports_replace = false (default false)
cancel_on_order_channel_loss boolean cancel all orders over REST when order entry drops (default true)
emit_ack_from_response boolean acknowledge orders from the request response, not the event stream (default true)
depth_limit integer REST snapshot depth: 5, 10, 20, 50, 100, 500 or 1000 (weight 2, 5, 10 or 20); default: 1000 with up to 10 subscribed symbols, else 100
key_type string hmac (default) | ed25519
private_key_file string Ed25519 private key file (PKCS#8 PEM), with key_type = ed25519
private_key_env string environment variable holding the Ed25519 private key PEM (instead of private_key_file)
order_rate_threshold number share of the venue's order-count limits (10 s, 1 d) the connector fills before it refuses an order; the request weight stays at 0.9 (default 0.9)
md_ticker_conns integer the older spelling of md_copies: bookTicker-only connections; with both set, the larger count is opened (0 to 8, default 0)
ws_private_url string private WebSocket URL; empty = derived from ws_url
position_from_account_update boolean correct the engine position from ACCOUNT_UPDATE when it differs from the fills (default true)
one_way_mode boolean at start, switch an account in hedge mode to one-way mode when it holds no position and no open order (default false: a hedge-mode account refuses to start)
leverage integer at start, set this leverage (1 to 125) on every enabled symbol; 0 leaves the account's (default 0)
transfer_api_key_env string pool treasury: environment variable holding the master account's API key with internal transfer enabled, used for transfers between the pool's accounts only (default none: no transfers)
transfer_api_secret_env string environment variable holding that key's HMAC secret
transfer_key_type string the transfer key: hmac (default) | ed25519
transfer_private_key_file string the transfer key's Ed25519 private key file (PKCS#8 PEM), with transfer_key_type = ed25519
transfer_private_key_env string environment variable holding the transfer key's Ed25519 private key PEM (instead of transfer_private_key_file)
transfer_rest_url string host of the transfer endpoint, /sapi/v1/sub-account/universalTransfer (default https://api.binance.com)
sub_account_email string this account's sub-account email in a transfer; empty: the master account (default empty)

bybit

Key Type Required Meaning
category string product: spot (default) | linear (USDT- and USDC-margined perpetuals, one-way position mode only); ws_url must be the matching public stream
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 2000)
dead_ms integer no traffic for this long forces a reconnect, ms; raised to at least 45000
order_api string order entry: ws (default) | rest
allow_offline_reference_data boolean start without REST reference data, using the configured tick and lot (default false)
dead_mans_switch_s integer Bybit disconnect-cancel-all window in seconds, 3 to 300; the venue cancels every spot order (every derivatives order with category = linear) once no private connection is left. 0 disables it (default 0: Bybit only grants DCP to institutional accounts)
cancel_on_order_channel_loss boolean cancel all orders over REST when order entry drops (default true)
emit_ack_from_response boolean acknowledge orders from the request response, not the event stream (default true)
depth integer order book subscription depth, 1 to 1000
ws_private_url string private WebSocket URL; empty = derived from ws_url
ping_interval_ms integer application ping interval, ms, at least 1000
orders_per_second integer client-side order rate cap, orders/s
position_from_wallet boolean spot: derive positions from the wallet
position_from_stream boolean linear: correct the engine position from the position topic when it differs from the fills (default true)

coinbase_advanced

Coinbase Advanced Trade spot, production only (testnet = false): api_key is the CDP key name and api_secret its EC private key (Venue connectors).

Key Type Required Meaning
ws_private_url string WebSocket URL of the user channel (order states); empty = wss://advanced-trade-ws-user.coinbase.com
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 2000)
dead_ms integer no traffic for this long forces a reconnect, ms (default 10000; heartbeats come every second)
orders_per_second integer client-side cap on new orders, per second (default 8)
cancel_batch integer orders one batch_cancel request names in cancel-all, 1 to 100 (default 50)
allow_offline_reference_data boolean start without REST reference data, using the configured tick and lot (default false)
cancel_on_order_channel_loss boolean cancel all orders over REST when the user channel drops (default true)
emit_ack_from_response boolean acknowledge new orders from the POST orders reply as well as the user channel (default true)

coinbase_exchange

Coinbase Exchange spot; the third credential is the generic api_passphrase, and testnet = true (the default) selects the sandbox hosts (Venue connectors).

Key Type Required Meaning
ws_private_url string WebSocket URL of the user channel (order events); empty = ws_url
depth_channel string order book channel: level2_batch (default; batched every 50 ms, no signature) | level2 (signed: needs the keys)
stp string self-trade prevention of every order: dc (default) | co | cn | cb
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 2000)
dead_ms integer no traffic for this long forces a reconnect, ms (default 10000; heartbeats come every second)
orders_per_second integer client-side cap on new orders, per second (default 8; the venue allows 15 private REST requests a second)
cancel_all_rounds integer kill-switch DELETE /orders per product, repeated until one cancels nothing, at most this often, 1 to 10 (default 3)
allow_offline_reference_data boolean start without REST reference data, using the configured tick and lot (default false)
cancel_on_order_channel_loss boolean cancel all orders over REST when the user channel drops (default true)
emit_ack_from_response boolean acknowledge new orders from the POST /orders reply as well as the user channel (default true)

deribit

Key Type Required Meaning
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 10000)
dead_ms integer no traffic for this long forces a reconnect, ms; raised to three heartbeat intervals, 30000 by default
allow_offline_reference_data boolean start without REST reference data, using the configured tick and lot (default false)
cancel_on_order_channel_loss boolean cancel all orders over REST when order entry drops (default true)
emit_ack_from_response boolean acknowledge orders from the request response, not the event stream (default true)
ws_private_url string private WebSocket URL; empty = derived from ws_url
currencies any currencies for reference data, user channels and reconciliation, "BTC" or ["BTC", "ETH"] (default "BTC")
book_interval string book channel interval, 100ms (default) | agg2
ticker_interval string ticker channel interval, 100ms (default) | agg2
trades_interval string trades channel interval, 100ms (default) | agg2
heartbeat_interval_s integer public/set_heartbeat interval, s, at least 10
reject_post_only boolean reject crossing post-only orders instead of repricing them (default true)
cancel_on_disconnect boolean cancel-on-disconnect on the order connection (default true)
matching_engine_rate integer order requests per second of the account tier (default 5)
matching_engine_burst integer order request burst of the account tier (default 20)

okx

USDT-margined swaps, quantities in contracts, and spot pairs, quantities in the base coin. The third credential is the generic api_passphrase, testnet = true (the default) selects demo trading, and region the site the account is registered on (Venue connectors).

Key Type Required Meaning
region string the site the account is registered on, which sets ws_url and rest_url when they are empty: global (default; www.okx.com) | eea or my (my.okx.com: eea.okx.com, wseea / wseeapap) | us or app (app.okx.com: us.okx.com, wsus / wsuspap)
ws_private_url string private WebSocket URL (login, orders, positions); empty = ws_url's host + /ws/v5/private
td_mode string margin mode of every swap order: cross (default) | isolated; spot orders go with cash
depth_channel string order book channel: books (default; 400 levels, 100 ms) | books50-l2-tbt | books-l2-tbt (10 ms; VIP4 and a login)
order_api string order entry: ws (default) | rest
dead_mans_switch_s integer cancel-all-after countdown, seconds, 10 to 120, refreshed every third of it; the venue cancels every pending order of the account when it runs out. 0 disables it (default 60)
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 2000)
dead_ms integer no traffic for this long forces a reconnect, ms; raised to at least twice ping_interval_ms plus 5000
ping_interval_ms integer "ping" interval on every connection, ms, 1000 to 25000 (default 20000; OKX closes a connection idle for 30 s)
orders_per_second integer client-side cap on new orders and amends, per second (default 25; OKX allows 60 per 2 s per instrument)
position_from_stream boolean correct the engine position from the positions channel when it differs from the fills (default true)
allow_offline_reference_data boolean start without REST reference data, using the configured tick and lot (default false)
cancel_on_order_channel_loss boolean cancel all orders over REST when order entry drops (default true)
emit_ack_from_response boolean acknowledge new orders from the request response, not the orders channel (default true)

gate_usdt

USDT-settled perpetual futures on Gate, quantities in contracts, single position mode; one WebSocket URL serves the public channels, the private channels and the order API (Venue connectors).

Key Type Required Meaning
settle string settlement currency of the futures: usdt (default) | usd1 | btc; ws_url and rest_url must match it when set
order_api string order entry: ws (default, futures.order_place) | rest
book_level integer futures.obu depth: 50 (pushed every 20 ms, default) | 400 (every 100 ms)
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 2000)
dead_ms integer no traffic for this long forces a reconnect, ms; raised to at least 2 x ping_interval_ms + 5000
ping_interval_ms integer futures.ping interval on every connection, ms, at least 1000 (default 15000)
orders_per_second integer client-side cap on new orders and amends per second (default 50; the venue allows 100 per UID, 200 cancels)
emit_ack_from_response boolean acknowledge orders from the order_place reply, not the orders channel (default true)
position_from_stream boolean correct the engine position from the positions channel when it differs from the fills (default true)
cancel_on_order_channel_loss boolean cancel all orders over REST when order entry drops (default true)
allow_offline_reference_data boolean start without the contract table, using the configured tick, lot and multiplier (default false)
fetch_fees boolean read the account's maker/taker rates from GET /futures/{settle}/fee at start (default false)
dead_mans_switch_s integer POST /futures/{settle}/countdown_cancel_all window in seconds, refreshed at a third of it; the venue cancels every order of the account when no refresh arrives. 0 disables it (default 0)

gemini

Perpetuals and spot on the WebSocket API. The URLs default to the sandbox hosts and testnet must match the hosts; api_key is an account-scoped key with a time-based nonce (Venue connectors).

Key Type Required Meaning
cancel_on_disconnect boolean cancelOnDisconnect=true on the order connection: the venue cancels the orders placed on it when it closes (default true)
heartbeat boolean the API key has "Requires Heartbeat": POST /v1/heartbeat every 15 s; the venue cancels the key's orders after 30 s without one (default false)
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 2000)
dead_ms integer no traffic for this long forces a reconnect, ms; raised to at least twice ping_interval_ms plus 5000
ping_interval_ms integer ping interval on both connections, ms, 1000 to 60000 (default 10000; the venue sends no heartbeats)
orders_per_second integer client-side cap on new orders, per second (default 20)
allow_offline_reference_data boolean start without REST reference data, using the configured tick and lot (default false)
cancel_on_order_channel_loss boolean cancel this key's orders over REST (order/cancel/session) when the order connection drops (default true)

hyperliquid

Perpetuals on the main dex and the builder-deployed (HIP-3) dexes, such as xyz's US equities (xyz:NVDA). api_key is the account's address and api_secret the signing key: an agent wallet the account approved, or the account's own. testnet must be false for mainnet (Venue connectors).

Key Type Required Meaning
dex string builder-deployed perp dex whose coins may be named without their prefix (symbol NVDA for xyz:NVDA with dex = "xyz"); default none
vault_address string trade for this vault or sub-account of the account (0x and 40 hex digits); default none
order_api string order entry: ws (default, WebSocket post) | rest
l2_book boolean subscribe l2Book, 20 levels a side (default true)
bbo boolean subscribe bbo, the touch (default true)
trades boolean subscribe trades (default true)
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 5000)
dead_ms integer no traffic for this long forces a reconnect, ms; raised to at least 2 x ping_interval_ms + 5000 (default 60000)
ping_interval_ms integer {"method":"ping"} interval on every connection, ms, 1000 to 50000 (default 30000; the venue closes a connection that sent nothing for 60 s)
orders_per_second integer client-side cap on new orders and modifies per second (default 20)
posts_per_minute integer client-side cap on actions sent per minute, at most 2000 (default 1800; the venue allows 2000 WebSocket messages a minute)
address_reserve integer refuse new orders and modifies when no more than this many requests of the address budget (userRateLimit) would remain (default 200)
rate_limit_refresh_s integer read the address budget (userRateLimit) this often, s, at least 10 (default 60)
emit_ack_from_response boolean acknowledge orders from the action's reply, not the orderUpdates stream (default true)
cancel_on_order_channel_loss boolean cancel all orders over REST when order entry drops (default true)
allow_offline_reference_data boolean start without metaAndAssetCtxs, using the configured tick and lot (default false)
dead_mans_switch_s integer scheduleCancel window in seconds, at least 10, refreshed at a third of it; each refresh spends one request of the address budget and the venue allows 10 triggers a day. 0 disables it (default 0)
latency_log_s integer log the post reply round trip and the order open lag (block time - send time) this often, s; 0 off (default 60)

lighter

Lighter (zkLighter) perpetuals. api_key is the account index, api_secret the API key's private key (80 hex digits) and api_key_index the slot it is registered in; testnet = true selects the testnet hosts and chain id 300 (Venue connectors).

Key Type Required Meaning
api_key_index integer the slot the API key is registered in, 4 to 254 (tools/lighter_api_key.py registers one); needed with api_secret
order_api string order entry: ws (default, jsonapi/sendtx) | rest
order_book boolean subscribe order_book, the whole book (default true)
ticker boolean subscribe ticker, the touch (default true)
trades boolean subscribe trade (default true)
skip_nonce boolean sign every transaction with the SkipNonce attribute, so one the venue refuses does not fail the ones after it (default true)
stale_ms integer no traffic for this long marks the feed stale and pulls the venue's quotes, ms (default 5000)
dead_ms integer no traffic for this long forces a reconnect, ms; raised to at least 2 x ping_interval_ms + 5000 (default 60000)
ping_interval_ms integer {"type":"ping"} interval on every connection, ms, 1000 to 110000 (default 30000; the venue closes a connection that sent nothing for 2 minutes)
orders_per_second integer client-side cap on new orders and modifies per second (default 20)
tx_per_minute integer client-side cap on transactions sent per minute (default 3600; the venue allows 4000 on a Premium account with no LIT staked, 60 on a Standard one)
quota_reserve integer refuse new orders and modifies when no more than this much of the volume quota would remain (default 50)
order_expiry_s integer lifetime of a resting order, s, 300 to 2592000 (default 2419200, 28 days)
auth_ttl_s integer lifetime of the auth token of the account channel and the authenticated REST calls, s, 600 to 28740; the account channel reconnects with a new one at 90 % of it (default 25200)
terminal_wait_ms integer hold an order's cancel or expiry this long for the fills it counts, ms (default 2000)
emit_ack_from_response boolean acknowledge orders from the sendtx reply (accepted) rather than their open on account_all_orders (default false)
cancel_on_order_channel_loss boolean cancel all orders over REST when order entry drops (default true)
allow_offline_reference_data boolean start without orderBookDetails; no market can be traded then (default false)
dead_mans_switch_s integer scheduled CancelAll window in seconds, 310 to 1296000, refreshed at a third of it over the trade connection; each refresh is one transaction. 0 disables it (default 0)
latency_log_s integer log the sendtx reply round trip and the order open lag (venue time - send time) this often, s; 0 off (default 60)

nasdaq_itch

Line and recovery keys apply to the multicast feed; rx_backend selects how it is received and order_entry whether OUCH order entry is opened at all.

Key Type Required Meaning
rx_backend string multicast receive, kernel (UDP sockets) | af_xdp (needs CAP_NET_ADMIN, CAP_NET_RAW, CAP_BPF, CAP_IPC_LOCK) | dpdk (a -DFASTMM_WITH_DPDK=ON build, spin_mode = "busy") (default kernel)
interface string interface of both lines, name or IPv4 address; af_xdp needs a name (default: routing table)
line_a string line A, ":" (required)
line_b string line B, ":"; absent = one line
line_a_interface string interface of line A, overrides interface
line_b_interface string interface of line B, overrides interface
line_a_source string source address of line A: a source-specific join (default any source)
line_b_source string source address of line B
depth integer price levels per side sent to the engine, 1 to 256 (default 20)
queues any af_xdp: RX queues to bind on every line interface, [0, 1] or "0,1" (default: every RX queue the interface has)
dpdk_eal_args string dpdk: rte_eal_init arguments, space-separated (e.g. "--no-huge --no-pci --in-memory --vdev=net_af_packet0,iface=eth1")
dpdk_port string dpdk: ethdev name, e.g. net_af_packet0 or a PCI address (default: the first port)
dpdk_exception_port string dpdk: ethdev name of a net_tap vdev that carries the kernel's traffic on the port (ARP, GLIMPSE, re-requests, IGMP, kernel TCP); default none
dpdk_exception_ip string dpdk: "a.b.c.d/len" given to the exception port's interface
dpdk_exception_interval_us integer dpdk: how often the exception port is read, microseconds; 0 = every poll (default 20)
xdp_mode string af_xdp: auto | zerocopy | native_copy | generic (default auto: the first that works in that order)
rcvbuf integer kernel: SO_RCVBUF, bytes; 0 = system default (default 0)
batch integer datagrams per recvmmsg (kernel) or RX descriptors per poll (af_xdp), 1 to 1024 (default 32)
rerequest string MoldUDP64 re-request server, ":"; absent = gaps are unrecoverable
glimpse_url string GLIMPSE 5.0 server, ":"; absent = start at sequence 1 (before the directory spin)
glimpse_username string GLIMPSE login, at most 6 characters (default glimps, the simulator's)
glimpse_password string GLIMPSE password, at most 10 characters (default glimpse)
reorder_packets integer packets held ahead of a gap (default 256)
gap_timeout_ns integer a missing sequence awaited this long on every line is a gap, ns; size it from the A/B skew in the status (default 2000000)
max_request_attempts integer re-requests of one gap before it is unrecoverable; 0 = no limit (default 4)
request_timeout_ns integer re-send an unanswered re-request after this long, ns (default 250000000)
recovery_buffer_packets integer datagrams buffered while a GLIMPSE snapshot is taken, allocated at start (default 65536)
price_window_ticks integer L3 book price window per side, in 0.0001 steps, a multiple of 64 (rounded up to a power of two); orders outside go to an overflow store (default 65536)
max_orders integer resting orders per instrument the L3 book holds (default 262144)
max_overflow_levels integer price levels outside the L3 window per side, allocated at start; 0 disables overflow (default 8192)
hw_timestamps boolean kernel: enable NIC receive timestamps on the line interfaces (SIOCSHWTSTAMP, CAP_NET_ADMIN) (default false)
hw_clock string none | phc_synced: use the NIC timestamp as recv_ts (only when the PHC is synchronised to CLOCK_REALTIME) (default none)
order_entry string none (every order is rejected) | sim_ouch (OUCH 5.0 to fastmm-sim-itch) (default none)
ouch_url string sim_ouch: OUCH 5.0 server, ":"
order_transport string sim_ouch: kernel (TCP socket, TCP_NODELAY; the only value) (default kernel)
ouch_username string sim_ouch: login, at most 6 characters (default fmouch, the simulator's)
ouch_password string sim_ouch: password, at most 10 characters (default ouch)

[[instruments]]

Key Type Required Meaning
venue string yes name of a [venues.] table
symbol string yes venue symbol, for example BTCUSDT
base string base asset, for example BTC
quote string quote asset, for example USDT
asset_class string spot | perpetual (perp) | future (futures) | option | fx | equity (default spot)
tick any yes price increment, decimal
lot any yes quantity increment, decimal
min_qty any smallest order quantity, decimal
max_qty any largest order quantity, decimal
min_notional any smallest order value, settlement currency (base coin for an inverse contract), decimal
contract_multiplier any units of the underlying per contract, decimal; PnL and notional use it (default 1)
enabled boolean trade this instrument; false loads it without trading (default true)
price_decimals integer price display precision (default 8)
expiry string expiry of a derivative, ISO-8601
strike any option strike, decimal
option_type string call | put
maker_bps number maker fee of this instrument, bps; negative = rebate. Overrides the venue's fees table
taker_bps number taker fee of this instrument, bps. Overrides the venue's fees table
initial_margin any initial margin of a derivative, fraction of the notional (0.1 at 10x leverage), decimal; the balance check and estimate use it (default: none, an order passes while the venue reports margin available)

Live connectors replace tick, lot and the size bounds with the venue's reference data when they connect; the configured values are used by backtests and the simulator.

[strategy]

Key Type Required Meaning
name string yes registered strategy name (see --list-strategies)
max_param_age_ms integer disable quoting before the first parameter update and while none was applied for this long, ms of engine time (default 0: off)
state_file string file the strategy's state() is written to every state_interval_s and at the end, and restore() reads at the start (a strategy that keeps state; default: none)
state_interval_s integer how often the state is written, seconds of engine time (default 300)
params table [strategy.params] table: the strategy's parameters
groups table [strategy.groups] table: name = ["symbol" or "venue:symbol", ...], instruments that [strategy.overrides] and fastmm-ctl param --group name together
overrides table [strategy.overrides.] tables: parameters of one instrument ("symbol" or "venue:symbol") or group on top of [strategy.params]; an instrument's own table wins over its groups' (a strategy with a parameter set per instrument)

[strategy.params] holds scalars, validated against the strategy's parameter schema:

[strategy]
name = "first_mm"

[strategy.params]
edge_bps = 5.0
quote_qty = 0.001
  • Names, types, defaults and bounds come from the strategy's FASTMM_PARAM declarations; --list-strategies prints them (--format json for tools).
  • decimal values take up to 8 decimals and bps values up to 4; exponent notation is accepted (Fixed point). ms and int values are whole numbers.
  • An unknown parameter, a value with too many decimals or an out-of-range value is an error at startup.
  • --strategy and --param override this section (Command lines).
  • max_param_age_ms bounds the age of parameter updates sent while the session runs (Strategy API).

[ab]

An A/B test of strategy parameters, in fastmm-live and in a backtest (Run an A/B test).

Key Type Required Meaning
name string yes name of the test, up to 32 letters, digits, '_', '-' or '.'; the store and journal record it with every arm assignment
assignment string yes instrument (each instrument stays in one arm, the arms balanced on weights) | time (every instrument in the same arm, the arm changing each block) | crossover (instruments split as with instrument, each one changing arm each block) | branch (a backtest only: one run per arm over the same data and seed, every instrument in that arm from the start of trading)
seed integer seed of the instrument split and of the order of the arms over the blocks (default 1)
block_s integer time, crossover: block length, s; blocks start at multiples of it since 1970-01-01 UTC, and each run of as many blocks as there are arms gives every arm one, in an order drawn from seed (required with time and crossover, refused with instrument)
start string UTC time the test starts, YYYY-MM-DD, YYYY-MM-DDTHH:MM or YYYY-MM-DDTHH:MM:SSZ; before it the configured parameters run (default: at the start of the session)
end string UTC time the test ends, as start; after it the configured parameters run again (default: none)
weights table [ab.weights] table: instrument, crossover: the weight of each instrument ("venue:symbol" or "symbol" = number >= 0, e.g. its daily volume), every instrument or none; instruments of similar weight go to different arms (default: equal weights)
assign table [ab.assign] table: instrument, crossover: the arm of each instrument ("venue:symbol" or "symbol" = arm name) instead of a drawn split; an instrument not listed stays out of the test (default: drawn, balanced on weights)
block_offset_s integer time, crossover: blocks start this many seconds after the multiples of block_s, 0 to block_s - 1; with block_s = 86400, 79200 starts each day at 22:00 UTC (default 0)
arms any yes [[ab.arms]] tables, 2 to 16, in order: arm 0 is the control the readout compares the others with

Each [[ab.arms]] table is one arm:

Key Type Required Meaning
name string yes arm name, up to 16 letters, digits, '_' or '-'
params table [ab.arms.params] table: the arm's strategy parameters on top of [strategy.params] (default: none, the configured values); the parameters the arms name, 32 at most, belong to the test while it runs
[ab]
name = "spread-1"
assignment = "crossover"
block_s = 3600

[ab.weights]
BTCUSDT = 2.1e9
ETHUSDT = 9.5e8

[[ab.arms]]
name = "control"

[[ab.arms]]
name = "wide"
params = { half_spread_bps = 8, levels = 2 }
  • The arms' parameters are checked against the strategy's schema and validate() when the session or backtest starts; an unknown parameter or a value out of range is an error, exit code 3.
  • instrument and crossover give instruments different parameters, so the strategy must keep a set per instrument (ParamScope::PerInstrument, Strategy API); time works with any strategy that takes parameter updates.
  • While the test runs, fastmm-ctl param refuses the parameters the arms name.

[risk]

Every limit is off when it is 0 or omitted. A fastmm-live session that trades with real keys (a venue with an api_key, or an OUCH login, that is not public_only; not --dry-run) refuses to start, exit code 3, unless [risk] sets max_position or max_order_notional, and max_loss; allow_unlimited = true starts it without them. A dry run, a backtest, a replay and a strategy behind fastmm-gateway are not checked. Risk model describes the checks and their order.

fastmm-ctl limits changes any of these keys and check_balance while the session runs (Operating a running session).

Key Type Required Meaning
max_order_qty any largest order quantity, decimal
max_order_notional any largest order value, settlement currency (base coin for an inverse contract), decimal
max_position any largest absolute position per instrument, counting same-side open orders, decimal
max_open_orders integer open orders per instrument
price_collar_bps integer refuse limit prices further than this from the mid, bps
fat_finger_bps integer refuse limit prices further than this from the last trade, bps
stale_md_ms integer refuse orders when the instrument's book is older than this, ms
max_loss any trip the kill switch when net PnL falls to -max_loss, settlement currency (the [accounting] reporting_currency when set), decimal; latched across restarts in kill_file
max_loss_period string what max_loss is a budget for: total (every session since kill_file was cleared) | utc_day (net PnL from 00:00 UTC; a trip stays latched across the day) (default total)
max_gross_notional any refuse an order that would take the portfolio's summed |position| at the last marks past this, settlement currency (or reporting_currency), decimal
max_net_notional any refuse an order that would take the portfolio's signed position sum further past this, settlement currency (or reporting_currency), decimal
orders_per_sec integer token-bucket order rate, orders/s
burst integer token-bucket capacity, orders (default orders_per_sec)
stp boolean self-trade prevention against our own resting orders (default true)
max_feed_lag_ms integer pull a venue's quotes and refuse orders that could rest there without reducing the position while its market data arrives this much later than its baseline, ms; resumes 100 ms after the last message over it (default 0: off)
fill_cluster_names integer the fill-cluster guard: when maker fills of our quotes on one side cover this many distinct instruments within fill_cluster_window_ms, that side's quotes are pulled on every instrument for fill_cluster_hold_ms, then put back (0 to 16; default 0: off)
fill_cluster_window_ms integer the fill-cluster guard's window, ms (default 500)
fill_cluster_hold_ms integer how long the fill-cluster guard holds the side after the last fill that completed a cluster, ms (default 500)
hazard any [[risk.hazard]] tables, 16 at most: groups of instruments whose quotes on one side are pulled together when evidence that the side is being picked off reaches a threshold (default: none)
check_balance boolean refuse an order the venue's reported balance, less this session's orders and fills since, cannot cover; off for a venue until it reports balances (default true)
reduce_only boolean start in reduce-only mode for every instrument: orders that would take a position further from zero are refused until fastmm-ctl reduce-only off (default false)
allow_unlimited boolean let fastmm-live trade with real keys without max_position (or max_order_notional) and max_loss; without it such a session refuses to start, exit code 3 (default false)
underlying table one [risk.underlying.BTC] table per base asset: a net position limit over every instrument and venue that trades it

[[risk.hazard]]

A group of instruments whose quotes on one side are pulled together when evidence that the side is being picked off reaches threshold. Risk model describes the score.

[[risk.hazard]]
name = "semis"
instruments = ["NVDAUSDT", "AMDUSDT", "MUUSDT"]
threshold = 500      # quote notional of our fills, each piece halving every half_life_ms
half_life_ms = 20
hold_ms = 500
side = "bid"
mode = "log"         # "pull" once the log shows what it would have pulled
Key Type Required Meaning
name string yes group name, for the log
instruments string array yes the members: "symbol", "venue:symbol" or the name of a [strategy.groups] group; an instrument belongs to one hazard group at most
weights table [risk.hazard.weights] "symbol" or "venue:symbol" = number: what a unit of notional on that member adds to the score (default 1 for each member)
threshold number yes the score that pulls a side, in quote notional times weight; the score is the sum of the evidence, each piece halving every half_life_ms
half_life_ms number half-life of the score, ms (default 20)
hold_ms integer how long the side stays pulled after the last evidence that found the score at the threshold, ms (default 500)
side string the sides the group scores and pulls: "bid", "ask" or "both" (default "both")
prints boolean count a public print that reaches a quote of ours when it arrives before the fill's own report (default true)
mode string "pull" cancels the side's quotes and holds it; "log" keeps the score and only logs what it would have pulled and the fills that arrived meanwhile (default "pull")
  • An entry of instruments that names a [strategy.groups] group stands for its members.
  • [risk.hazard.weights] belongs to the [[risk.hazard]] table above it.
  • Not adjustable at run time.

[risk.underlying.<BASE>]

A limit on the net position in one base asset, in base units, over every instrument of the session whose base it is, on every venue. Long 0.3 BTC on one venue and short 0.3 BTC on another is 0 BTC.

[risk.underlying.BTC]
max_net = 0.5
  • A contract counts qty * contract_multiplier base units, an inverse one qty * multiplier / mark at its current mark. Options do not count. Risk model has the check and when it refuses.
  • The base asset is matched against each instrument's base without regard to case, once the venues' reference data has loaded; a base asset no instrument has (other than options) exits with code 3. At most 8.
  • max_net = 0 tracks the underlying (status, metrics) without a limit, so fastmm-ctl limits underlying.BTC.max_net=... can set one at run time.
Key Type Required Meaning
max_net any yes refuse an order that would take the net position in this base asset, open orders on the order's side included, further past this; base units (contracts times contract_multiplier, inverse contracts at the mark), decimal; 0: tracked, no limit

[[windows]]

A recurring time window: on given weekdays or dates, from a local time in a time zone, the engine pulls the quotes of a scope or holds it reduce-only, and lets go when the window closes. Schedule windows has examples.

[[windows]]
name = "weekly-reopen"
zone = "America/New_York"
days = ["sun"]
start = "19:55"
duration = "35m"
action = "reduce_only"
Case When the window opens or closes
start on a day the clock skips it (spring forward) at the jump: 02:30 on 2026-03-08 in New York opens at 03:00 EDT
start on a day the clock shows it twice (fall back) at the first: 01:30 on 2026-11-01 in New York opens at 01:30 EDT
duration across a change of offset wall-clock: Friday 17:00 plus 48h closes Sunday 17:00 local, 47 h later in March
end at or before start the next day
two occurrences overlap open while either is
  • days, dates, from, until and except are dates in zone, of the day an occurrence starts on.
  • The scope is the union of venues and instruments; without either it is the whole session. A pool's members follow the primary's venue.
  • action = "pull" stops quoting in the scope as fastmm-ctl pull does; "reduce_only" holds it as fastmm-ctl reduce-only on does (Operate a running session). The operator's switches and a window's add up: resume and reduce-only off do not end a window, and a window that closes does not end an operator's pull.
  • The engine evaluates windows on its own clock, so a backtest and a replay open and close them at the same events as the live session. The zones come from the IANA tzdata compiled into the build (status shows its release), not from the host. A zone is an IANA name or a POSIX TZ rule such as "EST5EDT,M3.2.0,M11.1.0". Times before 2000-01-01 take the zone's offset on that day.
  • 32 windows at most. Not adjustable at run time.
Key Type Required Meaning
name string yes the window's name, 1 to 32 letters, digits, '_', '-' or '.', for the log and the status
zone string yes the time zone of start, end and the dates: an IANA name ("America/New_York") of the tzdata compiled into the build, or a POSIX TZ rule ("EST5EDT,M3.2.0,M11.1.0")
days string array the local weekdays an occurrence starts on: "mon" ... "sun"; give days or dates
dates string array the local dates an occurrence starts on, "YYYY-MM-DD"; give days or dates
start string yes local time the window opens, "HH:MM" or "HH:MM:SS"; a time the clock skips opens at the jump, one it shows twice opens at the first
end string local time it closes, "HH:MM[:SS]": the same day when later than start, otherwise the next; give end or duration
duration string how long it stays open in wall-clock time, "30m", "1h30m", "2d" (units d, h, m, s), more than 0 and at most 7d; give end or duration
from string first local date an occurrence may start on, "YYYY-MM-DD" (default: no limit)
until string last local date an occurrence may start on, "YYYY-MM-DD" (default: no limit)
except string array local dates no occurrence starts on, "YYYY-MM-DD" (default none)
action string "pull": no quotes in the scope while open, as fastmm-ctl pull; "reduce_only": orders that add to a position are refused, as fastmm-ctl reduce-only on (default "pull")
venues string array the scope: every instrument of these [venues.] (default: with no instruments either, the whole session)
instruments string array the scope: "symbol", "venue:symbol" or a [strategy.groups] name (default: with no venues either, the whole session)

[capacity]

The price of an order slot: a new order or a move of a resting one is sent when what it is worth covers what its slot costs at that moment (Price order capacity). Cancels are never priced. Without the table, or with mode = "off", nothing is priced.

[capacity]
mode = "observe"
value = "learned"
orders_10s = 100
fill_credit = true
orders_1d = 200000
Quantity Value
the floor L the smallest min_notional of the instruments x the session's filled per placed notional (0.02 until learnt) x margin_bps / 10,000
R, the price of a full window over L [risk] max_order_notional over that minimum; 100 without max_order_notional
the price L up to R x L as the account's window fills, plus the day prices (Order capacity)
  • Prices and values are in the quote currency of the instruments; give the instruments of one quote currency in venues.
  • orders_10s is the venue's limit, not the connector's cap below it.
Key Type Required Meaning
mode string off | observe (price every new order and move, count and record what it would refuse, refuse nothing) | new (refuse new orders below their price, observe moves) | enforce (refuse both) (default off)
value string the value of a quote level whose strategy states none: off (worth any price) | learned (notional x the filled per placed notional of its instrument, side and size class x margin_bps) (default off)
orders_10s integer orders each account's window admits; the window's price rises as its share is used (Binance Spot 100) (default 0: the window is not priced)
venues string array the [venues.] whose accounts are priced, with their pools' members; the others' orders are neither priced nor counted (default []: every venue)
window_ms integer the account window's length, ms; windows start at multiples of it since 1970-01-01 UTC (default 10000)
fill_credit boolean an order's first fill gives its slot back to its window, as Binance's unfilled order count does (default false)
orders_1d integer orders each account may send per UTC day; a day price keeps the day's demand within it (Binance Spot 200000) (default 0: no day price per account)
orders_per_day integer the strategy's orders per UTC day over every account; a day price keeps the day's demand within it (default 0: no budget)
weight_1m integer request weight per minute shared by a pool's accounts (one IP); a new order, a replace and a cancel count 1 each (default 0: not priced)
margin_bps number what a filled unit of notional earns, rebate plus edge, bps; scales the learned values and the price floor (default 1)
full_move_bps number a move towards the touch of this many bps is worth a whole new order when the strategy states no keep value; a smaller move buys that share of the level's value (default 10)

[gateway]

Read by fastmm-gateway only: account guards over every attached strategy, checked before an order reaches the connector (Run behind a gateway). The rate and max_open_notional are per venue; max_loss, max_gross_notional and max_net_notional are over the account's positions on every venue, which the gateway books from the fills that pass through it and marks at the mids of its books. max_loss is carried in the gateway's kill file ([engine] kill_file, default <journal_dir>/<name>.kill) and latches like [risk] max_loss. Each strategy keeps its own [risk].

Key Type Required Meaning
orders_per_sec integer fastmm-gateway: new orders and replaces per second per venue, over every attached strategy (default 0: off)
burst integer fastmm-gateway: token-bucket capacity of orders_per_sec, orders (default orders_per_sec)
max_open_notional any fastmm-gateway: refuse an order that would take the notional working at its venue, over every attached strategy and both sides, past this; settlement currency, decimal
max_loss any fastmm-gateway: trip the account's kill switch when the net PnL of every strategy together, carried across restarts in the gateway's kill file, reaches -max_loss; decimal, in [accounting] reporting_currency when set
max_gross_notional any fastmm-gateway: refuse an order that would take the sum of the account's |position| at the marks past this, unless it only closes its instrument's position (an order through zero counts what it opens); decimal
max_net_notional any fastmm-gateway: refuse an order that would take the account's net position at the marks further past this, unless it only closes its instrument's position (an order through zero counts what it opens); decimal
underlying table fastmm-gateway: one [gateway.underlying.BTC] table per base asset: the account's net limit, over every strategy and venue
check_balance boolean fastmm-gateway: refuse an order the venue's reported balance, less the orders and fills of every attached strategy since, cannot cover (default true)
shared table fastmm-gateway: one [gateway.shared."venue:symbol"] table per instrument that several strategies may trade at once (default: one strategy per instrument)

[gateway.underlying.<BASE>]

[risk.underlying] for the account: the net position in one base asset over every instrument of the gateway, every venue and every attached strategy, with the orders working at the venues. Not adjustable at run time.

Key Type Required Meaning
max_net any yes fastmm-gateway: refuse an order that would take the account's net position in this base asset, working orders on the order's side included, further past this; base units, decimal

[gateway.shared."<venue>:<symbol>"]

An instrument of [[instruments]] that several attached strategies may trade at once (Run behind a gateway). Without this table a second strategy claiming it is refused. An empty table shares it with no primary.

[gateway.shared."bybit:BTCUSDT"]
primary = "hedger"
Key Type Required Meaning
primary string fastmm-gateway: [engine] name of the strategy that books this instrument's events naming no order (funding, liquidation fills, executions of orders placed elsewhere); default none: the account alone books them

[accounting]

Converts totals to one reporting currency, so instruments that settle in different currencies (an inverse contract in its base coin, a linear one in its quote currency) can share a session or a gateway. fastmm-live, fastmm-gateway, the backtester and replay read this section.

[accounting]
reporting_currency = "USDT"

[accounting.fx]
BTC = "binance:BTCUSDT"     # BTC in USDT: the mid of BTCUSDT
  • Positions, PnL and fees stay in each instrument's settlement currency. The PnL totals, [risk] max_loss, max_gross_notional and max_net_notional (and the [gateway] ones) are in reporting_currency, converted at the mid of each currency's source.
  • A source is "venue:symbol", an instrument listed in [[instruments]] (enabled = false if it is not traded): its book is where the rate comes from, so the session must subscribe to it. It prices the currency in reporting_currency either way round: BTCUSDT gives BTC in USDT, USDTBTC is inverted.
  • Once the venues' reference data has loaded, every settlement currency of an enabled instrument (of every instrument, in fastmm-gateway) must be reporting_currency or have a source. Otherwise fastmm-live and fastmm-gateway exit with code 3 while max_loss or an exposure cap is set, and warn and convert nothing when none is.
  • A rate is unknown until its source's book is valid, and not current while that book is invalid or has not updated for stale_fx_ms (default 60 s; 0: a valid book is enough). It is not [risk] stale_md_ms: a venue sends a book only when it changes, and a quiet FX pair can go seconds without one. With no current rate, an order that adds to exposure in that currency is refused (FxRateUnknown, GatewayFxRateUnknown in the gateway) while max_loss or an exposure cap is set; one that reduces a position passes. PnL already booked stays measured at the last rate; a currency whose rate was never known counts as zero, and nothing can be traded in it until it is.
  • Fees are booked in the settlement currency (a commission in the base asset is valued at the fill price); a commission in another asset is not booked, so it needs no source.
  • Without this section nothing is converted.
Key Type Required Meaning
reporting_currency string currency the PnL totals, [risk] max_loss and the exposure caps (and fastmm-gateway's) are in when instruments settle in more than one; every other settlement currency needs a source in [accounting.fx] (default unset: no conversion)
fx table [accounting.fx] table: one entry per other settlement currency, the instrument whose mid prices it in reporting_currency (BTC = "binance:BTCUSDT"; a pair quoted the other way round, USDTBTC, is inverted)
mark string what a derivative's position is valued at for the unrealized PnL, max_loss and the exposure caps (fastmm-gateway's too): venue (its venue's mark price while it is fresh, else the book's mid) | mid (default venue)
stale_mark_ms integer a venue's mark or index price older than this is stale: ctx.mark and ctx.index flag it and the position is valued at the mid, ms (default 15000)
stale_funding_ms integer a venue's funding rate older than this is stale (ctx.funding flags it), ms (default 180000)
stale_fx_ms integer an [accounting.fx] rate whose source's book has not updated for this long is not current: an order that adds exposure in that currency is refused; ms (default 60000; 0: a valid book is enough). Not [risk] stale_md_ms: a quiet FX book can go seconds without a change

[logging]

Key Type Required Meaning
level string trace | debug | info | warn (or warning) | error | off (default info)
file string log file; empty = stderr only
mirror_level string records at or above this level are also written to stderr (default warn)
status_interval_s integer seconds between the per-venue status lines, 0 = none (default 1 with a log file, 10 on stderr)

[shadow]

Read by fastmm-shadow and, for enabled, by fastmm-live (Shadow sweeps). The simulated venue's settings are the [backtest] keys below; a key in [shadow.grid] and [[shadow.points]] is a strategy parameter or one of the settings a sweep can vary (Running a sweep).

Key Type Required Meaning
enabled boolean fastmm-live starts fastmm-shadow from its own directory, which follows the session's journal in a process of its own (default false)
program string the program fastmm-live starts: an application's own fastmm::cli::shadow for its own strategies (default fastmm-shadow in fastmm-live's directory)
threads integer threads that step the points, at most 128 points each, plus one that reads the journal when there are two or more (default 1)
window_s integer length of a comparison window, seconds: the error of the simulation and the variants' intervals are per window, and each window closes settle_s after its end (default 60)
settle_s integer how far behind the journal the simulation runs, seconds: what the journal says about a venue time (acks, fills, parameter updates) must arrive within this for the runs to equal a backtest of the finished journal; the report counts what came later (default 10)
max_lag_s integer behind the session by more than this and not catching up, the highest-numbered half of the variants stop, seconds; the live point never does; 0 = never (default 300)
idle_exit_s integer a shadow fastmm-live started leaves when no session has written for this long, seconds (default 3600)
cpus integer array CPU cores the process may use; empty = every core but [engine] cpu and net_cpus (default [])
nice integer the process's nice value (default 10)
report string the report, rewritten as each window closes (default "/.shadow.json"), and beside it one line per window (.jsonl)
status string the status file fastmm-top reads (default "/dev/shm/fastmm-.shadow")
grid table variants, the cartesian product of = [values]: strategy parameters and the backtest settings a sweep can vary
points any more variants, [[shadow.points]] with one table of = value each

[storage]

Free-form: each backend reads its own keys (Storage). The keys every backend shares, then the SQLite backend's:

Key Type Required Meaning
backend string sqlite or none (default sqlite)
ring_bytes integer engine-to-store ring, bytes, a power of two (default 4194304)
kill_on_failure boolean fastmm-live: trip the kill switch (StoreFailure) when a store write fails or the ring drops a record (default false)
path string sqlite: the store file (default <journal_dir>/<name>.db)
retention_days integer sqlite: delete orders that ended, position snapshots, markouts and rejects older than this many days, while the session runs; fills and the rows a restart reads stay (Retention); 0 = keep everything (default 0)

[backtest]

Read by fastmm-backtest, fastmm-replay, the tests and the Python module (src/backtest/backtest_config.cpp); the section is free-form in the schema. The engine, risk and strategy settings come from the sections above; each instrument pays its own venue's fees table (or its own maker_bps / taker_bps), self-trade prevention follows [risk] stp, and in-place replace follows [engine] supports_replace, unless [backtest.venues.<name>] sets them for one venue.

Key Type Default Meaning
source string "" Market-data source: a name (synthetic, journal, csv, binance, tardis, itch) or a whole spec with its options ("binance:BTCUSDT,2024-03-27"). Several specs separated by ; are merged by event time, ties to the earlier spec ("binance:BTCUSDT,2024-03-27,venue=0; csv:bybit.csv,venue=1"); a TOML list is refused. When empty, the format is inferred from path (Market-data sources)
path string "" Data file, the positional argument of a bare source name. .fmj is a journal, .csv is CSV; empty means synthetic data
seed int [sim] seed, else 1 Seed for the synthetic market and the simulated venue; the engine's random generator uses [engine] rng_seed
duration_s int [sim] duration_s, else 60 Simulated horizon for synthetic data, s; must be positive
fill_model string "matching" matching matches our orders against the simulated order flow; over recorded data its book holds the recorded levels, and each recorded trade takes them in price-time order, ours among them. l2_queue estimates queue position on recorded L2 data, which has no counterparties; a post-only order is checked against the venue's book at its arrival, the book ticker's touch where it is newer than the depth or inside a stale depth level, and a resting order is filled by trades printed at or through its price and by opposite levels that come in at or through it (Backtesting). Its results are optimistic. l3_queue is l2_queue with the queue taken from order-by-order data (the itch source): each order sits behind the recorded orders that came before it, moves up only as they are cancelled or executed, and is filled by the executions that reach it (Backtesting); a run over a source without every order is refused
queue_conservatism number [engine] queue_conservatism, else 1.0 For l2_queue, from 0 to 1: at 0 cancellations ahead of us always move our order up the queue, at 1 they never do. The strategy's ctx.queue_ahead uses the same value in a backtest. fastmm-data fill-check compares values against a live session (Check the fill model), fastmm-data calibrate fits it (Calibrating). l3_queue does not use it. Measured against a Nasdaq day where every order's outcome is known, 0 comes within 1 % of the true filled quantity and 1 fills half of it (Backtesting)
latency_fixed_us int 200 Fixed latency for orders to the venue, and for acknowledgements back unless latency_ack_us is set, µs
latency_jitter_us int 50 Random jitter added to that latency, µs, seeded
latency_sigma number 0.5 Shape of that jitter: the excess over the fixed latency is the jitter times a lognormal of mean 1 and this sigma, so a larger value keeps the mean and gives a heavier tail; in (0, 4]
latency_ack_sigma number latency_sigma The same for acknowledgements and fills back from the venue
latency_cancel_sigma number latency_sigma The same for cancels to the venue; setting it gives cancels their own path, as the cancel keys do
latency_ack_us int latency_fixed_us Fixed latency for acknowledgements and fills back from the venue, µs
latency_ack_jitter_us int latency_jitter_us Random jitter added to that latency, µs, seeded
latency_md_us int 0 Fixed market-data latency, µs
latency_md_jitter_us int 0 Market-data latency jitter, µs
latency_cancel_us int latency_fixed_us Fixed latency for cancels to the venue, µs, when either cancel key is set; otherwise cancels take the order latency. A venue can take a cancel in faster than a new order (Binance Spot: about 0.4 ms less to its time on the ack)
latency_cancel_jitter_us int latency_jitter_us Random jitter added to that latency, µs, seeded
latency_fill_us int latency_ack_us Fixed latency for fills and balance updates back from the venue, µs, when any fill key is set: they then come on a path of their own, as a live venue's private stream sends them apart from its order API's replies, in order among themselves and holding up no ack (nor an ack them). Without the keys they come behind the acks, on the ack path
latency_fill_jitter_us int latency_ack_jitter_us Random jitter added to that latency, µs, seeded
latency_fill_sigma number latency_ack_sigma Shape of that jitter; a private stream whose 99th percentile is many times its median needs a sigma well above the default
order_service_us int 0 The venue takes the order messages (new, cancel, replace) of one connection one after another, each no sooner than this after the one before: a burst of cancels reaches the book later and later, as on a live venue. 0 draws every message's latency on its own and may reorder them. fastmm-data calibrate fits it (Calibrating)
md_arrival string "venue" When recorded market data reaches the strategy: venue at its venue time plus latency_md_us, recorded at the recv_ts it was recorded with plus latency_md_us, which replays the feed lag of a live journal ([risk] max_feed_lag_ms reads it); a message keeps its place behind the one before it
reorder_window_ms int 1000 Recorded data reaches the simulated venues in venue-time order, assuming no event was received more than this long after its venue time; the strategy still gets it in recorded order. 0 keeps the recorded order (Backtesting)
transfer_latency_ms int 0 With a pool treasury ([venues.<primary>.treasury]): a simulated transfer between the pool's accounts is carried out this long after it is sent; 0 carries it out at once
transfer_p_fail number 0 The share of simulated transfers the venue refuses: nothing moves
transfer_p_unknown number 0 The share whose answer is lost: the transfer is carried out transfer_hang_ms later, Pending until then
transfer_hang_ms int 90000 How long a transfer whose answer was lost hangs
p_drop number 0.0 Probability, below 1, that an outbound order message is lost
orders_10s int 0 The simulated venue's order count per 10 s (new orders and replaces, as Binance's ORDERS 10 s interval): one past it is refused with VenueRateLimit, and ctx.order_budget reports the count; 0 is unlimited and leaves the budget unknown
orders_1d int 0 The same per day
orders_credit_fills bool false An order's first fill takes one off each window's count, never below zero, as Binance Spot's unfilled order count does
equity_bar_s int 1 Bar length for the equity curve and the Sharpe ratio, s. The annualised Sharpe ratio is reported only for runs of at least 1 day (86,400 s); shorter runs report n/a (NaN in Python, null in summary.json)
initial_capital number 0 Starting capital, quote currency. The drawdown percentage is the largest fall from peak equity divided by this value; with 0 it is not reported (NaN in Python, null in summary.json)
markout_horizons_s string "1,10,60" Post-fill markout horizons in seconds, comma separated ("0.5,5" is allowed); "" turns markouts off. The run stops the simulated clock at every fill time plus horizon to read the venue mid there, so the shortest horizon also bounds how often the run loop is entered (Backtesting)
output_dir string "runs/backtest" Where equity.csv, fills.csv, orders.csv and summary.json are written
journal_out string "" When set, the backtest session is also recorded as a .fmj journal
own_orders_in_feed bool true The simulated venues' feed shows the strategy's resting orders, as a live venue's does: the engine's book and book tickers show our quantity (OwnLevels messages) and the engine takes it out where it needs to (ctx.own_qty, ctx.best_ex_self, ctx.queue_ahead); false shows the recorded data alone (Backtesting)
reconcile_on_unknown_cancel bool false A cancel the simulated venue refuses because it no longer holds the order (a fill won the race; Binance -2011) is followed by an open-order snapshot of that account, as the Binance connector asks for one on that reject: the engine reconciles as it does live
initial_state string "state_file" Where the strategy's starting state comes from: state_file reads [strategy] state_file when set; journal takes the data journal's: the state the recorded session restored at its start, else its first state snapshot, with the positions of that snapshot, or with the positions the session restored and reconciled before its first order (Backtesting); none starts the strategy fresh. journal needs a journal as the data source
params_from_journal bool false The data journal's parameter updates reach the strategy at the times the recorded session received them, their fields mapped by name and type onto the strategy's schema (as fastmm-replay maps them), except the parameters a sweep's point sets; the data source must be a journal
params_pinned string "" Parameter names, comma separated, that params_from_journal leaves at their configured values: a run of what a change would have done keeps the session's other updates
controls_from_journal bool false The data journal's operator commands reach the engine at the times the recorded session received them: quotes pulled and resumed, a flatten, limits changed, a kill switch tripped or reset, reduce-only mode switched, a pool home moved by the operator, or by the planner when the run does not plan that pool itself (plan_interval_s = 0). The data source must be a journal
start_at number or string none Unix time in seconds, or a UTC time ("2026-10-20T08:00:00Z"), that trading starts at: with initial_state = "journal" at the last checkpoint of the data journal at or before it, whose state the strategy restores, else at this time. Before it the run reads the data and the engine refuses orders (NotReconciled); then every venue reconciles with the start positions (Backtesting)
balances_from_journal bool false Each venue's account starts from the balances the journal recorded for it: its first snapshot, or with start_at its account as the venue last reported it when trading starts (every asset at its total; account-wide margin rows are left out); a venue without one keeps [backtest.balances]. From then on the account follows the session's account events: each recorded flow of money in or out (AccountFlow, Venues) at its time, a withdrawal at most what the run has free, and a full snapshot whenever the session's connector refreshed the account. A pool whose treasury the run simulates moves its own money: the session's transfers between its accounts (the same amount out of one and into another within 60 s) are left out; otherwise the payouts it held (reserve = true) move the engine's estimate as they did live. The data source must be one journal
latency_from_journal bool false The simulated venues follow the latencies the data journal's own messages had: an order or cancel takes the time a live one sent at about the same moment on the same account took to reach the venue (the one of the same instrument within 2 ms, else the nearest within 20 ms), a reply the time the nearest live reply took to come back, wherever that is more than 1 ms longer than the model's draw. Quiet moments keep the model; a burst, when the venue's gateway and its replies slow down, gets what the session got (Backtesting). The data source must be a journal

Command-line flags of fastmm-backtest (--data, --strategy, --param key=value, --seed, --duration, --out, --journal-out) override these values (Command lines).

[backtest.venues.<name>]

One venue's own settings; <name> is a [venues.<name>] that an instrument trades on, or a member of such a venue's pool (pool_of). Every venue an instrument names is simulated separately, and so is each pool member: orders, acknowledgements, fills and market data of an instrument go through its venue's latency and its venue's two connections, so a slow venue never delays a fast one, and an order's events come back on the member it went to. A missing key takes the value above. An unknown name, a venue without instruments or an unknown key is an error.

Key Type Default Meaning
latency_fixed_us int [backtest] Fixed latency for orders to this venue and acknowledgements back, µs
latency_jitter_us int [backtest] Jitter added to that latency, µs
latency_sigma number [backtest] Lognormal shape of that jitter
latency_ack_sigma number [backtest] latency_ack_sigma, else this venue's latency_sigma Shape of the acknowledgement jitter
latency_cancel_sigma number [backtest], else this venue's order shape Shape of the cancel jitter
latency_ack_us int [backtest] latency_ack_us, else this venue's latency_fixed_us Fixed latency for acknowledgements and fills back from this venue, µs
latency_ack_jitter_us int [backtest] latency_ack_jitter_us, else this venue's latency_jitter_us Jitter added to that latency, µs
latency_md_us int [backtest] Fixed market-data latency, µs
latency_md_jitter_us int [backtest] Market-data latency jitter, µs
latency_cancel_us int [backtest], else this venue's order latency Fixed latency for cancels to this venue, µs; the cancel key it does not set comes from [backtest], else from this venue's order latency
latency_cancel_jitter_us int [backtest], else this venue's order jitter Jitter added to that latency, µs
latency_fill_us int [backtest], else this venue's ack latency Fixed latency for fills and balance updates back from this venue on their own path, µs; the fill key it does not set comes from [backtest], else from this venue's ack path
latency_fill_jitter_us int [backtest], else this venue's ack jitter Jitter added to that latency, µs
latency_fill_sigma number [backtest], else this venue's ack shape Shape of that jitter
order_service_us int [backtest] Time this venue takes per order message of one connection, µs; each pool member is a connection of its own
md_arrival string [backtest] venue or recorded, for this venue's market data
p_drop number [backtest] Probability that an outbound order message to this venue is lost
supports_replace bool [engine] supports_replace In-place replace on this venue: the engine replaces quotes on its instruments if [engine] supports_replace is true, cancel and new otherwise
stp bool [risk] stp Self-trade prevention (cancel the taker) on this venue
orders_10s int [backtest] This venue's order count per 10 s (0: unlimited); per pool member, so the engine's routing sees each account's window
orders_1d int [backtest] This venue's order count per day
orders_credit_fills bool [backtest] A first fill gives back its order's slot in this venue's windows

[backtest.balances]

The account the simulated venue keeps: <ASSET> = "<amount>", one line per asset (a decimal string, at least 0). Without the table, and without balances_from_journal, the venues take every order whatever it costs and send no balances. With it, every venue an instrument trades on starts with these amounts, and an asset its instruments use that is not listed starts at 0; [backtest.venues.<name>.balances] replaces the table for one venue.

[backtest.balances]
BTC = "0.5"
USDT = "20000"

[backtest.venues.okx.balances]
USDT = "5000"

The venue holds each order's amount and refuses an order its free balance cannot cover with InsufficientBalance (venue code -2010, as Binance), and reports its balances as a live venue does: a snapshot at the start and an update after every order event that moved one. The engine's balance table, [risk] check_balance, ctx.balance and the strategies read those reports as they read a live venue's (Backtesting).

[backtest.positions]

The engine's positions at the start: <SYMBOL> = "<qty>" or "<qty>@<avg_px>", signed, for the instrument of that symbol (the first one listed when several venues trade it). They reach the engine as reconciled positions at the first step and replace, for the instruments listed, the positions initial_state = "journal" takes from the journal. A part from the middle of a live session holds no record of the positions the session had then; this table gives them (Backtesting).

[backtest.positions]
BTCUSDT = "0.35@67210.5"
ETHUSDT = "-2"

[sim]

The synthetic market; free-form in the schema. Prices and sizes use the first instrument's tick and lot. fastmm-sim-exchange and fastmm-sim-itch read their own keys from [sim] too (Simulated exchange, fastmm-sim-itch).

Key Type Default Meaning
seed int 1 Used when [backtest] seed is not set
duration_s int 60 Used when [backtest] duration_s is not set, s
start_mid decimal "60000" Initial mid price
seed_levels int 20 Price levels populated before the run starts
limit_rate_per_s number 200 Limit-order arrivals per second
cancel_rate_per_order_s number 0.5 Cancellation hazard of each resting order, per second
market_rate_per_s number 10 Market-order arrivals per second
mid_step_rate_per_s number 2 Steps of the latent mid price per second, times volatile_mult in the volatile regime
spread_bps number 4 The spread new limit orders leave around the latent mid, bps of start_mid; the book's spread is narrower, since orders a mid step left behind rest inside it
depth_bps number 1 Mean distance of a new limit order behind the touch, bps of start_mid (geometric)
mid_step_bps number 0.5 Size of one latent mid step, bps of start_mid
base_spread_ticks int from spread_bps Distance of the touch from the latent mid, ticks, at least 1; replaces spread_bps
offset_p number unset In (0, 1]. Limit orders land k ticks from the touch with probability p(1-p)^k, at most 200; replaces depth_bps
mid_step_ticks int from mid_step_bps Size of one latent mid step, ticks, at least 1; replaces mid_step_bps
limit_qty_median_lots number 200 Median limit-order size in lots (log-normal)
market_qty_median_lots number 100 Median market-order size in lots (log-normal)
regimes bool true Switch between a calm and a volatile regime
volatile_mult number 4.0 Multiplier on mid steps and market orders in the volatile regime
depth_update_ms int 100 Book changes are aggregated into one depth diff per interval, ms, like Binance @depth@100ms
book_ticker bool true Also publish top-of-book updates, at the same flush as the depth diff

At the defaults, a BTCUSDT-like instrument at 60,000 USDT with a 0.01 tick has a book 1.7 to 3.4 bps wide (10th to 90th percentile, 2.7 at the median) and 0.4 to 0.7 bps of volatility a square-root second. Setting a bps key and the tick key that replaces it is an error. configs/backtest-example.toml sets base_spread_ticks = 1, mid_step_ticks = 1 and offset_p: the one-tick market its golden fixtures record, 0.003 bps wide.