|
FastMM C++ API 0.14.0
Public headers, tier 1 and tier 2
|
Namespaces | |
| namespace | bt |
| namespace | cli |
| namespace | codecs |
| namespace | literals |
Exact literals, parsed at compile time: 100.25_px, 0.01_qty (up to 8 decimals), 5_bps, 0.25_bps (up to 4 decimals). More decimals, or a value out of range, is a compile error. An inline namespace, so using namespace fastmm; brings them in too (like std::literals). | |
| namespace | live |
| namespace | net |
| namespace | options |
| namespace | research |
| namespace | sim |
| namespace | store |
| namespace | venues |
Classes | |
| struct | AbArmSection |
| [ab]: an A/B test of strategy parameters (strategies/ab_test.hpp). No arms: no test. More... | |
| class | AbController |
| class | AbPlan |
| struct | AbSection |
| struct | AccountFlowMsg |
| Money that entered or left one account other than by its trades and funding (EventType::AccountFlow): a deposit, a withdrawal or a transfer between accounts, as the venue reported it. More... | |
| struct | BalanceMsg |
| The account's holding of one asset on one venue (EventType::Balance), as the venue reports it at its time hdr.exch_ts. More... | |
| struct | BinanceFuturesSyncTraits |
| Binance USDT-M futures: first applied delta must have U <= L and u >= L, or follow the snapshot directly (pu == L); afterwards each delta's pu must equal the previous delta's u. More... | |
| struct | BinanceSpotSyncTraits |
| Binance Spot: snapshot via REST (lastUpdateId = L). More... | |
| struct | BookDeltaMsg |
| Bids then asks follow the fixed part as a flexible array of Level (bid_count + ask_count). More... | |
| class | BookSyncer |
| struct | BookTickerMsg |
| struct | BybitSyncTraits |
Bybit v5: the stream itself sends a snapshot first (kSnapshot flag), then deltas whose u must be strictly increasing; u == 1 means the venue restarted the book (treated as a snapshot marker -> resubscribe). More... | |
| struct | CapacityConfig |
| class | CapacityDayPrice |
| The day price of one budget: the value at which the rest of the day's demand fits what is left. More... | |
| struct | CapacityMinute |
| A minute of one account (CapacityRecord): what was priced and refused. More... | |
| class | CapacityPrice |
| The prices, the windows and the learned yields of one engine. More... | |
| struct | CapacityQuote |
| What an action costs on one account now (ctx.capacity). More... | |
| struct | CapacityRecord |
| A minute of one account's capacity price ([capacity], core/capacity_price.hpp): the actions priced, those refused below their price and those that would have been (observe), and the price paid. More... | |
| struct | CapacitySection |
| [capacity]: the price of an order slot (core/capacity_price.hpp). More... | |
| class | CapacityThreshold |
| h(z): the knapsack threshold as a multiple of L, precomputed. More... | |
| struct | ClockReadings |
| Clock readings used by TscCalibrator. More... | |
| class | Config |
| class | ConfigError |
| struct | ConfigLoadOptions |
| struct | ConnectionStateMsg |
| struct | ContextNamesRecord |
| The names the strategy gave the values of its quote context (StrategyContext:: quote_context_names), in slot order; an empty name leaves a slot unnamed. More... | |
| struct | ControlBaseFlowMsg |
| ControlCommand::BaseFlow: a change of the base asset of spot instrument hdr.instrument on the accounts of pool hdr.venue (the primary) that the engine's fills and transfers do not explain ([engine] base_flows). More... | |
| struct | ControlLimitsMsg |
| struct | ControlMsg |
| struct | ControlTransferMsg |
| ControlCommand::Transfer: one step of a pool treasury's transfer (core/treasury.hpp), on the treasury's ring into the engine, which journals it. More... | |
| struct | ControlUnderlyingMsg |
ControlCommand::SetUnderlyingLimit: a ControlMsg whose arg is the new max_net (raw Qty, base units; 0 lifts the limit) of the underlying at index underlying of the session's plan (core/underlying.hpp), named in name for the log and a journal reader. More... | |
| struct | Cycles |
| struct | DesiredQuotes |
| struct | Duration |
| struct | EngineConfig |
| struct | EngineSection |
| struct | EngineTimeMsg |
| Journal only (format v2): the engine clock as an absolute value. More... | |
| struct | EventHeader |
| struct | FeeRates |
| One maker/taker pair. 1 cbps == 0.01 bps == 1e-6 of the notional. More... | |
| struct | FeesSection |
| class | FeeTable |
| struct | Fill |
| One execution as a strategy sees it (on_fill). More... | |
| struct | FillRecord |
| One execution. More... | |
| struct | Fixed |
| struct | FundingMsg |
| A perpetual funding payment the venue booked on the account's position in hdr.instrument (EventType::Funding). More... | |
| struct | FundingRecord |
A funding payment the engine booked (FundingMsg): amount in the instrument's settlement currency, negative paid. More... | |
| struct | GatewaySection |
| fastmm-gateway's account guards: one venue's account, shared by every attached strategy. More... | |
| struct | GenericSection |
| struct | Handle |
| struct | HazardSection |
| One [[risk.hazard]] table (core/hazard.hpp). More... | |
| class | HedgeExecutor |
| struct | HookInfo |
| struct | Instrument |
| struct | InstrumentRulesMsg |
| A venue changed an instrument's trading rules or trading status while the session ran (EventType::InstrumentRules): the connector read them again (venues/instrument_rules.hpp) and found them different from the last it reported. More... | |
| struct | InstrumentSection |
| class | InstrumentTable |
| Dense-by-id table built at startup; symbol lookup is a sorted FlatMap keyed by (venue, symbol). More... | |
| struct | KeySpec |
| struct | KillRecord |
| A kill switch trip. hdr.flags & kVenue marks a per-venue trip (hdr.venue names it). More... | |
| struct | KillState |
| Cumulative risk state across sessions. More... | |
| class | KillStateStore |
| class | L2Book |
| struct | LatencySampleMsg |
| struct | Level |
| One price level. Shared by book messages and the L2 book. More... | |
| struct | LimitOrder |
| Chainable builder returned by NewOrderRequest::limit(); converts to NewOrderRequest. More... | |
| struct | LimitsRecord |
An operator's limits command the engine applied (ControlCommand::SetLimits or SetUnderlyingLimit): the [risk] limits and check_balance before and after it, or one underlying's max_net. More... | |
| struct | LiveMetric |
| A number the strategy publishes by name (ctx.metric): a budget split, a model state. More... | |
| struct | LiveQuoteInstrument |
| struct | LiveQuoteSide |
| One side of an instrument as the engine publishes it (EngineLiveStats::quotes). More... | |
| class | LogClockScope |
While one is alive, the lines the thread logs carry the time of clock instead of the wall clock: a backtest's and a replay's lines name the moment of the data they were written at. More... | |
| struct | LogDescriptor |
| class | Logger |
| Process-wide registry of per-thread rings + the sink thread. Implemented in log_sink.cpp. More... | |
| struct | LoggingSection |
| struct | LogRecord |
| class | LogRunScope |
While one is alive, the lines the thread logs name run index of a sweep ("\#index", the points' order): a sweep's runs share the threads and the log. More... | |
| struct | MarkoutRecord |
The instrument's mid horizon_ms after one of its fills, 0 at the fill ([engine] markout_ms). More... | |
| struct | NewOrderRequest |
| class | Oms |
| struct | OmsStats |
| struct | OmsUpdate |
| struct | OptionTickerMsg |
| Options ticker (EventType::OptionTicker): the venue's mark, implied volatilities and greeks for one option instrument. More... | |
| struct | Order |
| struct | OrderAckMsg |
| struct | OrderAddL3Msg |
| struct | OrderCancelAckMsg |
| struct | OrderCancelL3Msg |
| struct | OrderCancelRejectMsg |
| struct | OrderExecL3Msg |
| struct | OrderExpiredMsg |
| struct | OrderFillMsg |
| struct | OrderRecord |
| The OMS record after a transition. More... | |
| struct | OrderRejectMsg |
| struct | OrderReplaceL3Msg |
| struct | OrderTimes |
| When the order's working leg (the order, or its latest replacement once acknowledged) was sent and accepted. More... | |
| struct | OrderTrail |
| How an order came to be where it was when something happened to it: kept by the OMS next to Order (Oms::trail), for an open order and for a recently terminal one, and copied into the record of each fill (FillRecord). More... | |
| struct | OutCancelMsg |
| struct | OutNewOrderMsg |
| struct | OutReplaceMsg |
| struct | ParamDesc |
| class | ParamPublisher |
| struct | ParamRecord |
| A strategy parameter update the engine applied (ParamUpdateMsg): after the header, the message's bytes past its own header, so the fields sit at the same offsets. More... | |
| class | ParamSchema |
| struct | ParamSink |
| Where a built update goes; push returns false when it was not accepted (full). More... | |
| struct | ParamUpdateMsg |
| New strategy parameter values (ADR-0013): up to kMaxFields (field index, raw value) pairs, built and validated off the engine thread (strategies/param_publisher.hpp). More... | |
| struct | PartyId |
| struct | PerpStateMsg |
| The venue's reference prices and funding of one derivative (EventType::PerpState), from its public market data. More... | |
| struct | PoolSection |
| [venues. More... | |
| struct | Portfolio |
| PnL totals over every instrument (StrategyContext::portfolio()), in the reporting currency when the tracker converts (PositionTracker::set_accounting). More... | |
| struct | Position |
| struct | PositionRecord |
| One instrument's position and the portfolio totals at the same instant. More... | |
| class | PositionTracker |
| struct | PositionUpdateMsg |
| struct | QuoteAction |
| struct | QuoteContext |
| class | QuoteManager |
| struct | QuoteNote |
| What the strategy says about a side (ctx.note_quote): a short reason ("inventory_cap", "model_off", "cooldown"; empty: none) and the budget it gave the side, in the settlement currency (raw 1e-8; 0: none given). More... | |
| struct | QuoteParams |
| struct | QuoteStats |
| struct | ReconcileMsg |
| Control thread injects the venue's view after a reconnect (5.8). More... | |
| struct | RecordHeader |
| class | RecordWriter |
| Engine-side producer. More... | |
| struct | RejectRecord |
| One order refused: by the pre-trade checks (the engine's) or by its venue (an OrderReject), with the account's order budget as the engine saw it then (ctx.order_budget). More... | |
| struct | ReplayedRecord |
| A venue's execution replay ended complete (a reconciliation began with ReconcileMsg::kExecutionsExact): every execution the venue made before it is in the records before this one. More... | |
| class | Result |
| class | Result< void, E > |
| Result<void, E>: success carries nothing. More... | |
| struct | RiskHeadroom |
| How much more each limit admits for one instrument now: the largest order (or number of orders) that passes that limit's check at this instant, the others aside. More... | |
| struct | RiskLimits |
| struct | RiskReject |
| A new order or replace the engine's own risk check refused (RiskEngine, [risk]): nothing was sent and no order exists for it. More... | |
| struct | RiskSection |
| struct | RunnerDeps |
| Everything a factory needs that is backend-independent. More... | |
| struct | Secret |
| Wrap a value to have it rendered as "***". More... | |
| class | SessionEpochStore |
| The 16-bit session epoch is the high half of every ClientOrderId, so two sessions that share one would let a venue's late message from the earlier session match an order of the later one. More... | |
| struct | SessionRecordMsg |
A record of a recorded session in the stream of a source that follows its journal, ahead of the market data it must reach the runs before (backtest/follow_source.hpp): hdr, of type Padding, which no source yields and no engine takes, then a copy of the record (ParamUpdate, Control, AccountFlow, a Balance that ends a snapshot). More... | |
| struct | SettlementMix |
| Instruments do not all settle in the same currency: an inverse contract settles in its base coin, a linear one in its quote currency. More... | |
| struct | ShadowSection |
| Free-form section used by the sim / backtest libraries: dotted keys -> stringified value. More... | |
| class | SimClock |
| Deterministic clock for sim/backtest/replay. 1 cycle == 1 ns. More... | |
| struct | StateOrder |
| One open order in a StrategyStateMsg's kOrdersPart: on the account (venue) it went to, its OrderState and Order::flags, its price and what it has left. More... | |
| struct | StatePosition |
| One instrument's position in a StrategyStateMsg's kPositionsPart: on the account (venue) whose Reconcile Position would set it. More... | |
| class | StateReader |
| class | StateWriter |
| class | StrategyBase |
| class | StrategyConflict |
| Thrown by register_strategy when a name is already registered with a different schema or factory. More... | |
| class | StrategyContext |
| struct | StrategyEntry |
| class | StrategyRegistry |
| struct | StrategySection |
| struct | StrategyStateMsg |
| Journal only: what a replay or a backtest over the journal can start from. More... | |
| struct | StrongId |
| struct | TimerMsg |
| struct | Timestamp |
| struct | TopLevels |
| Fixed-size result of top<N>(). More... | |
| struct | TradeMsg |
| A trade whose venue names the buyer and the seller carries them in the 64 bytes after the message: hdr.len is kSizeWithParties and parties() points at them. More... | |
| struct | TradeParties |
| struct | TransferRequest |
| struct | TransferResult |
| struct | TransfersSection |
| [venues. More... | |
| struct | TreasurySection |
| [venues. More... | |
| struct | TscAnchor |
| One simultaneous reading of the three clocks (the TSC is the midpoint of a tight bracket). More... | |
| struct | TscCalibration |
| class | TscCalibrator |
| Long-baseline TSC calibration for the calibrator (control) thread. More... | |
| class | TscClock |
| Periodic recalibration (see docs/explanation/architecture.md, "Clock calibration"): a calibrator thread measures with calibrate_tsc() and publishes into a Seqlocked<TscCalibration>; every TscClock user keeps its own copy and calls refresh() from its loop. More... | |
| struct | TscRecalibration |
| struct | Unexpected |
| class | VenueHealth |
| struct | VenueHealthView |
| What StrategyContext::venue_health returns. Durations are zero until the first sample. More... | |
| struct | VenueSection |
| struct | WindowSection |
| One [[windows]] table (core/windows.hpp), as written; window_config() resolves it. More... | |
| class | Xoshiro256ss |
Concepts | |
| concept | StrategyLike |
| concept | KeepsState |
Optional state the engine keeps across sessions ([strategy] state_file): std::string_view state() returns the bytes to save (valid until the strategy's next hook; the engine copies them at once) and bool restore(std::string_view) takes the bytes saved before, false when they are not this strategy's (it then starts fresh). | |
| concept | ClockLike |
| concept | MessageLike |
| Every message: trivially copyable with the EventHeader first. | |
| concept | FixedSizeMessage |
| concept | BookView |
Typedefs | |
| using | ParamMap = std::map< std::string, std::string > |
| using | StrategyModule = void(*)(StrategyRegistry &) |
| A strategy library's registration function. | |
| using | Price = Fixed< struct PriceTag > |
| using | Qty = Fixed< struct QtyTag > |
| using | Notional = Fixed< struct NotionalTag > |
| using | Ratio = Fixed< RatioTag > |
| A dimensionless factor: 1.0 == 1e8 raw, 1 bp == 10'000 raw, so 0.0001 bp is the smallest step. | |
| using | Symbol = FixedString< 20 > |
| using | InstrumentId = StrongId< struct InstrumentTag, std::uint32_t > |
| Dense index into the engine's instrument table. | |
| using | VenueId = StrongId< struct VenueTag, std::uint8_t > |
| using | ClientOrderId = StrongId< struct ClientOrderTag, std::uint64_t, 0 > |
| 48-bit: session_epoch(16) << 32 | seq(32). 0 is never issued. | |
| using | VenueOrderId = FixedString< 40 > |
| using | TimerId = StrongId< struct TimerTag, std::uint32_t > |
| using | ExecId = FixedString< 40 > |
| using | BookSnapshotMsg = BookDeltaMsg |
| same layout; hdr.type == BookSnapshot, kSnapshot set | |
| using | OwnLevelsMsg = BookDeltaMsg |
| EventType::OwnLevels, the same layout: each level is our resting quantity at that price as the feed shows it from now on, zero for none. | |
| using | LogRing = SpscRing< LogRecord, kLogRingSize > |
Enumerations | |
| enum class | ParamScope : std::uint8_t { Shared , PerInstrument } |
| How a StrategyBase keeps its parameters. More... | |
| enum class | Hook : std::uint8_t { FASTMM_HOOK_ENUM , FASTMM_STRATEGY_HOOKS } |
| enum class | HookStatus : std::uint8_t { Absent , Ok , Mismatch } |
| Absent: no member with the hook's name. More... | |
| enum class | ParamType : std::uint8_t { Int = 0 , Double = 1 , Bool = 2 , Decimal = 3 , Bps = 4 , Millis = 5 } |
| enum class | AbAssignment : std::uint8_t { Instrument , Time , Crossover , Branch } |
| enum class | TransportKind : std::uint8_t { Sim = 0 , Live = 1 , Replay = 2 , Count = 3 } |
| enum class | AddResult : std::uint8_t { Added , AlreadyPresent , Conflict , Invalid } |
| enum class | Transports : std::uint8_t { None = 0 , Sim = 1 , Replay = 2 , Live = 4 , All = 7 } |
| Internal: the factories register_strategy adds. More... | |
| enum class | InstrumentError : std::uint8_t { TableFull , DuplicateSymbol , InvalidTick , InvalidLot , EmptySymbol } |
| enum class | Side : std::uint8_t { Buy = 0 , Sell = 1 } |
| enum class | OrderType : std::uint8_t { Limit = 0 , Market = 1 , PostOnly = 2 } |
| enum class | TimeInForce : std::uint8_t { Gtc = 0 , Ioc = 1 , Fok = 2 , Day = 3 } |
| enum class | AssetClass : std::uint8_t { Spot = 0 , Perpetual = 1 , Future = 2 , Option = 3 , Fx = 4 , Equity = 5 } |
| enum class | OptionType : std::uint8_t { None = 0 , Call = 1 , Put = 2 } |
| enum class | OrderState : std::uint8_t { PendingNew = 0 , Live = 1 , PartiallyFilled = 2 , PendingCancel = 3 , PendingReplace = 4 , Filled = 5 , Canceled = 6 , Rejected = 7 , Expired = 8 } |
| enum class | RejectReason : std::uint8_t { None = 0 , KillSwitch = 1 , VenueKilled = 2 , InstrumentDisabled = 3 , InvalidTick = 4 , InvalidLot = 5 , BelowMinNotional = 6 , StaleMarketData = 7 , PriceCollar = 8 , FatFinger = 9 , MaxOrderQty = 10 , MaxOrderNotional = 11 , MaxPosition = 12 , MaxOpenOrders = 13 , SelfTradePrevention = 14 , RateLimit = 15 , MaxLoss = 16 , MaxGrossNotional = 17 , MaxNetNotional = 18 , FxRateUnknown = 19 , FeedLag = 20 , MaxUnderlyingNet = 21 , UnderlyingMarkUnknown = 22 , BalanceShort = 23 , ReduceOnly = 24 , PricedOut = 25 , PoolExhausted = 32 , UnknownOrder = 33 , InvalidState = 34 , DuplicateId = 35 , TransportFull = 36 , NotReconciled = 37 , InvalidTag = 38 , OrderTableFull = 39 , InvalidAccount = 40 , HomeUnavailable = 41 , GatewayRateLimit = 48 , GatewayOpenNotional = 49 , GatewayNotOwner = 50 , GatewayAccountKilled = 51 , GatewayGrossNotional = 52 , GatewayNetNotional = 53 , GatewayFxRateUnknown = 54 , GatewayUnderlyingNet = 55 , GatewayUnderlyingMarkUnknown = 56 , GatewaySelfTrade = 57 , GatewayBalanceShort = 58 , VenueReject = 64 , PostOnlyWouldCross = 65 , InsufficientBalance = 66 , VenueRateLimit = 67 , VenueUnknownOrder = 68 } |
| Ordered exactly like RiskEngine::check_new evaluates them (5.7), followed by OMS / transport / venue reasons. More... | |
| enum class | EventType : std::uint8_t { Padding = 0 , BookDelta = 1 , BookSnapshot = 2 , BookTicker = 3 , Trade = 4 , OrderAck = 5 , OrderReject = 6 , OrderCancelAck = 7 , OrderCancelReject = 8 , OrderFill = 9 , OrderExpired = 10 , PositionUpdate = 11 , Timer = 12 , Control = 13 , ConnectionState = 14 , Reconcile = 15 , LatencySample = 16 , OutNewOrder = 17 , OutCancel = 18 , OutReplace = 19 , OrderAddL3 = 20 , OrderExecL3 = 21 , OrderCancelL3 = 22 , OrderReplaceL3 = 23 , OptionTicker = 24 , EngineTime = 25 , ParamUpdate = 26 , Funding = 27 , Balance = 28 , PerpState = 29 , StrategyState = 30 , AccountFlow = 31 , OwnLevels = 32 , InstrumentRules = 33 , Count = 34 } |
| Message discriminator carried in EventHeader::type. More... | |
| enum class | TradingStatus : std::uint8_t { Trading = 0 , Halted = 1 , Closed = 2 } |
| Whether a venue takes orders on an instrument (Instrument::status, InstrumentRulesMsg). More... | |
| enum class | ConnState : std::uint8_t { Disconnected = 0 , Connecting = 1 , Live = 2 , Stale = 3 , Resyncing = 4 , Dead = 5 } |
| enum class | FeeAsset : std::uint8_t { Quote = 0 , Base = 1 , Other = 2 } |
| The asset a fill's commission is charged in. More... | |
| enum class | Liquidity : std::uint8_t { Unknown = 0 , Maker = 1 , Taker = 2 } |
| enum class | ControlCommand : std::uint8_t { Stop = 0 , PullQuotes = 1 , ResumeQuotes = 2 , TripKill = 3 , ResetKill = 4 , Reload = 5 , FlushStats = 6 , RecalibrateTsc = 7 , TripVenueKill = 8 , Flatten = 9 , SetLimits = 10 , Reconcile = 11 , SetUnderlyingLimit = 12 , TakeOver = 13 , Transfer = 14 , ResetLossBudget = 15 , ReduceOnly = 16 , PoolHome = 17 , PoolSweep = 18 , BaseFlow = 19 } |
| enum class | KillReason : std::uint8_t { None = 0 , Requested = 1 , MaxLoss = 2 , TransportFull = 3 , JournalOverflow = 4 , AllVenuesKilled = 5 , VenueFatal = 6 , VenueHardStop = 7 , OrderRingOverflow = 8 , StrategyError = 9 , FeedLost = 10 , OrderIdsExhausted = 11 , DeadMansSwitchLost = 12 , GatewayMaxLoss = 13 , GatewayOperator = 14 , StoreFailure } |
| Why a kill switch (global or one venue's) was tripped. More... | |
| enum class | FlattenState : std::uint8_t { Off = 0 , Working = 1 , Flat = 2 , TimedOut = 3 , Stopped = 4 } |
| How far an operator flatten (ControlCommand::Flatten) got. More... | |
| enum class | LogLevel : std::uint8_t { Trace = 0 , Debug = 1 , Info = 2 , Warn = 3 , Error = 4 , Off = 5 } |
| enum class | TscKind : std::uint8_t { None , Constant , Invariant } |
| What /proc/cpuinfo says about the TSC (cached after the first call): Invariant constant_tsc + nonstop_tsc: wall time and intervals from the TSC. More... | |
| enum class | TscRefresh : std::uint8_t { None = 0 , Adopted , Reanchored , Stepped , Rejected } |
| Outcome of TscClock::refresh() / reanchor(). More... | |
| enum class | PartyIdKind : std::uint8_t { None = 0 , Account = 1 , Address = 2 } |
| One side of a public trade as the venue names it, on venues that publish who traded (Hyperliquid: wallet addresses; Lighter: account indexes). More... | |
| enum class | OmsAction : std::uint8_t { None = 0 , Ignored , Duplicate , CancelUnknown , LateFill , UnknownFill , ReconcileNeeded } |
| enum class | OrderClass : std::uint8_t { Open , RecentlyTerminal , Unknown } |
| enum class | QuoteActionKind : std::uint8_t { New , Cancel , Replace } |
| enum class | QuoteBlock : std::uint8_t { Quoting = 0 , NotWanted = 1 , QuotingOff = 2 , Pulled = 3 , VenueKilled = 4 , FeedLag = 5 , Backoff = 6 , Starved = 7 , Refused = 8 , Pending = 9 , FillCluster = 10 , Hazard = 11 , Window = 12 , NotTrading = 13 } |
| The first obstacle between what the strategy asked for on a side and orders working there. More... | |
| enum class | BaseFlows : std::uint8_t { Off = 0 , Report = 1 , Adjust = 2 } |
| [engine] base_flows: what the engine does with a change of a spot instrument's base asset that neither its fills nor its transfers made (Engine::flow_tick). More... | |
| enum class | CapacityMode : std::uint8_t { Off = 0 , Observe = 1 , New = 2 , Enforce = 3 } |
| enum class | CapacityValue : std::uint8_t { Off = 0 , Learned = 1 } |
| The value of a quote level whose strategy states none. More... | |
| enum class | LogArgType : std::uint8_t { Int = 1 , Uint = 2 , Double = 3 , Bool = 4 , Char = 5 , PriceFx = 6 , QtyFx = 7 , NotionalFx = 8 , Str = 9 , Secret = 10 } |
| enum class | KeyType : unsigned char { String , Int , Float , Bool , IntArray , StringArray , Table , Any } |
| enum class | TransferState : std::uint8_t { Pending = 0 , Done = 1 , Failed = 2 , NotFound = 3 , Unknown = 4 } |
| enum class | TreasuryEventKind : std::uint8_t { Planned = 0 , Sent = 1 , Done = 2 , Failed = 3 , TimedOut = 4 , Reserve = 5 , Released = 6 , Request = 7 } |
| What the treasury reports through TreasuryPort::record (journal) and its counters. More... | |
| enum class | SyncState : std::uint8_t { Idle = 0 , Buffering = 1 , Synced = 2 , Resync = 3 } |
| enum class | SyncReason : std::uint8_t { None = 0 , SequenceGap = 1 , BufferOverflow = 2 , SnapshotTooOld = 3 , Explicit = 4 , SnapshotMarker = 5 , ChecksumMismatch = 6 } |
| enum class | RecordType : std::uint8_t { Fill = 1 , Order = 2 , Position = 3 , Kill = 4 , Funding = 5 , Replayed = 6 , Param = 7 , Reject = 8 , Limits = 9 , Markout = 10 , Capacity = 11 , ContextNames = 12 } |
| Never 0: the ring reserves type 0 for padding. More... | |
| enum class | RejectSource : std::uint8_t { Risk = 0 , RiskBucket = 1 , AccountPaused = 2 , AccountOrders10s = 3 , AccountOrders1m = 4 , AccountOrders1d = 5 , VenueLocal = 6 , Venue = 7 , Capacity = 8 } |
| What refused an order (RejectRecord::source): the limit behind a rate-limit refusal, or the side that refused it otherwise. More... | |
Functions | |
| template<class S > | |
| constexpr std::uint32_t | state_version_of (S &s) noexcept |
The layout of the bytes state() returns: static constexpr std::uint32_t state_version, or a state_version() member function; 0 when the strategy declares none. | |
| template<class S , class Ctx , class Book > | |
| constexpr HookStatus | hook_status (Hook h) noexcept |
| template<class S , class Ctx , class Book > | |
| constexpr bool | implements_hook (Hook h) noexcept |
True when the engine calls S's hook h (the engine dispatches on this at compile time). | |
| template<class S , class Ctx = detail::hooks::StandInContext, class Book = detail::hooks::StandInBook> | |
| constexpr bool | verify_strategy () noexcept |
Compile-time check of every hook of S; always returns true (failures are static_asserts), so it can be written as static_assert(fastmm::verify_strategy<MyMM>());. | |
| template<class S , class Ctx , class Book > | |
| constexpr std::string_view | implemented_hooks () noexcept |
| The implemented hooks as words in table order ("start book fill timer connection quoting"). | |
| constexpr std::string_view | to_string (ParamType t) noexcept |
| constexpr std::string_view | to_string (AbAssignment a) noexcept |
| std::optional< std::int64_t > | parse_utc_time (std::string_view s) |
| "YYYY-MM-DD", "YYYY-MM-DD HH:MM" or "YYYY-MM-DD HH:MM:SS", with a T for the space and a trailing Z allowed, UTC, as ns since the epoch. | |
| std::string | format_utc_time (std::int64_t ns) |
| "YYYY-MM-DD HH:MM:SS UTC". | |
| constexpr std::string_view | to_string (AbController::State s) noexcept |
| constexpr Price | mid (Price bid, Price ask) noexcept |
| constexpr Price | microprice (Level bid, Level ask) noexcept |
| Size-weighted microprice of the touch, truncated toward zero. | |
| constexpr Ratio | spread_ratio (Price bid, Price ask) noexcept |
| (ask - bid) / mid; zero when the mid is not positive. 1 bp == Ratio raw 10'000. | |
| constexpr Price | away_from (Price ref, Side side, Price dist) noexcept |
A price dist away from ref on the passive side: Buy -> ref - dist, Sell -> ref + dist. | |
| constexpr bool | inventory_allows (Side side, Qty position, Qty qty, Qty limit) noexcept |
Whether a fill of qty on side keeps the position within +-limit: Buy needs position + qty <= limit, Sell needs position - qty >= -limit. | |
| void | keep_passive (DesiredQuotes &q, Price best_bid, Price best_ask, Price tick) noexcept |
| Post-only quotes must not cross the market. | |
| void | fit_side (StaticVector< Level, kMaxQuoteLevels > &levels, Qty room, const Instrument &inst) noexcept |
Cuts one side of a ladder to room in total, keeping the levels closest to the mid: each level is rounded down to the lot, and one left under the lot, the instrument's min_qty or its min_notional ends the side (the venue would refuse it). | |
| template<class Ctx > | |
| void | fit_to_reported (Ctx &ctx, InstrumentId id, const Instrument &inst, DesiredQuotes &q) noexcept |
| Cuts both sides of a ladder to what the account's balance on the instrument's venue covers (StrategyContext::balance_room, priced at the side's dearest level). | |
| template<class Ctx > | |
| FASTMM_FORCE_INLINE void | fit_to_balance (Ctx &ctx, InstrumentId id, const Instrument &inst, DesiredQuotes &q) noexcept |
| constexpr std::string_view | to_string (TransportKind k) noexcept |
| constexpr std::string_view | to_string (AddResult r) noexcept |
| const std::vector< StrategyEntry > & | list_strategies () |
| template<class S > | |
| std::unique_ptr< IEngineRunner > | sim_factory (TransportKind kind, RunnerDeps &deps) |
Declared template <class S>, not template <StrategyLike S>: GCC and Clang mangle constrained templates differently. | |
| template<class S > | |
| std::unique_ptr< IEngineRunner > | replay_factory (TransportKind kind, RunnerDeps &deps) |
| template<class S > | |
| std::unique_ptr< IEngineRunner > | live_factory (TransportKind kind, RunnerDeps &deps) |
| constexpr Transports | operator| (Transports a, Transports b) noexcept |
| constexpr bool | has (Transports set, Transports t) noexcept |
| template<class S , Transports Enabled = Transports::All> | |
| void | register_strategy (StrategyRegistry &r) |
Adds the Sim, Replay and Live factories of S (or those in Enabled). | |
| template<class T > | |
| constexpr Fixed< T > | operator* (Fixed< T > v, Ratio r) noexcept |
| value * ratio in the value's domain, through Int128 with one truncation toward zero: mid * 5_bps, qty * ratio(filled, total). | |
| template<class T > | |
| constexpr Fixed< T > | operator* (Ratio r, Fixed< T > v) noexcept |
| constexpr Ratio | operator* (Ratio a, Ratio b) noexcept |
| template<class T > | |
| constexpr Ratio | ratio (Fixed< T > num, Fixed< T > den) noexcept |
| num / den as a Ratio, truncated toward zero; zero when den is zero. | |
| constexpr Notional | mul (Price p, Qty q) noexcept |
| price * qty with a 128-bit intermediate, truncated toward zero to 1e-8. | |
| template<class A , class B > | |
| constexpr std::int64_t | mul_raw (Fixed< A > a, Fixed< B > b) noexcept |
| Generic scaled multiply for fixed*fixed in one domain (e.g. qty * multiplier). | |
| constexpr Price | div (Notional n, Qty q) noexcept |
| notional / qty -> price (used for average cost). Truncates toward zero. | |
| template<class T > | |
| constexpr Fixed< T > | apply_bps (Fixed< T > v, std::int64_t bps) noexcept |
| value * bps / 10000 in one domain. | |
| constexpr std::int64_t | floor_div (std::int64_t a, std::int64_t b) noexcept |
| Floor division for possibly-negative numerators (prices are >= 0, but be safe). | |
| constexpr Price | round_to_tick (Price p, Price tick, Side side) noexcept |
| Round to the tick grid in the passive direction: bids down, asks up. tick > 0. | |
| constexpr Price | round_to_tick_nearest (Price p, Price tick) noexcept |
| constexpr bool | on_tick (Price p, Price tick) noexcept |
| constexpr Qty | round_to_lot (Qty q, Qty lot) noexcept |
| Quantities always round down (never send more than intended). | |
| constexpr bool | on_lot (Qty q, Qty lot) noexcept |
| template<class T > | |
| constexpr Fixed< T > | min (Fixed< T > a, Fixed< T > b) noexcept |
| template<class T > | |
| constexpr Fixed< T > | max (Fixed< T > a, Fixed< T > b) noexcept |
| template<class T > | |
| constexpr std::optional< Fixed< T > > | checked_add (Fixed< T > a, Fixed< T > b) noexcept |
| Checked arithmetic: nullopt instead of a wrapped int64. The operators stay unchecked; these are for the places that combine a value from outside the engine with a configured one. | |
| template<class T > | |
| constexpr std::optional< Fixed< T > > | checked_sub (Fixed< T > a, Fixed< T > b) noexcept |
| template<class T > | |
| constexpr std::optional< Fixed< T > > | checked_mul (Fixed< T > a, std::int64_t k) noexcept |
| constexpr Price | operator""_px (unsigned long long v) noexcept |
| 100_px == Price::from_int(100). | |
| constexpr Qty | operator""_qty (unsigned long long v) noexcept |
| template<char... Cs> | |
| constexpr Price | operator""_px () noexcept |
| template<char... Cs> | |
| constexpr Qty | operator""_qty () noexcept |
| template<char... Cs> | |
| constexpr Ratio | operator""_bps () noexcept |
| constexpr Side | opposite (Side s) noexcept |
| constexpr int | sign (Side s) noexcept |
| constexpr std::string_view | to_string (Side s) noexcept |
| constexpr std::string_view | to_string (OrderType t) noexcept |
| constexpr std::string_view | to_string (TimeInForce t) noexcept |
| constexpr std::string_view | to_string (AssetClass a) noexcept |
| constexpr bool | is_terminal (OrderState s) noexcept |
| constexpr bool | is_pending (OrderState s) noexcept |
| constexpr std::string_view | to_string (OrderState s) noexcept |
| constexpr std::string_view | to_string (RejectReason r) noexcept |
| constexpr std::string_view | to_string (EventType t) noexcept |
| constexpr std::string_view | to_string (TradingStatus s) noexcept |
| constexpr std::string_view | to_string (ConnState s) noexcept |
| constexpr std::string_view | to_string (Liquidity l) noexcept |
| constexpr std::string_view | to_string (ControlCommand c) noexcept |
| constexpr std::string_view | to_string (KillReason r) noexcept |
| constexpr std::string_view | to_string (FlattenState s) noexcept |
| constexpr std::string_view | to_string (LogLevel l) noexcept |
| FASTMM_FORCE_INLINE void | write_cl_ord_id (char *dst, ClientOrderId id) noexcept |
| Writes the kClOrdIdChars characters of the wire form to dst (no terminator) with two 8-byte stores. | |
| FixedString< 16 > | encode_cl_ord_id (ClientOrderId id) noexcept |
| std::optional< ClientOrderId > | decode_cl_ord_id (std::string_view s) noexcept |
| constexpr ClientOrderId | make_cl_ord_id (std::uint16_t epoch, std::uint32_t seq) noexcept |
| constexpr std::uint16_t | cl_ord_id_epoch (ClientOrderId id) noexcept |
| constexpr std::uint32_t | cl_ord_id_seq (ClientOrderId id) noexcept |
| constexpr Duration | nanoseconds (std::int64_t v) noexcept |
| constexpr Duration | microseconds (std::int64_t v) noexcept |
| constexpr Duration | milliseconds (std::int64_t v) noexcept |
| constexpr Duration | seconds (std::int64_t v) noexcept |
| FASTMM_FORCE_INLINE Cycles | rdtscp () noexcept |
| Serialising read (rdtscp) is what latency hops want: it waits for prior loads to retire. | |
| FASTMM_FORCE_INLINE Cycles | rdtsc () noexcept |
| Timestamp | wall_now () noexcept |
| CLOCK_REALTIME via vDSO (~20 ns). Implemented in src/core/time.cpp. | |
| Timestamp | steady_now () noexcept |
| TscKind | tsc_kind () noexcept |
| bool | has_invariant_tsc () noexcept |
| FASTMM_FORCE_INLINE std::uint64_t | tsc_interval_ns (const TscCalibration &c, std::uint64_t cycles) noexcept |
| A TSC cycle interval in ns; 0 without a rate. | |
| ClockReadings | system_clock_readings () noexcept |
| TscCalibration | calibrate_tsc (Duration window=milliseconds(50)) noexcept |
Startup calibration (spins for window): TscCalibrator::start(), so the rate is measured against CLOCK_MONOTONIC_RAW and a host wall-clock step inside the window cannot distort it; the anchor follows CLOCK_REALTIME. | |
| TscCalibration | calibrate_tsc (Duration window, const ClockReadings &readings) noexcept |
| constexpr const char * | to_string (TscRefresh r) noexcept |
| FASTMM_FORCE_INLINE std::int64_t | tsc_to_ns (const TscCalibration &c, std::uint64_t tsc) noexcept |
TSC reading -> wall ns under c. | |
| template<class E > | |
| constexpr Unexpected< std::decay_t< E > > | fail (E &&e) noexcept |
| template<class M > | |
| constexpr void | init_header (M &m, EventType type, InstrumentId inst={}, VenueId venue={}, std::uint32_t len=static_cast< std::uint32_t >(sizeof(M))) noexcept |
| For fixed-size messages len defaults to sizeof(M); BookDeltaMsg passes size_for(). | |
| constexpr std::uint8_t | truncation_flags (bool bids, bool asks) noexcept |
| The header flags of a delta whose bids and/or asks kept only the levels nearest the touch. | |
| constexpr std::string_view | to_string (ParamUpdateMsg::Origin o) noexcept |
| "strategy", "control", "ab", "config": the store's param_updates.origin. | |
| template<MessageLike M> | |
| FASTMM_FORCE_INLINE const M & | msg_cast (const EventHeader *h) noexcept |
| constexpr bool | value_stated (float v) noexcept |
| Result< void, std::string > | write_file_atomic (const std::string &path, std::string_view contents) |
Writes contents to path atomically: <path>.tmp, fsync, rename, fsync of the directory. | |
| Result< bool, std::string > | load_strategy_state (const std::string &path, std::string &out) |
| The strategy state file ([strategy] state_file, written by write_file_atomic): its bytes, true when it exists, false when there is no such file (a first start); an error when it cannot be read. | |
| Result< void, std::string > | write_strategy_state (const std::string &path, std::string_view bytes, std::uint32_t version) |
| The [strategy] state_file as the engine's state() bytes go into it: a 16-byte head ("FMSTATE1", the strategy's state_version as a little-endian u32, 4 zero bytes), then the bytes. | |
| Result< bool, std::string > | read_strategy_state (const std::string &path, std::string &out, std::uint32_t &version) |
| constexpr std::int64_t | utc_day_start (std::int64_t wall_ns) noexcept |
00:00 UTC of the day wall_ns falls in. | |
| bool | start_loss_period (KillState &s, std::int64_t period_start_ns) noexcept |
Starts the loss budget's period that holds wall_ns when the state counts an earlier one: realized and fees go back to zero, the latch stays. | |
| constexpr std::int64_t | opening_qty (std::int64_t q, Side side, std::int64_t ahead, std::int64_t qty) noexcept |
The part of an order of side for qty that position q does not absorb once ahead (our open orders on that side) has taken its share of the way to zero: what the order opens, raw. | |
| constexpr bool | nearer_zero (std::int64_t q, Side side, std::int64_t ahead, std::int64_t qty) noexcept |
Reduce-only mode: counted as opening_qty counts, the order leaves the position nearer zero than ahead left it. | |
| Notional | notional_share (Notional n, std::int64_t part, std::int64_t qty) noexcept |
part of an order of qty whose notional is n, rounded up (a cap check is not lenient). | |
| constexpr std::string_view | to_string (QuoteBlock b) noexcept |
| constexpr BaseFlows | base_flows_of (std::string_view s) noexcept |
| The value of [engine] base_flows ("off", "report", "adjust"; anything else is off). | |
| template<class F > | |
| constexpr void | for_each_changed_limit (const RiskLimits &a, const RiskLimits &b, F &&f) |
Calls f(key, before, after) for each [risk] key whose value differs between a and b, in the order of the configuration reference, with the values as [risk] writes them: Qty or Notional, an integer (stale_md_ms in milliseconds) or a bool. | |
| constexpr std::string_view | to_string (CapacityMode m) noexcept |
| template<class T > | |
| Secret< std::decay_t< T > > | secret (T &&v) |
| FASTMM_FORCE_INLINE bool | log_enabled (LogLevel lvl) noexcept |
| void | log_switch_run (const SimClock &clock, std::size_t index) noexcept |
Within a LogClockScope and a LogRunScope, the thread's lines from now on carry the time of clock and name run index (a pass of a sweep switches between its runs). | |
| constexpr bool | at_or_better (Side s, Price p, Price q) noexcept |
true if p is at least as good as q from the point of view of side s. | |
| constexpr bool | better (Side s, Price p, Price q) noexcept |
| InstrumentTable | load_instruments (const Config &cfg) |
| Builds the dense instrument table (src/core/instrument_loader.cpp). Throws ConfigError. | |
| PoolHomesPlan | pool_homes (const Config &cfg, const InstrumentTable &table) |
| [venues. | |
| HazardConfig | hazard_config (const Config &cfg, const InstrumentTable &table, std::span< const std::string > venue_names) |
[[risk.hazard]] with the members resolved in table (venue_names naming its venue ids). | |
| WindowsConfig | window_config (const Config &cfg, const InstrumentTable &table, std::span< const std::string > venue_names) |
[[windows]] with the zones looked up and the scopes resolved in table (venue_names naming its venue ids). | |
| FeeTable | fee_table (const Config &cfg, const InstrumentTable *table=nullptr, const std::vector< std::string > *venue_names=nullptr) |
| The fee rates of each instrument: its [[instruments]] maker_bps / taker_bps, else its venue's [venues. | |
| BalanceConfig | balance_config (const Config &cfg, const InstrumentTable *table=nullptr, const std::vector< std::string > *venue_names=nullptr) |
| [risk] check_balance and each instrument's [[instruments]] initial_margin, the instruments mapped as fee_table() maps them. | |
| PerpConfig | perp_config (const Config &cfg) |
| [accounting] mark, stale_mark_ms and stale_funding_ms. | |
| std::span< const KeySpec > | config_schema () noexcept |
| Result< std::string, std::string > | substitute_env (std::string_view in) |
| Returns the substituted string, or the name of the first missing variable. | |
| bool | has_env_reference (std::string_view s) noexcept |
| constexpr std::string_view | to_string (TransferState s) noexcept |
| constexpr const char * | to_string (SyncReason r) noexcept |
| constexpr const char * | to_string (SyncState s) noexcept |
| constexpr std::string_view | to_string (RecordType t) noexcept |
| constexpr std::string_view | to_string (RejectSource s) noexcept |
Variables | |
| constexpr std::array< HookInfo, static_cast< std::size_t >(Hook::Count)> | kHooks |
| constexpr std::size_t | kMaxParams = 128 |
| constexpr std::size_t | kMaxAbArms = 16 |
| constexpr std::size_t | kTransportKinds = static_cast<std::size_t>(TransportKind::Count) |
| constexpr std::int64_t | kFixedScale = 100'000'000 |
| 1e-8 | |
| constexpr int | kFixedDecimals = 8 |
| constexpr std::size_t | kMaxDecimalChars = 24 |
| sign + 11 integer digits + '.' + 8 fraction digits + NUL | |
| constexpr std::int64_t | kRatioPerBp = 10'000 |
| Ratio (below): 1.0 == kFixedScale raw, one basis point == kRatioPerBp raw. | |
| constexpr int | kBpsDecimals = 4 |
| constexpr std::size_t | kMaxInstruments = 256 |
| constexpr std::size_t | kKillVenueSlots = 31 |
| Kill reasons are kept per venue id for ids 0..kKillVenueSlots-1; higher ids share the last slot, as they share the last kill bit (RiskEngine::venue_bit). | |
| constexpr std::uint32_t | kNullHandle = std::numeric_limits<std::uint32_t>::max() |
| 32-bit pool index handle. | |
| constexpr std::size_t | kClOrdIdChars = 14 |
| "fm" + 12 lowercase hex digits (48 bits) = 14 chars. Fits Binance (36) and Bybit (36). | |
| constexpr std::uint8_t | kMessageVersion = 1 |
| constexpr std::string_view | kFundingIdPrefix = "funding:" |
| A funding id in the list of venue ids a restarted session's store already holds (store::Recovery::VenueResume::known_exec_ids, next to the trade ids): the prefix keeps the two id spaces apart. | |
| constexpr std::uint64_t | kTripKillPlannedStop = 1 |
| ControlCommand::TripKill's arg for a stop that was asked for (fastmm-live's --duration, a signal, fastmm-ctl stop): the engine pulls its quotes and cancels as for any trip, and logs it as a stop. | |
| constexpr std::uint64_t | kTripKillStoreFailure = 2 |
| ControlCommand::TripKill's arg when the store failed or dropped records and [storage] kill_on_failure is set: the engine trips with KillReason::StoreFailure. | |
| constexpr std::uint64_t | kLimitsCheckBalance = 1 |
| ControlCommand::SetLimits: a ControlMsg with the new limits after it. | |
| constexpr std::uint64_t | kLimitsCheckBalanceOn = 2 |
| check_balance = true | |
| constexpr std::uint64_t | kLimitsForced = 4 |
| The operator turned a limit off (fastmm-ctl limits --force); ControlUnderlyingMsg::flags too. | |
| constexpr std::uint32_t | kMaxBookLevelsPerMsg = 1024 |
| Largest fixed-size message; BookDelta is bounded separately by kMaxBookLevelsPerMsg. | |
| constexpr std::uint32_t | kMaxMsgBytes |
| constexpr std::size_t | kQuoteContextSize = 4 |
| The numbers a strategy publishes about its quotes on one side of an instrument (StrategyContext::quote_context): the fair value it priced them from, a quote's distance from it, a signal. | |
| constexpr float | kNoValue = std::numeric_limits<float>::quiet_NaN() |
| What an order or a quote level is worth when the strategy did not say ([capacity], core/capacity_price.hpp). | |
| constexpr std::size_t | kMaxOpenOrders = 4096 |
| constexpr std::size_t | kRecentlyTerminal = 4096 |
| constexpr std::size_t | kExecMemory = std::size_t{1} << 16 |
| Executions the OMS remembers by the venue's id, so that one it is given again (a replay of the venue's trade history reading back past rows it already had) is dropped as a duplicate. | |
| constexpr std::uint64_t | kMaxSeq = 0xFFFF'FFFFULL |
| Client order ids per session: the wire form is 48 bits, epoch(16) << 32 | seq(32). | |
| constexpr std::size_t | kMaxQuoteLevels = 8 |
| constexpr std::size_t | kQuoteNoteLen = 24 |
| QuoteNote::reason, NUL-terminated. | |
| constexpr std::size_t | kMaxStrategyMetrics = 32 |
| constexpr std::size_t | kStrategyMetricNameLen = 24 |
| constexpr std::size_t | kQuoteDiagAccounts = 8 |
| a pool's accounts (EngineConfig::pools) | |
| constexpr std::size_t | kLogRecordBytes = 256 |
| constexpr std::size_t | kLogMaxStrBytes = 64 |
| constexpr std::size_t | kLogRingSize = 8192 |
| records per thread (2 MiB) | |
| constexpr std::size_t | kLogMaxThreads = 64 |
| std::atomic< std::uint8_t > | g_log_level {static_cast<std::uint8_t>(LogLevel::Info)} |
| Global level (runtime); FASTMM_MIN_LOG_LEVEL is the compile-time floor. | |
| constexpr std::size_t | kMaxVenuesConfig = 8 |
| == kMaxVenues (transport.hpp) | |
| constexpr int | kMaxMdCopies = 8 |
| The most redundant market-data connections a venue opens ([venues.*] md_copies). | |
| constexpr int | kMinFillAuditIntervalS = 10 |
| The shortest [venues.<name>] fill_audit_interval_s: an audit reads every subscribed symbol. | |
| constexpr KeySpec | kConfigSchema [] |
| constexpr std::uint8_t | kRecordVersion = 1 |
| using fastmm::ParamMap = typedef std::map<std::string, std::string> |
| using fastmm::StrategyModule = typedef void (*)(StrategyRegistry&) |
A strategy library's registration function.
| using fastmm::Price = typedef Fixed<struct PriceTag> |
| using fastmm::Qty = typedef Fixed<struct QtyTag> |
| using fastmm::Notional = typedef Fixed<struct NotionalTag> |
| using fastmm::Ratio = typedef Fixed<RatioTag> |
A dimensionless factor: 1.0 == 1e8 raw, 1 bp == 10'000 raw, so 0.0001 bp is the smallest step.
| using fastmm::Symbol = typedef FixedString<20> |
| using fastmm::InstrumentId = typedef StrongId<struct InstrumentTag, std::uint32_t> |
Dense index into the engine's instrument table.
All per-instrument state is an array indexed by this.
| using fastmm::VenueId = typedef StrongId<struct VenueTag, std::uint8_t> |
| using fastmm::ClientOrderId = typedef StrongId<struct ClientOrderTag, std::uint64_t, 0> |
48-bit: session_epoch(16) << 32 | seq(32). 0 is never issued.
| using fastmm::VenueOrderId = typedef FixedString<40> |
| using fastmm::TimerId = typedef StrongId<struct TimerTag, std::uint32_t> |
| using fastmm::ExecId = typedef FixedString<40> |
| using fastmm::BookSnapshotMsg = typedef BookDeltaMsg |
same layout; hdr.type == BookSnapshot, kSnapshot set
| using fastmm::OwnLevelsMsg = typedef BookDeltaMsg |
EventType::OwnLevels, the same layout: each level is our resting quantity at that price as the feed shows it from now on, zero for none.
The update ids are unused.
| using fastmm::LogRing = typedef SpscRing<LogRecord, kLogRingSize> |
|
strong |
How a StrategyBase keeps its parameters.
Shared: one set for every instrument, and an update naming an instrument is refused by its publisher. PerInstrument: a set per instrument as well, which params(id) reads. An update naming an instrument ([strategy.overrides], fastmm-ctl param --instrument, an [ab] test that splits the instruments) sets that instrument's own values; one without an instrument changes the shared set and every instrument's values that are not its own (strategies/param_overrides.hpp).
| Enumerator | |
|---|---|
| Shared | |
| PerInstrument | |
|
strong |
|
strong |
|
strong |
| Enumerator | |
|---|---|
| Int | |
| Double | |
| Bool | |
| Decimal | Price, Qty, Notional. |
| Bps | Ratio configured in basis points. |
| Millis | Duration configured in milliseconds. |
|
strong |
|
strong |
|
strong |
|
strong |
Internal: the factories register_strategy adds.
FastMM's tests use it; a strategy that should not run live is simply not registered by that project's live app. The set is a template argument so that the factories it leaves out are never referenced, at any optimisation level.
| Enumerator | |
|---|---|
| None | |
| Sim | |
| Replay | |
| Live | |
| All | |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
Ordered exactly like RiskEngine::check_new evaluates them (5.7), followed by OMS / transport / venue reasons.
| Enumerator | |
|---|---|
| None | |
| KillSwitch | |
| VenueKilled | |
| InstrumentDisabled | |
| InvalidTick | |
| InvalidLot | |
| BelowMinNotional | |
| StaleMarketData | |
| PriceCollar | |
| FatFinger | |
| MaxOrderQty | |
| MaxOrderNotional | |
| MaxPosition | |
| MaxOpenOrders | |
| SelfTradePrevention | |
| RateLimit | |
| MaxLoss | |
| MaxGrossNotional | portfolio |position| at the last marks, over every instrument |
| MaxNetNotional | |
| FxRateUnknown | [accounting]: the rate of the order's settlement currency is unknown or stale, and the order would add to its exposure while max_loss or an exposure cap is set. |
| FeedLag | [risk] max_feed_lag_ms: the venue's market data is late (core/venue_health.hpp) and the order could rest there without reducing the position. |
| MaxUnderlyingNet | [risk.underlying. <BASE>] max_net: the net position in the order's underlying, in base units over every instrument, with the open orders on the order's side and the order itself, would move further past the limit. |
| UnderlyingMarkUnknown | The underlying cannot be measured: an inverse contract in it has a position or open orders (or is the order's instrument) and no current mark. |
| BalanceShort | The account's balance on the venue, as the venue last reported it less what the engine's own orders and fills took since (core/balance_book.hpp), does not cover the order: a spot sell above the free base asset, a spot buy whose notional plus taker fee is above the free quote asset, a derivative whose initial margin is above the available margin ([risk] check_balance). |
| ReduceOnly | Reduce-only mode (fastmm-ctl reduce-only, [risk] reduce_only) holds the order's instrument, and the order, with the open orders on its side, would leave the position no nearer zero. |
| PricedOut | [capacity]: the order is worth less than the price of the order slot it takes now (its account's window, the day's budget; core/capacity_price.hpp). |
| PoolExhausted | OMS / transport. |
| UnknownOrder | |
| InvalidState | |
| DuplicateId | |
| TransportFull | |
| NotReconciled | |
| InvalidTag | a direct order used a user_tag in the QuoteManager's range |
| OrderTableFull | The connector's table of the orders it has sent is full: it could not record this one (whose fills, amends and replies it would then not map back), so it did not send it. |
| InvalidAccount | NewOrderRequest::account names a venue that is neither the instrument's nor a member of its pool (core/account_pool.hpp); refused locally. |
| HomeUnavailable | [venues. <primary>.pool] placement = "home": the order goes to the instrument's home, whose order link is down or whose kill switch is engaged (core/pool_homes.hpp; spill = "flat" re-homes a flat instrument instead). |
| GatewayRateLimit | fastmm-gateway's account guards ([gateway]), refused before the order reached the connector the venue's order rate, shared by every attached strategy |
| GatewayOpenNotional | the notional working at the venue, over every attached strategy |
| GatewayNotOwner | the instrument belongs to another attachment (or none) |
| GatewayAccountKilled | [gateway] max_loss tripped the account's kill switch |
| GatewayGrossNotional | the account's |position| at the marks, over every instrument |
| GatewayNetNotional | the account's signed position at the marks |
| GatewayFxRateUnknown | [accounting]: the order's currency has no current rate |
| GatewayUnderlyingNet | [gateway.underlying.<BASE>] max_net, over every strategy and venue |
| GatewayUnderlyingMarkUnknown | an inverse contract of the underlying has no current mark |
| GatewaySelfTrade | it would cross another attached strategy's resting order |
| GatewayBalanceShort | the account's balance, less every attached strategy's orders |
| VenueReject | Venue-originated. |
| PostOnlyWouldCross | |
| InsufficientBalance | |
| VenueRateLimit | |
| VenueUnknownOrder | |
|
strong |
Message discriminator carried in EventHeader::type.
BookDelta is 1 so the dispatch switch's most likely case is the first compare.
| Enumerator | |
|---|---|
| Padding | ring wrap filler, never dispatched |
| BookDelta | |
| BookSnapshot | |
| BookTicker | |
| Trade | |
| OrderAck | |
| OrderReject | |
| OrderCancelAck | |
| OrderCancelReject | |
| OrderFill | |
| OrderExpired | |
| PositionUpdate | |
| Timer | |
| Control | |
| ConnectionState | |
| Reconcile | |
| LatencySample | |
| OutNewOrder | |
| OutCancel | |
| OutReplace | |
| OrderAddL3 | |
| OrderExecL3 | |
| OrderCancelL3 | |
| OrderReplaceL3 | |
| OptionTicker | mark / implied vols / greeks of one option (OptionTickerMsg) |
| EngineTime | journal only: the engine clock at start / finish / a delta overflow |
| ParamUpdate | new strategy parameter values (ParamUpdateMsg) |
| Funding | a perpetual funding payment booked by the venue (FundingMsg) |
| Balance | the account's holding of one asset on one venue (BalanceMsg) |
| PerpState | mark, index and funding of one derivative (PerpStateMsg) |
| StrategyState | journal only: a checkpoint or a restored state (StrategyStateMsg) |
| AccountFlow | money in or out of an account other than by trades (AccountFlowMsg) |
| OwnLevels | Our resting quantity at the prices of one instrument's book as a simulated venue's feed shows it ([backtest] own_orders_in_feed; OwnLevelsMsg): the engine's book is the recorded one with it added. |
| InstrumentRules | A venue's trading rules or trading status of one instrument changed while the session ran (InstrumentRulesMsg): tick, lot, the order limits, trading or not. |
| Count | |
|
strong |
Whether a venue takes orders on an instrument (Instrument::status, InstrumentRulesMsg).
Anything but Trading: the engine sends the instrument nothing, not even a cancel, until it trades again.
| Enumerator | |
|---|---|
| Trading | |
| Halted | a break, a halt, an auction, before or after the session |
| Closed | the venue lists it no longer, or has closed it for the day |
|
strong |
|
strong |
|
strong |
|
strong |
| Enumerator | |
|---|---|
| Stop | |
| PullQuotes | |
| ResumeQuotes | |
| TripKill | |
| ResetKill | |
| Reload | |
| FlushStats | |
| RecalibrateTsc | |
| TripVenueKill | A venue connector gave up on one venue (arg: KillReason, hdr.venue: the venue): the engine trips that venue's kill bit only. Sent through the venue's order ring, so it is journaled and replays like any other engine input. |
| Flatten | Operator flatten (arg: the slippage allowance in basis points, 0 takes [engine] flatten_slippage_bps; hdr.instrument: one instrument, invalid for every one): the engine stops quoting in that scope, cancels its orders and sends reduce-only IOC slices through the touch until the position is flat (core/engine.hpp). |
| SetLimits | New risk limits for RiskEngine::set_limits. The message is a ControlLimitsMsg: a ControlMsg with a RiskLimits payload (core/messages.hpp). |
| Reconcile | Engine -> venue, on the outbound ring (hdr.venue: the venue): the engine and the venue disagree about an order (a cancel rejected more than three times), so the connector runs the reconciliation it runs after a reconnect. The engine ignores it as an input. |
| SetUnderlyingLimit | A new [risk.underlying. <BASE>] max_net for RiskEngine::set_underlying_limit. The message is a ControlUnderlyingMsg: the underlying's index in the session's plan, and the limit in |
| TakeOver | A warm standby took the instance lock (fastmm-live --standby): arg is the PnL carried from earlier sessions (Notional raw, two's complement), read from the kill file once the session before it had written it last, and the strategy restores the state staged with Engine::stage_strategy_state (none in a replay). |
| Transfer | A pool treasury's transfer (core/treasury.hpp): planned, sent, done, failed or timed out. The message is a ControlTransferMsg; the engine counts it and changes nothing, so the journal holds every transfer next to the balances it moved. |
| ResetLossBudget | A new [risk] max_loss period began (max_loss_period = "utc_day"): the engine measures net PnL from zero again, unrealized PnL included; a tripped kill switch stays tripped. |
| ReduceOnly | Reduce-only mode (arg: 1 on, 0 off; hdr.instrument: one instrument, else hdr.venue: one venue's instruments, else the whole session): new orders and replaces that would take a position further from zero are refused (RejectReason::ReduceOnly), and turning it on cancels the working orders on each instrument's adding side. An off without a scope clears every scope. |
| PoolHome | An instrument's home in its account pool (core/pool_homes.hpp): hdr.instrument, arg pool_home_arg(to, source, from). From the planner and the operator; the engine journals its own (kSynthetic), which a replay does not take as input. |
| PoolSweep | A pool's sweep (core/transfer_lane.hpp): hdr.venue the pool's primary, arg kSweepOff, kSweepOn, kSweepPause or kSweepNow (hdr.instrument: the instrument whose pieces go home at the next look). From the operator (fastmm-ctl pool sweep). |
| BaseFlow | A change of a spot instrument's base asset on its accounts that no fill and no transfer of the engine's made ([engine] base_flows): a token dividend, an airdrop, a venue's adjustment, a deposit. The message is a ControlBaseFlowMsg, a record the engine journals (kSynthetic): a replay finds the flow again from the balances. |
|
strong |
Why a kill switch (global or one venue's) was tripped.
The engine records the first reason per flag; fastmm-live decides from it whether to exit ([engine] on_kill) and shows it in the status.
| Enumerator | |
|---|---|
| None | |
| Requested | ControlCommand::TripKill: shutdown, operator. |
| MaxLoss | [risk] max_loss |
| TransportFull | the outbound ring to a venue was full |
| JournalOverflow | the journal ring was full |
| AllVenuesKilled | every venue with instruments has its own kill bit set |
| VenueFatal | venue error map: bad key, signature, permission, failed auth |
| VenueHardStop | venue error map: REST stopped (IP ban) |
| OrderRingOverflow | fastmm-live: a venue's order-event ring overflowed |
| StrategyError | a strategy hook reported an error (Python hot hooks) |
| FeedLost | a multicast feed cannot rebuild its books (nasdaq_itch) |
| OrderIdsExhausted | the session's 32-bit client order id sequence is used up |
| DeadMansSwitchLost | the venue-side countdown could not be refreshed within its window |
| GatewayMaxLoss | fastmm-gateway: the account's [gateway] max_loss, over every strategy |
| GatewayOperator | fastmm-gateway: an operator's |
| StoreFailure | fastmm-live: the store failed or dropped records ([storage] kill_on_failure) |
|
strong |
How far an operator flatten (ControlCommand::Flatten) got.
The engine publishes it with its live stats and fastmm-live copies it into the status file and the control socket's status.
|
strong |
|
strong |
What /proc/cpuinfo says about the TSC (cached after the first call): Invariant constant_tsc + nonstop_tsc: wall time and intervals from the TSC.
Constant constant_tsc only (KVM guests such as Vultr's): fixed rate, but not promised to count through deep C-states. Wall time from clock_gettime; the TSC still times intervals, which are far shorter than any drift that could matter. None neither: clock_gettime for everything.
| Enumerator | |
|---|---|
| None | |
| Constant | |
| Invariant | |
|
strong |
Outcome of TscClock::refresh() / reanchor().
|
strong |
One side of a public trade as the venue names it, on venues that publish who traded (Hyperliquid: wallet addresses; Lighter: account indexes).
Copied as sent; FastMM gives it no meaning.
|
strong |
|
strong |
|
strong |
|
strong |
The first obstacle between what the strategy asked for on a side and orders working there.
The engine checks them in this order, except that a venue kill comes before the pull it causes.
| Enumerator | |
|---|---|
| Quoting | the working orders cover what the strategy asked for |
| NotWanted | the strategy asks for nothing on this side (its note may say why) |
| QuotingOff | the session does not quote: pulled, killed, reconciling, parameters stale |
| Pulled | this instrument or its venue is pulled (fastmm-ctl pull --instrument/--venue) |
| VenueKilled | its venue's kill switch |
| FeedLag | the venue's feed-lag gate holds ([risk] max_feed_lag_ms) |
| Backoff | a venue refusal put the side in its reject backoff |
| Starved | waiting for an order token ([risk] orders_per_sec) |
| Refused | the last order on the side was refused ( |
| Pending | orders on their way: sent, not yet working, or a requote waiting its turn |
| FillCluster | the fill-cluster guard holds the side ([risk] fill_cluster_names) |
| Hazard | a hazard group holds the side ([[risk.hazard]]) |
| Window | an open [[windows]] window with action = "pull" covers the instrument |
| NotTrading | the venue does not trade the instrument now (Instrument::status) |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
What the treasury reports through TreasuryPort::record (journal) and its counters.
|
strong |
|
strong |
|
strong |
|
strong |
What refused an order (RejectRecord::source): the limit behind a rate-limit refusal, or the side that refused it otherwise.
Rate limits stay apart by where they are counted: the engine's [risk] bucket, the engine's view of an account's order windows (ctx.order_budget, pool routing), the connector's own limiter (never sent), and the venue's answer.
| Enumerator | |
|---|---|
| Risk | a pre-trade check other than the rate limits ( |
| RiskBucket | the [risk] orders_per_sec token bucket, shared by every account |
| AccountPaused | the account's connector is paused (429 Retry-After, 418) |
| AccountOrders10s | the account's order window at the connector's cap |
| AccountOrders1m | |
| AccountOrders1d | |
| VenueLocal | the connector's own limiter refused it before sending (OrderReject text) |
| Venue | the venue refused it (venue_code, text) |
| Capacity | worth less than the order slot it takes ([capacity], RejectReason::PricedOut) |
|
constexprnoexcept |
The layout of the bytes state() returns: static constexpr std::uint32_t state_version, or a state_version() member function; 0 when the strategy declares none.
The state file and every checkpoint record it, and a backtest, a replay or a live session refuses bytes of another version.
|
constexprnoexcept |
|
constexprnoexcept |
True when the engine calls S's hook h (the engine dispatches on this at compile time).
|
constexprnoexcept |
Compile-time check of every hook of S; always returns true (failures are static_asserts), so it can be written as static_assert(fastmm::verify_strategy<MyMM>());.
The local names make clang's "due to requirement '...'" line readable.
|
constexprnoexcept |
The implemented hooks as words in table order ("start book fill timer connection quoting").
|
constexprnoexcept |
|
constexprnoexcept |
| std::optional< std::int64_t > fastmm::parse_utc_time | ( | std::string_view | s | ) |
"YYYY-MM-DD", "YYYY-MM-DD HH:MM" or "YYYY-MM-DD HH:MM:SS", with a T for the space and a trailing Z allowed, UTC, as ns since the epoch.
| std::string fastmm::format_utc_time | ( | std::int64_t | ns | ) |
"YYYY-MM-DD HH:MM:SS UTC".
|
constexprnoexcept |
Size-weighted microprice of the touch, truncated toward zero.
With no size on either side it is the plain mid.
(ask - bid) / mid; zero when the mid is not positive. 1 bp == Ratio raw 10'000.
A price dist away from ref on the passive side: Buy -> ref - dist, Sell -> ref + dist.
|
constexprnoexcept |
Whether a fill of qty on side keeps the position within +-limit: Buy needs position + qty <= limit, Sell needs position - qty >= -limit.
A zero limit means no cap. A side that reduces the position is allowed as long as the result stays within the limit.
|
inlinenoexcept |
Post-only quotes must not cross the market.
Inventory skew can push the unwinding side through the touch (a skewed bid above the best ask); the venue would reject it and that side would stop quoting. Shift the whole ladder back so level 0 sits one tick inside the touch, keeping the spacing between levels; bid levels pushed to a non-positive price are removed. An empty opposite side (price 0) imposes no limit.
|
inlinenoexcept |
Cuts one side of a ladder to room in total, keeping the levels closest to the mid: each level is rounded down to the lot, and one left under the lot, the instrument's min_qty or its min_notional ends the side (the venue would refuse it).
|
noexcept |
Cuts both sides of a ladder to what the account's balance on the instrument's venue covers (StrategyContext::balance_room, priced at the side's dearest level).
What the side's resting orders hold counts as room: the ladder replaces them. A side whose balance the venue has not reported is left as it is. Before any venue reports balances it is one test.
|
noexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
inline |
| std::unique_ptr< IEngineRunner > fastmm::sim_factory | ( | TransportKind | kind, |
| RunnerDeps & | deps | ||
| ) |
Declared template <class S>, not template <StrategyLike S>: GCC and Clang mangle constrained templates differently.
The definitions check StrategyLike<S> with a static_assert.
| std::unique_ptr< IEngineRunner > fastmm::replay_factory | ( | TransportKind | kind, |
| RunnerDeps & | deps | ||
| ) |
| std::unique_ptr< IEngineRunner > fastmm::live_factory | ( | TransportKind | kind, |
| RunnerDeps & | deps | ||
| ) |
|
constexprnoexcept |
|
constexprnoexcept |
| void fastmm::register_strategy | ( | StrategyRegistry & | r | ) |
Adds the Sim, Replay and Live factories of S (or those in Enabled).
Registering the same strategy again does nothing; throws StrategyConflict when another strategy already uses the name.
if constexpr: a discarded branch is not instantiated, so it does not reference its factory.
|
constexprnoexcept |
value * ratio in the value's domain, through Int128 with one truncation toward zero: mid * 5_bps, qty * ratio(filled, total).
|
constexprnoexcept |
|
constexprnoexcept |
num / den as a Ratio, truncated toward zero; zero when den is zero.
The quotient must fit +-92,233,720,368.
price * qty with a 128-bit intermediate, truncated toward zero to 1e-8.
|
constexprnoexcept |
Generic scaled multiply for fixed*fixed in one domain (e.g. qty * multiplier).
notional / qty -> price (used for average cost). Truncates toward zero.
|
constexprnoexcept |
value * bps / 10000 in one domain.
|
constexprnoexcept |
Floor division for possibly-negative numerators (prices are >= 0, but be safe).
Round to the tick grid in the passive direction: bids down, asks up. tick > 0.
Quantities always round down (never send more than intended).
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
Checked arithmetic: nullopt instead of a wrapped int64. The operators stay unchecked; these are for the places that combine a value from outside the engine with a configured one.
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
noexcept |
Writes the kClOrdIdChars characters of the wire form to dst (no terminator) with two 8-byte stores.
"fm" + the last 4 characters of hi (its upper 4 bytes); bytes 6 and 7 are then overwritten by lo.
|
inlinenoexcept |
|
inlinenoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
noexcept |
Serialising read (rdtscp) is what latency hops want: it waits for prior loads to retire.
|
noexcept |
|
noexcept |
CLOCK_REALTIME via vDSO (~20 ns). Implemented in src/core/time.cpp.
|
noexcept |
|
noexcept |
|
inlinenoexcept |
|
noexcept |
A TSC cycle interval in ns; 0 without a rate.
|
noexcept |
|
noexcept |
Startup calibration (spins for window): TscCalibrator::start(), so the rate is measured against CLOCK_MONOTONIC_RAW and a host wall-clock step inside the window cannot distort it; the anchor follows CLOCK_REALTIME.
src/core/time.cpp
|
noexcept |
|
constexprnoexcept |
|
noexcept |
TSC reading -> wall ns under c.
Signed, so readings taken before the anchor (e.g. a network-thread receive stamp converted after a re-anchor) map to earlier times.
|
constexprnoexcept |
|
constexprnoexcept |
For fixed-size messages len defaults to sizeof(M); BookDeltaMsg passes size_for().
|
constexprnoexcept |
The header flags of a delta whose bids and/or asks kept only the levels nearest the touch.
|
constexprnoexcept |
"strategy", "control", "ab", "config": the store's param_updates.origin.
|
noexcept |
|
constexprnoexcept |
| Result< void, std::string > fastmm::write_file_atomic | ( | const std::string & | path, |
| std::string_view | contents | ||
| ) |
Writes contents to path atomically: <path>.tmp, fsync, rename, fsync of the directory.
| Result< bool, std::string > fastmm::load_strategy_state | ( | const std::string & | path, |
| std::string & | out | ||
| ) |
The strategy state file ([strategy] state_file, written by write_file_atomic): its bytes, true when it exists, false when there is no such file (a first start); an error when it cannot be read.
The bytes are the strategy's own: whether they are its is for restore() to say.
| Result< void, std::string > fastmm::write_strategy_state | ( | const std::string & | path, |
| std::string_view | bytes, | ||
| std::uint32_t | version | ||
| ) |
The [strategy] state_file as the engine's state() bytes go into it: a 16-byte head ("FMSTATE1", the strategy's state_version as a little-endian u32, 4 zero bytes), then the bytes.
A file without the head, from before it was written, is read whole as version 0.
| Result< bool, std::string > fastmm::read_strategy_state | ( | const std::string & | path, |
| std::string & | out, | ||
| std::uint32_t & | version | ||
| ) |
|
constexprnoexcept |
00:00 UTC of the day wall_ns falls in.
|
inlinenoexcept |
Starts the loss budget's period that holds wall_ns when the state counts an earlier one: realized and fees go back to zero, the latch stays.
False: already that period.
|
constexprnoexcept |
The part of an order of side for qty that position q does not absorb once ahead (our open orders on that side) has taken its share of the way to zero: what the order opens, raw.
Zero: the order only reduces the position. All raw Qty.
|
constexprnoexcept |
Reduce-only mode: counted as opening_qty counts, the order leaves the position nearer zero than ahead left it.
It only closes, or it goes through zero by less than it closes (long 10, a sell of 15 passes and one of 20 does not). Nothing passes on a flat position. All raw Qty.
part of an order of qty whose notional is n, rounded up (a cap check is not lenient).
|
constexprnoexcept |
|
constexprnoexcept |
The value of [engine] base_flows ("off", "report", "adjust"; anything else is off).
|
constexpr |
Calls f(key, before, after) for each [risk] key whose value differs between a and b, in the order of the configuration reference, with the values as [risk] writes them: Qty or Notional, an integer (stale_md_ms in milliseconds) or a bool.
|
constexprnoexcept |
| Secret< std::decay_t< T > > fastmm::secret | ( | T && | v | ) |
|
noexcept |
|
inlinenoexcept |
Within a LogClockScope and a LogRunScope, the thread's lines from now on carry the time of clock and name run index (a pass of a sweep switches between its runs).
true if p is at least as good as q from the point of view of side s.
| InstrumentTable fastmm::load_instruments | ( | const Config & | cfg | ) |
Builds the dense instrument table (src/core/instrument_loader.cpp). Throws ConfigError.
| PoolHomesPlan fastmm::pool_homes | ( | const Config & | cfg, |
| const InstrumentTable & | table | ||
| ) |
[venues.
<primary>.pool] of every pool, and the pinned homes (homes) by the id each instrument has in table.
| HazardConfig fastmm::hazard_config | ( | const Config & | cfg, |
| const InstrumentTable & | table, | ||
| std::span< const std::string > | venue_names | ||
| ) |
[[risk.hazard]] with the members resolved in table (venue_names naming its venue ids).
Throws ConfigError for a member that names no instrument or one that two groups share.
| WindowsConfig fastmm::window_config | ( | const Config & | cfg, |
| const InstrumentTable & | table, | ||
| std::span< const std::string > | venue_names | ||
| ) |
[[windows]] with the zones looked up and the scopes resolved in table (venue_names naming its venue ids).
Throws ConfigError for a scope entry that names no instrument.
| FeeTable fastmm::fee_table | ( | const Config & | cfg, |
| const InstrumentTable * | table = nullptr, |
||
| const std::vector< std::string > * | venue_names = nullptr |
||
| ) |
The fee rates of each instrument: its [[instruments]] maker_bps / taker_bps, else its venue's [venues.
<x>.fees]; the first venue's are the default for ids outside the configuration. Without table, instrument k of the configuration is InstrumentId k (load_instruments); with it, each instrument of table takes the entry with its venue and symbol, venue_names naming its venue ids (a table from fastmm-gateway, whose order is not the configuration's).
| BalanceConfig fastmm::balance_config | ( | const Config & | cfg, |
| const InstrumentTable * | table = nullptr, |
||
| const std::vector< std::string > * | venue_names = nullptr |
||
| ) |
[risk] check_balance and each instrument's [[instruments]] initial_margin, the instruments mapped as fee_table() maps them.
| PerpConfig fastmm::perp_config | ( | const Config & | cfg | ) |
[accounting] mark, stale_mark_ms and stale_funding_ms.
|
inlinenoexcept |
|
inline |
Returns the substituted string, or the name of the first missing variable.
|
inlinenoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
1e-8
|
inlineconstexpr |
|
inlineconstexpr |
sign + 11 integer digits + '.' + 8 fraction digits + NUL
|
inlineconstexpr |
Ratio (below): 1.0 == kFixedScale raw, one basis point == kRatioPerBp raw.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Kill reasons are kept per venue id for ids 0..kKillVenueSlots-1; higher ids share the last slot, as they share the last kill bit (RiskEngine::venue_bit).
|
inlineconstexpr |
32-bit pool index handle.
Cheaper than a pointer, stable across relocation of the pool (journals/snapshots), and lets a slot be recycled with a generation check by the owner.
|
inlineconstexpr |
"fm" + 12 lowercase hex digits (48 bits) = 14 chars. Fits Binance (36) and Bybit (36).
|
inlineconstexpr |
|
inlineconstexpr |
A funding id in the list of venue ids a restarted session's store already holds (store::Recovery::VenueResume::known_exec_ids, next to the trade ids): the prefix keeps the two id spaces apart.
|
inlineconstexpr |
ControlCommand::TripKill's arg for a stop that was asked for (fastmm-live's --duration, a signal, fastmm-ctl stop): the engine pulls its quotes and cancels as for any trip, and logs it as a stop.
|
inlineconstexpr |
ControlCommand::TripKill's arg when the store failed or dropped records and [storage] kill_on_failure is set: the engine trips with KillReason::StoreFailure.
|
inlineconstexpr |
ControlCommand::SetLimits: a ControlMsg with the new limits after it.
The prefix is a ControlMsg (same type, same offsets), so the engine's dispatch reads command from either and only this command looks past it; hdr.len tells the rings, the journal and a replay how long the record is. ControlLimitsMsg::arg. A record without kLimitsCheckBalance leaves [risk] check_balance alone (journals from before the flag). kLimitsCheckBalanceOn is the value
|
inlineconstexpr |
check_balance = true
|
inlineconstexpr |
The operator turned a limit off (fastmm-ctl limits --force); ControlUnderlyingMsg::flags too.
|
inlineconstexpr |
Largest fixed-size message; BookDelta is bounded separately by kMaxBookLevelsPerMsg.
|
inlineconstexpr |
|
inlineconstexpr |
The numbers a strategy publishes about its quotes on one side of an instrument (StrategyContext::quote_context): the fair value it priced them from, a quote's distance from it, a signal.
NaN where nothing was published. The engine copies the side's context into each order it sends or moves on that side, so the record of a fill can say what the strategy knew when it placed the order and what it knew when the fill arrived (FillRecord).
|
inlineconstexpr |
What an order or a quote level is worth when the strategy did not say ([capacity], core/capacity_price.hpp).
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Executions the OMS remembers by the venue's id, so that one it is given again (a replay of the venue's trade history reading back past rows it already had) is dropped as a duplicate.
4096 was not enough: live, Binance spot replays re-sent executions 4,000 and more executions after the private stream had reported them, naming no order, and each was booked a second time into the position and the PnL. 64Ki executions is days of a busy market maker's fills and costs 1.6 MiB, allocated with the OMS.
|
inlineconstexpr |
Client order ids per session: the wire form is 48 bits, epoch(16) << 32 | seq(32).
|
inlineconstexpr |
|
inlineconstexpr |
QuoteNote::reason, NUL-terminated.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
a pool's accounts (EngineConfig::pools)
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
records per thread (2 MiB)
|
inlineconstexpr |
|
inline |
Global level (runtime); FASTMM_MIN_LOG_LEVEL is the compile-time floor.
|
inlineconstexpr |
== kMaxVenues (transport.hpp)
|
inlineconstexpr |
The most redundant market-data connections a venue opens ([venues.*] md_copies).
|
inlineconstexpr |
The shortest [venues.<name>] fill_audit_interval_s: an audit reads every subscribed symbol.
|
inlineconstexpr |
|
inlineconstexpr |