|
FastMM C++ API 0.6.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 | 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; 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 | ClockReadings |
| Clock readings used by TscCalibrator. More... | |
| class | Config |
| class | ConfigError |
| struct | ConfigLoadOptions |
| struct | ConnectionStateMsg |
| struct | ControlLimitsMsg |
| ControlCommand::SetLimits: a ControlMsg with the new limits after it. More... | |
| 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 |
| Free-form section used by the sim / backtest libraries: dotted keys -> stringified value. More... | |
| struct | Handle |
| class | HedgeExecutor |
| struct | HookInfo |
| struct | Instrument |
| 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 | 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... | |
| struct | LogDescriptor |
| class | Logger |
| Process-wide registry of per-thread rings + the sink thread. Implemented in log_sink.cpp. More... | |
| struct | LoggingSection |
| struct | LogRecord |
| 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 | 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 | PerpStateMsg |
| The venue's reference prices and funding of one derivative (EventType::PerpState), from its public market data. 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 |
| 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 | 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... | |
| class | SimClock |
| Deterministic clock for sim/backtest/replay. 1 cycle == 1 ns. More... | |
| struct | StatePosition |
| One instrument's position in a StrategyStateMsg's kPositionsPart: on the account (venue) whose Reconcile Position would set it. More... | |
| 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 |
| struct | TransferRequest |
| struct | TransferResult |
| 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 |
| 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 | LogRing = SpscRing< LogRecord, kLogRingSize > |
Enumerations | |
| 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 | 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 , PoolExhausted = 32 , UnknownOrder = 33 , InvalidState = 34 , DuplicateId = 35 , TransportFull = 36 , NotReconciled = 37 , InvalidTag = 38 , OrderTableFull = 39 , InvalidAccount = 40 , 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 , Count = 31 } |
| Message discriminator carried in EventHeader::type. 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 } |
| 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 } |
| 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 | 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 } |
| The first obstacle between what the strategy asked for on a side and orders working there. 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 | 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 } |
| 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 } |
| 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 , 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 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 (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. | |
| template<MessageLike M> | |
| FASTMM_FORCE_INLINE const M & | msg_cast (const EventHeader *h) 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. | |
| constexpr std::string_view | to_string (QuoteBlock b) noexcept |
| template<class T > | |
| Secret< std::decay_t< T > > | secret (T &&v) |
| FASTMM_FORCE_INLINE bool | log_enabled (LogLevel lvl) noexcept |
| 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. | |
| 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 | 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::uint32_t | kMaxBookLevelsPerMsg = 1024 |
| Largest fixed-size message; BookDelta is bounded separately by kMaxBookLevelsPerMsg. | |
| constexpr std::uint32_t | kMaxMsgBytes |
| constexpr std::size_t | kMaxOpenOrders = 4096 |
| constexpr std::size_t | kRecentlyTerminal = 4096 |
| constexpr std::size_t | kMaxSyntheticFills = 64 |
| Fills booked from a cumulative quantity and never named by an execution. | |
| 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 | 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::LogRing = typedef SpscRing<LogRecord, kLogRingSize> |
|
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 |
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). |
| 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. |
| 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: the strategy's state and the positions (StrategyStateMsg) |
| Count | |
|
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. |
|
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 |
|
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 |
|
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.
|
strong |
|
strong |
|
strong |
|
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.
|
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 |
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 |
|
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.
|
noexcept |
| 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.
|
constexprnoexcept |
| Secret< std::decay_t< T > > fastmm::secret | ( | T && | v | ) |
|
noexcept |
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.
| 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 |
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 |
Largest fixed-size message; BookDelta is bounded separately by kMaxBookLevelsPerMsg.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Fills booked from a cumulative quantity and never named by an execution.
One entry per order, so this is the number of orders that can be waiting for an execution-history replay at once; a private-stream outage covers a handful, and the oldest entry is dropped (and counted) past that.
|
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 shortest [venues.<name>] fill_audit_interval_s: an audit reads every subscribed symbol.
|
inlineconstexpr |
|
inlineconstexpr |