FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
fastmm Namespace Reference

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
 

Typedef Documentation

◆ ParamMap

using fastmm::ParamMap = typedef std::map<std::string, std::string>

◆ StrategyModule

using fastmm::StrategyModule = typedef void (*)(StrategyRegistry&)

A strategy library's registration function.

◆ Price

using fastmm::Price = typedef Fixed<struct PriceTag>

◆ Qty

using fastmm::Qty = typedef Fixed<struct QtyTag>

◆ Notional

using fastmm::Notional = typedef Fixed<struct NotionalTag>

◆ Ratio

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.

◆ Symbol

using fastmm::Symbol = typedef FixedString<20>

◆ InstrumentId

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.

◆ VenueId

using fastmm::VenueId = typedef StrongId<struct VenueTag, std::uint8_t>

◆ ClientOrderId

using fastmm::ClientOrderId = typedef StrongId<struct ClientOrderTag, std::uint64_t, 0>

48-bit: session_epoch(16) << 32 | seq(32). 0 is never issued.

◆ VenueOrderId

using fastmm::VenueOrderId = typedef FixedString<40>

◆ TimerId

using fastmm::TimerId = typedef StrongId<struct TimerTag, std::uint32_t>

◆ ExecId

using fastmm::ExecId = typedef FixedString<40>

◆ BookSnapshotMsg

same layout; hdr.type == BookSnapshot, kSnapshot set

◆ LogRing

using fastmm::LogRing = typedef SpscRing<LogRecord, kLogRingSize>

Enumeration Type Documentation

◆ Hook

enum class fastmm::Hook : std::uint8_t
strong
Enumerator
FASTMM_HOOK_ENUM 
FASTMM_STRATEGY_HOOKS 

◆ HookStatus

enum class fastmm::HookStatus : std::uint8_t
strong

Absent: no member with the hook's name.

Ok: the engine calls it. Mismatch: a member with the name exists but the call does not compile (a build error through verify_strategy).

Enumerator
Absent 
Ok 
Mismatch 

◆ ParamType

enum class fastmm::ParamType : std::uint8_t
strong
Enumerator
Int 
Double 
Bool 
Decimal 

Price, Qty, Notional.

Bps 

Ratio configured in basis points.

Millis 

Duration configured in milliseconds.

◆ TransportKind

enum class fastmm::TransportKind : std::uint8_t
strong
Enumerator
Sim 
Live 
Replay 
Count 

◆ AddResult

enum class fastmm::AddResult : std::uint8_t
strong
Enumerator
Added 

the factory is now registered for (name, kind)

AlreadyPresent 

the same schema and factory were registered before: nothing changed

Conflict 

name is registered with a different schema, or (name, kind) with another factory

Invalid 

empty name, null schema or factory, or an invalid kind

◆ Transports

enum class fastmm::Transports : std::uint8_t
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 

◆ InstrumentError

enum class fastmm::InstrumentError : std::uint8_t
strong
Enumerator
TableFull 
DuplicateSymbol 
InvalidTick 
InvalidLot 
EmptySymbol 

◆ Side

enum class fastmm::Side : std::uint8_t
strong
Enumerator
Buy 
Sell 

◆ OrderType

enum class fastmm::OrderType : std::uint8_t
strong
Enumerator
Limit 
Market 
PostOnly 

◆ TimeInForce

enum class fastmm::TimeInForce : std::uint8_t
strong
Enumerator
Gtc 
Ioc 
Fok 
Day 

◆ AssetClass

enum class fastmm::AssetClass : std::uint8_t
strong
Enumerator
Spot 
Perpetual 
Future 
Option 
Fx 
Equity 

◆ OptionType

enum class fastmm::OptionType : std::uint8_t
strong
Enumerator
None 
Call 
Put 

◆ OrderState

enum class fastmm::OrderState : std::uint8_t
strong
Enumerator
PendingNew 
Live 
PartiallyFilled 
PendingCancel 
PendingReplace 
Filled 
Canceled 
Rejected 
Expired 

◆ RejectReason

enum class fastmm::RejectReason : std::uint8_t
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 

◆ EventType

enum class fastmm::EventType : std::uint8_t
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 

◆ ConnState

enum class fastmm::ConnState : std::uint8_t
strong
Enumerator
Disconnected 
Connecting 
Live 
Stale 
Resyncing 
Dead 

◆ FeeAsset

enum class fastmm::FeeAsset : std::uint8_t
strong

The asset a fill's commission is charged in.

Binance spot charges a buy in the base asset (you receive less), a sell in the quote asset, and either in BNB when the discount is enabled.

Enumerator
Quote 
Base 
Other 

◆ Liquidity

enum class fastmm::Liquidity : std::uint8_t
strong
Enumerator
Unknown 
Maker 
Taker 

◆ ControlCommand

enum class fastmm::ControlCommand : std::uint8_t
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 arg.

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.

◆ KillReason

enum class fastmm::KillReason : std::uint8_t
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 kill on the gateway's control socket

◆ FlattenState

enum class fastmm::FlattenState : std::uint8_t
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.

Enumerator
Off 

none was asked for in this session

Working 

quoting is off in its scope and reduce-only slices are going out

Flat 

it finished: no position left in its scope

TimedOut 

[engine] flatten_timeout_ms elapsed with a position left; it gave up

Stopped 

the operator resumed quoting before it finished

◆ LogLevel

enum class fastmm::LogLevel : std::uint8_t
strong
Enumerator
Trace 
Debug 
Info 
Warn 
Error 
Off 

◆ TscKind

enum class fastmm::TscKind : std::uint8_t
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 

◆ TscRefresh

enum class fastmm::TscRefresh : std::uint8_t
strong

Outcome of TscClock::refresh() / reanchor().

Enumerator
None 

no new calibration published (the common case)

Adopted 

the clock had no TSC mapping yet: took the published one as is

Reanchored 

continuous: same time at the refresh point, new rate from there on

Stepped 

old mapping disagreed with the measurement by more than the threshold

Rejected 

the published calibration is unusable (no TSC); kept the current mapping

◆ OmsAction

enum class fastmm::OmsAction : std::uint8_t
strong
Enumerator
None 
Ignored 

message did not apply (duplicate ack, late cancel-reject, ...)

Duplicate 

duplicate exec_id

CancelUnknown 

ack/fill for an id we do not know: engine must cancel it

LateFill 

fill for a recently terminal order: position, and the terminal record's cum_qty and state (changed = true when they moved)

UnknownFill 

fill for a completely unknown id: update position, alert

ReconcileNeeded 

too many cancel rejects

◆ OrderClass

enum class fastmm::OrderClass : std::uint8_t
strong
Enumerator
Open 
RecentlyTerminal 
Unknown 

◆ QuoteActionKind

enum class fastmm::QuoteActionKind : std::uint8_t
strong
Enumerator
New 
Cancel 
Replace 

◆ QuoteBlock

enum class fastmm::QuoteBlock : std::uint8_t
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 (reason) within the last 2 s

Pending 

orders on their way: sent, not yet working, or a requote waiting its turn

◆ LogArgType

enum class fastmm::LogArgType : std::uint8_t
strong
Enumerator
Int 
Uint 
Double 
Bool 
Char 
PriceFx 
QtyFx 
NotionalFx 
Str 
Secret 

◆ KeyType

enum class fastmm::KeyType : unsigned char
strong
Enumerator
String 
Int 
Float 
Bool 
IntArray 
StringArray 
Table 
Any 

◆ TransferState

enum class fastmm::TransferState : std::uint8_t
strong
Enumerator
Pending 

the venue took it and has not finished it

Done 

the amount has moved

Failed 

the venue refused it or gave up: nothing moved

NotFound 

the venue has no transfer under this id (status only)

Unknown 

no usable answer (a transport error, a timeout, a 5xx): it may have happened

◆ SyncState

enum class fastmm::SyncState : std::uint8_t
strong
Enumerator
Idle 
Buffering 
Synced 
Resync 

◆ SyncReason

enum class fastmm::SyncReason : std::uint8_t
strong
Enumerator
None 
SequenceGap 
BufferOverflow 
SnapshotTooOld 

buffered deltas start after the snapshot; need a newer one

Explicit 
SnapshotMarker 

venue signalled a reset (Bybit u == 1)

ChecksumMismatch 

the venue's book checksum disagrees with ours (OKX)

◆ RecordType

enum class fastmm::RecordType : std::uint8_t
strong

Never 0: the ring reserves type 0 for padding.

Enumerator
Fill 
Order 
Position 
Kill 
Funding 
Replayed 
Param 
Reject 

◆ RejectSource

enum class fastmm::RejectSource : std::uint8_t
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 (reason says which)

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)

Function Documentation

◆ hook_status()

template<class S , class Ctx , class Book >
constexpr HookStatus fastmm::hook_status ( Hook  h)
constexprnoexcept

◆ implements_hook()

template<class S , class Ctx , class Book >
constexpr bool fastmm::implements_hook ( Hook  h)
constexprnoexcept

True when the engine calls S's hook h (the engine dispatches on this at compile time).

◆ verify_strategy()

template<class S , class Ctx = detail::hooks::StandInContext, class Book = detail::hooks::StandInBook>
constexpr bool fastmm::verify_strategy ( )
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.

◆ implemented_hooks()

template<class S , class Ctx , class Book >
constexpr std::string_view fastmm::implemented_hooks ( )
constexprnoexcept

The implemented hooks as words in table order ("start book fill timer connection quoting").

◆ to_string() [1/23]

constexpr std::string_view fastmm::to_string ( ParamType  t)
constexprnoexcept

◆ mid()

constexpr Price fastmm::mid ( Price  bid,
Price  ask 
)
constexprnoexcept

◆ microprice()

constexpr Price fastmm::microprice ( Level  bid,
Level  ask 
)
constexprnoexcept

Size-weighted microprice of the touch, truncated toward zero.

With no size on either side it is the plain mid.

◆ spread_ratio()

constexpr Ratio fastmm::spread_ratio ( Price  bid,
Price  ask 
)
constexprnoexcept

(ask - bid) / mid; zero when the mid is not positive. 1 bp == Ratio raw 10'000.

◆ away_from()

constexpr Price fastmm::away_from ( Price  ref,
Side  side,
Price  dist 
)
constexprnoexcept

A price dist away from ref on the passive side: Buy -> ref - dist, Sell -> ref + dist.

◆ inventory_allows()

constexpr bool fastmm::inventory_allows ( Side  side,
Qty  position,
Qty  qty,
Qty  limit 
)
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.

◆ keep_passive()

void fastmm::keep_passive ( DesiredQuotes &  q,
Price  best_bid,
Price  best_ask,
Price  tick 
)
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.

◆ fit_side()

void fastmm::fit_side ( StaticVector< Level, kMaxQuoteLevels > &  levels,
Qty  room,
const Instrument &  inst 
)
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).

◆ fit_to_reported()

template<class Ctx >
void fastmm::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).

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.

◆ fit_to_balance()

template<class Ctx >
FASTMM_FORCE_INLINE void fastmm::fit_to_balance ( Ctx &  ctx,
InstrumentId  id,
const Instrument &  inst,
DesiredQuotes &  q 
)
noexcept

◆ to_string() [2/23]

constexpr std::string_view fastmm::to_string ( TransportKind  k)
constexprnoexcept

◆ to_string() [3/23]

constexpr std::string_view fastmm::to_string ( AddResult  r)
constexprnoexcept

◆ list_strategies()

const std::vector< StrategyEntry > & fastmm::list_strategies ( )
inline

◆ sim_factory()

template<class S >
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.

◆ replay_factory()

template<class S >
std::unique_ptr< IEngineRunner > fastmm::replay_factory ( TransportKind  kind,
RunnerDeps &  deps 
)

◆ live_factory()

template<class S >
std::unique_ptr< IEngineRunner > fastmm::live_factory ( TransportKind  kind,
RunnerDeps &  deps 
)

◆ operator|()

constexpr Transports fastmm::operator| ( Transports  a,
Transports  b 
)
constexprnoexcept

◆ has()

constexpr bool fastmm::has ( Transports  set,
Transports  t 
)
constexprnoexcept

◆ register_strategy()

template<class S , Transports Enabled = Transports::All>
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.

◆ operator*() [1/3]

template<class T >
constexpr Fixed< T > fastmm::operator* ( Fixed< T >  v,
Ratio  r 
)
constexprnoexcept

value * ratio in the value's domain, through Int128 with one truncation toward zero: mid * 5_bps, qty * ratio(filled, total).

◆ operator*() [2/3]

template<class T >
constexpr Fixed< T > fastmm::operator* ( Ratio  r,
Fixed< T >  v 
)
constexprnoexcept

◆ operator*() [3/3]

constexpr Ratio fastmm::operator* ( Ratio  a,
Ratio  b 
)
constexprnoexcept

◆ ratio()

template<class T >
constexpr Ratio fastmm::ratio ( Fixed< T >  num,
Fixed< T >  den 
)
constexprnoexcept

num / den as a Ratio, truncated toward zero; zero when den is zero.

The quotient must fit +-92,233,720,368.

◆ mul()

constexpr Notional fastmm::mul ( Price  p,
Qty  q 
)
constexprnoexcept

price * qty with a 128-bit intermediate, truncated toward zero to 1e-8.

◆ mul_raw()

template<class A , class B >
constexpr std::int64_t fastmm::mul_raw ( Fixed< A >  a,
Fixed< B >  b 
)
constexprnoexcept

Generic scaled multiply for fixed*fixed in one domain (e.g. qty * multiplier).

◆ div()

constexpr Price fastmm::div ( Notional  n,
Qty  q 
)
constexprnoexcept

notional / qty -> price (used for average cost). Truncates toward zero.

◆ apply_bps()

template<class T >
constexpr Fixed< T > fastmm::apply_bps ( Fixed< T >  v,
std::int64_t  bps 
)
constexprnoexcept

value * bps / 10000 in one domain.

◆ floor_div()

constexpr std::int64_t fastmm::floor_div ( std::int64_t  a,
std::int64_t  b 
)
constexprnoexcept

Floor division for possibly-negative numerators (prices are >= 0, but be safe).

◆ round_to_tick()

constexpr Price fastmm::round_to_tick ( Price  p,
Price  tick,
Side  side 
)
constexprnoexcept

Round to the tick grid in the passive direction: bids down, asks up. tick > 0.

◆ round_to_tick_nearest()

constexpr Price fastmm::round_to_tick_nearest ( Price  p,
Price  tick 
)
constexprnoexcept

◆ on_tick()

constexpr bool fastmm::on_tick ( Price  p,
Price  tick 
)
constexprnoexcept

◆ round_to_lot()

constexpr Qty fastmm::round_to_lot ( Qty  q,
Qty  lot 
)
constexprnoexcept

Quantities always round down (never send more than intended).

◆ on_lot()

constexpr bool fastmm::on_lot ( Qty  q,
Qty  lot 
)
constexprnoexcept

◆ min()

template<class T >
constexpr Fixed< T > fastmm::min ( Fixed< T >  a,
Fixed< T >  b 
)
constexprnoexcept

◆ max()

template<class T >
constexpr Fixed< T > fastmm::max ( Fixed< T >  a,
Fixed< T >  b 
)
constexprnoexcept

◆ checked_add()

template<class T >
constexpr std::optional< Fixed< T > > fastmm::checked_add ( Fixed< T >  a,
Fixed< T >  b 
)
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.

◆ checked_sub()

template<class T >
constexpr std::optional< Fixed< T > > fastmm::checked_sub ( Fixed< T >  a,
Fixed< T >  b 
)
constexprnoexcept

◆ checked_mul()

template<class T >
constexpr std::optional< Fixed< T > > fastmm::checked_mul ( Fixed< T >  a,
std::int64_t  k 
)
constexprnoexcept

◆ opposite()

constexpr Side fastmm::opposite ( Side  s)
constexprnoexcept

◆ sign()

constexpr int fastmm::sign ( Side  s)
constexprnoexcept

◆ to_string() [4/23]

constexpr std::string_view fastmm::to_string ( Side  s)
constexprnoexcept

◆ to_string() [5/23]

constexpr std::string_view fastmm::to_string ( OrderType  t)
constexprnoexcept

◆ to_string() [6/23]

constexpr std::string_view fastmm::to_string ( TimeInForce  t)
constexprnoexcept

◆ to_string() [7/23]

constexpr std::string_view fastmm::to_string ( AssetClass  a)
constexprnoexcept

◆ is_terminal()

constexpr bool fastmm::is_terminal ( OrderState  s)
constexprnoexcept

◆ is_pending()

constexpr bool fastmm::is_pending ( OrderState  s)
constexprnoexcept

◆ to_string() [8/23]

constexpr std::string_view fastmm::to_string ( OrderState  s)
constexprnoexcept

◆ to_string() [9/23]

constexpr std::string_view fastmm::to_string ( RejectReason  r)
constexprnoexcept

◆ to_string() [10/23]

constexpr std::string_view fastmm::to_string ( EventType  t)
constexprnoexcept

◆ to_string() [11/23]

constexpr std::string_view fastmm::to_string ( ConnState  s)
constexprnoexcept

◆ to_string() [12/23]

constexpr std::string_view fastmm::to_string ( Liquidity  l)
constexprnoexcept

◆ to_string() [13/23]

constexpr std::string_view fastmm::to_string ( ControlCommand  c)
constexprnoexcept

◆ to_string() [14/23]

constexpr std::string_view fastmm::to_string ( KillReason  r)
constexprnoexcept

◆ to_string() [15/23]

constexpr std::string_view fastmm::to_string ( FlattenState  s)
constexprnoexcept

◆ to_string() [16/23]

constexpr std::string_view fastmm::to_string ( LogLevel  l)
constexprnoexcept

◆ write_cl_ord_id()

FASTMM_FORCE_INLINE void fastmm::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.

"fm" + the last 4 characters of hi (its upper 4 bytes); bytes 6 and 7 are then overwritten by lo.

◆ encode_cl_ord_id()

FixedString< 16 > fastmm::encode_cl_ord_id ( ClientOrderId  id)
inlinenoexcept

◆ decode_cl_ord_id()

std::optional< ClientOrderId > fastmm::decode_cl_ord_id ( std::string_view  s)
inlinenoexcept

◆ make_cl_ord_id()

constexpr ClientOrderId fastmm::make_cl_ord_id ( std::uint16_t  epoch,
std::uint32_t  seq 
)
constexprnoexcept

◆ cl_ord_id_epoch()

constexpr std::uint16_t fastmm::cl_ord_id_epoch ( ClientOrderId  id)
constexprnoexcept

◆ cl_ord_id_seq()

constexpr std::uint32_t fastmm::cl_ord_id_seq ( ClientOrderId  id)
constexprnoexcept

◆ nanoseconds()

constexpr Duration fastmm::nanoseconds ( std::int64_t  v)
constexprnoexcept

◆ microseconds()

constexpr Duration fastmm::microseconds ( std::int64_t  v)
constexprnoexcept

◆ milliseconds()

constexpr Duration fastmm::milliseconds ( std::int64_t  v)
constexprnoexcept

◆ seconds()

constexpr Duration fastmm::seconds ( std::int64_t  v)
constexprnoexcept

◆ rdtscp()

FASTMM_FORCE_INLINE Cycles fastmm::rdtscp ( )
noexcept

Serialising read (rdtscp) is what latency hops want: it waits for prior loads to retire.

◆ rdtsc()

FASTMM_FORCE_INLINE Cycles fastmm::rdtsc ( )
noexcept

◆ wall_now()

Timestamp fastmm::wall_now ( )
noexcept

CLOCK_REALTIME via vDSO (~20 ns). Implemented in src/core/time.cpp.

◆ steady_now()

Timestamp fastmm::steady_now ( )
noexcept

◆ tsc_kind()

TscKind fastmm::tsc_kind ( )
noexcept

◆ has_invariant_tsc()

bool fastmm::has_invariant_tsc ( )
inlinenoexcept

◆ tsc_interval_ns()

FASTMM_FORCE_INLINE std::uint64_t fastmm::tsc_interval_ns ( const TscCalibration &  c,
std::uint64_t  cycles 
)
noexcept

A TSC cycle interval in ns; 0 without a rate.

◆ system_clock_readings()

ClockReadings fastmm::system_clock_readings ( )
noexcept

◆ calibrate_tsc() [1/2]

TscCalibration fastmm::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.

src/core/time.cpp

◆ calibrate_tsc() [2/2]

TscCalibration fastmm::calibrate_tsc ( Duration  window,
const ClockReadings &  readings 
)
noexcept

◆ to_string() [17/23]

constexpr const char * fastmm::to_string ( TscRefresh  r)
constexprnoexcept

◆ tsc_to_ns()

FASTMM_FORCE_INLINE std::int64_t fastmm::tsc_to_ns ( const TscCalibration &  c,
std::uint64_t  tsc 
)
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.

◆ fail()

template<class E >
constexpr Unexpected< std::decay_t< E > > fastmm::fail ( E &&  e)
constexprnoexcept

◆ init_header()

template<class M >
constexpr void fastmm::init_header ( M &  m,
EventType  type,
InstrumentId  inst = {},
VenueId  venue = {},
std::uint32_t  len = static_cast<std::uint32_t>(sizeof(M)) 
)
constexprnoexcept

For fixed-size messages len defaults to sizeof(M); BookDeltaMsg passes size_for().

◆ truncation_flags()

constexpr std::uint8_t fastmm::truncation_flags ( bool  bids,
bool  asks 
)
constexprnoexcept

The header flags of a delta whose bids and/or asks kept only the levels nearest the touch.

◆ msg_cast()

template<MessageLike M>
FASTMM_FORCE_INLINE const M & fastmm::msg_cast ( const EventHeader *  h)
noexcept

◆ write_file_atomic()

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.

◆ load_strategy_state()

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.

◆ to_string() [18/23]

constexpr std::string_view fastmm::to_string ( QuoteBlock  b)
constexprnoexcept

◆ secret()

template<class T >
Secret< std::decay_t< T > > fastmm::secret ( T &&  v)

◆ log_enabled()

FASTMM_FORCE_INLINE bool fastmm::log_enabled ( LogLevel  lvl)
noexcept

◆ at_or_better()

constexpr bool fastmm::at_or_better ( Side  s,
Price  p,
Price  q 
)
constexprnoexcept

true if p is at least as good as q from the point of view of side s.

◆ better()

constexpr bool fastmm::better ( Side  s,
Price  p,
Price  q 
)
constexprnoexcept

◆ load_instruments()

InstrumentTable fastmm::load_instruments ( const Config &  cfg)

Builds the dense instrument table (src/core/instrument_loader.cpp). Throws ConfigError.

◆ fee_table()

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).

◆ balance_config()

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.

◆ perp_config()

PerpConfig fastmm::perp_config ( const Config &  cfg)

[accounting] mark, stale_mark_ms and stale_funding_ms.

◆ config_schema()

std::span< const KeySpec > fastmm::config_schema ( )
inlinenoexcept

◆ substitute_env()

Result< std::string, std::string > fastmm::substitute_env ( std::string_view  in)
inline

Returns the substituted string, or the name of the first missing variable.

◆ has_env_reference()

bool fastmm::has_env_reference ( std::string_view  s)
inlinenoexcept

◆ to_string() [19/23]

constexpr std::string_view fastmm::to_string ( TransferState  s)
constexprnoexcept

◆ to_string() [20/23]

constexpr const char * fastmm::to_string ( SyncReason  r)
constexprnoexcept

◆ to_string() [21/23]

constexpr const char * fastmm::to_string ( SyncState  s)
constexprnoexcept

◆ to_string() [22/23]

constexpr std::string_view fastmm::to_string ( RecordType  t)
constexprnoexcept

◆ to_string() [23/23]

constexpr std::string_view fastmm::to_string ( RejectSource  s)
constexprnoexcept

Variable Documentation

◆ kHooks

constexpr std::array<HookInfo, static_cast<std::size_t>(Hook::Count)> fastmm::kHooks
inlineconstexpr
Initial value:
{{
#define FASTMM_HOOK_INFO(E, name, word, params, args, sig)
}}
#define FASTMM_STRATEGY_HOOKS(X)
The hook table.
Definition hooks.hpp:91
#define FASTMM_HOOK_INFO(E, name, word, params, args, sig)

◆ kMaxParams

constexpr std::size_t fastmm::kMaxParams = 128
inlineconstexpr

◆ kTransportKinds

constexpr std::size_t fastmm::kTransportKinds = static_cast<std::size_t>(TransportKind::Count)
inlineconstexpr

◆ kFixedScale

constexpr std::int64_t fastmm::kFixedScale = 100'000'000
inlineconstexpr

1e-8

◆ kFixedDecimals

constexpr int fastmm::kFixedDecimals = 8
inlineconstexpr

◆ kMaxDecimalChars

constexpr std::size_t fastmm::kMaxDecimalChars = 24
inlineconstexpr

sign + 11 integer digits + '.' + 8 fraction digits + NUL

◆ kRatioPerBp

constexpr std::int64_t fastmm::kRatioPerBp = 10'000
inlineconstexpr

Ratio (below): 1.0 == kFixedScale raw, one basis point == kRatioPerBp raw.

◆ kBpsDecimals

constexpr int fastmm::kBpsDecimals = 4
inlineconstexpr

◆ kMaxInstruments

constexpr std::size_t fastmm::kMaxInstruments = 256
inlineconstexpr

◆ kKillVenueSlots

constexpr std::size_t fastmm::kKillVenueSlots = 31
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).

◆ kNullHandle

constexpr std::uint32_t fastmm::kNullHandle = std::numeric_limits<std::uint32_t>::max()
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.

◆ kClOrdIdChars

constexpr std::size_t fastmm::kClOrdIdChars = 14
inlineconstexpr

"fm" + 12 lowercase hex digits (48 bits) = 14 chars. Fits Binance (36) and Bybit (36).

◆ kMessageVersion

constexpr std::uint8_t fastmm::kMessageVersion = 1
inlineconstexpr

◆ kFundingIdPrefix

constexpr std::string_view fastmm::kFundingIdPrefix = "funding:"
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.

◆ kTripKillPlannedStop

constexpr std::uint64_t fastmm::kTripKillPlannedStop = 1
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.

◆ kMaxBookLevelsPerMsg

constexpr std::uint32_t fastmm::kMaxBookLevelsPerMsg = 1024
inlineconstexpr

Largest fixed-size message; BookDelta is bounded separately by kMaxBookLevelsPerMsg.

◆ kMaxMsgBytes

constexpr std::uint32_t fastmm::kMaxMsgBytes
inlineconstexpr
Initial value:
=
BookDeltaMsg::size_for(kMaxBookLevelsPerMsg, kMaxBookLevelsPerMsg)

◆ kMaxOpenOrders

constexpr std::size_t fastmm::kMaxOpenOrders = 4096
inlineconstexpr

◆ kRecentlyTerminal

constexpr std::size_t fastmm::kRecentlyTerminal = 4096
inlineconstexpr

◆ kMaxSyntheticFills

constexpr std::size_t fastmm::kMaxSyntheticFills = 64
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.

◆ kMaxSeq

constexpr std::uint64_t fastmm::kMaxSeq = 0xFFFF'FFFFULL
inlineconstexpr

Client order ids per session: the wire form is 48 bits, epoch(16) << 32 | seq(32).

◆ kMaxQuoteLevels

constexpr std::size_t fastmm::kMaxQuoteLevels = 8
inlineconstexpr

◆ kQuoteNoteLen

constexpr std::size_t fastmm::kQuoteNoteLen = 24
inlineconstexpr

QuoteNote::reason, NUL-terminated.

◆ kMaxStrategyMetrics

constexpr std::size_t fastmm::kMaxStrategyMetrics = 32
inlineconstexpr

◆ kStrategyMetricNameLen

constexpr std::size_t fastmm::kStrategyMetricNameLen = 24
inlineconstexpr

◆ kQuoteDiagAccounts

constexpr std::size_t fastmm::kQuoteDiagAccounts = 8
inlineconstexpr

a pool's accounts (EngineConfig::pools)

◆ kLogRecordBytes

constexpr std::size_t fastmm::kLogRecordBytes = 256
inlineconstexpr

◆ kLogMaxStrBytes

constexpr std::size_t fastmm::kLogMaxStrBytes = 64
inlineconstexpr

◆ kLogRingSize

constexpr std::size_t fastmm::kLogRingSize = 8192
inlineconstexpr

records per thread (2 MiB)

◆ kLogMaxThreads

constexpr std::size_t fastmm::kLogMaxThreads = 64
inlineconstexpr

◆ g_log_level

std::atomic<std::uint8_t> fastmm::g_log_level {static_cast<std::uint8_t>(LogLevel::Info)}
inline

Global level (runtime); FASTMM_MIN_LOG_LEVEL is the compile-time floor.

◆ kMaxVenuesConfig

constexpr std::size_t fastmm::kMaxVenuesConfig = 8
inlineconstexpr

== kMaxVenues (transport.hpp)

◆ kMinFillAuditIntervalS

constexpr int fastmm::kMinFillAuditIntervalS = 10
inlineconstexpr

The shortest [venues.<name>] fill_audit_interval_s: an audit reads every subscribed symbol.

◆ kConfigSchema

constexpr KeySpec fastmm::kConfigSchema[]
inlineconstexpr

◆ kRecordVersion

constexpr std::uint8_t fastmm::kRecordVersion = 1
inlineconstexpr