FastMM documentation
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
messages.hpp
Go to the documentation of this file.
1#pragma once
2// Event bus message structs (5.5). Every message:
3// * starts with a 64-byte EventHeader whose first 4 bytes are the total length and 5th
4// byte the EventType (MsgRing protocol),
5// * is trivially copyable with sizeof a multiple of 64 (explicit padding),
6// * carries a `version` so journals remain readable across layout changes.
7//
8// Messages are constructed in place inside a ring/journal buffer; use init_header().
9#include "fastmm/core/config_macros.hpp"
10#include "fastmm/core/enums.hpp"
12#include "fastmm/core/fixed_string.hpp"
15#include "fastmm/core/time.hpp"
16
17#include <cstddef>
18#include <cstdint>
19#include <span>
20#include <string_view>
21#include <type_traits>
22
23namespace fastmm {
24
25inline constexpr std::uint8_t kMessageVersion = 1;
26
27// One price level. Shared by book messages and the L2 book.
28struct Level {
31 constexpr bool operator==(const Level&) const noexcept = default;
32};
33static_assert(sizeof(Level) == 16 && std::is_trivially_copyable_v<Level>);
34
35struct EventHeader {
36 enum Flags : std::uint8_t {
37 kSynthetic = 1U << 0, // generated locally (reconcile fill, sim), not from the venue
38 kReplayed = 1U << 1, // came from a journal
39 kSnapshot = 1U << 2, // BookDelta carries a full snapshot
40 kOutbound = 1U << 3, // engine -> venue message copied into the journal
41 // Journal only (format v2, ADR-0010): reserved0 holds the engine clock at consumption as a
42 // signed ns delta from the previous kEngineTime record or EngineTimeMsg.
43 kEngineTime = 1U << 4,
44 kDropped = 1U << 5, // journal only: outbound message the transport did not accept
45 // BookDelta: the venue's update changed more levels on this side than the message carries,
46 // and the side holds the ones nearest the touch (LevelSpill). A book level behind the last
47 // one it carries may be stale; L2Book drops those.
48 kTruncatedBids = 1U << 6,
49 kTruncatedAsks = 1U << 7,
50 };
52 std::uint32_t len; // total bytes incl. header, multiple of 64 (offset 0)
53 EventType type; // (offset 4)
54 std::uint8_t version; // kMessageVersion
56 std::uint8_t flags;
57 InstrumentId instrument; // dense id, invalid for non-instrument events (offset 8)
58 std::uint32_t reserved0; // journal: engine-time delta when kEngineTime (offset 12)
59 std::uint64_t seq; // engine consumption order; assigned by JournalWriter (16)
60 std::uint64_t venue_seq; // venue update id / sequence number (24)
61 Timestamp exch_ts; // venue event time (32)
62 Timestamp recv_ts; // T0 wall-clock (40)
63 Cycles t0_cycles; // T0 raw TSC at recv (48)
64 std::uint32_t t1_delta; // cycles T0->T1 (decoded) (56)
65 std::uint32_t t2_delta; // cycles T0->T2 (book applied) (60)
66};
67static_assert(sizeof(EventHeader) == 64);
68static_assert(offsetof(EventHeader, len) == 0 && offsetof(EventHeader, type) == 4);
69static_assert(std::is_trivially_copyable_v<EventHeader>);
70
71// For fixed-size messages len defaults to sizeof(M); BookDeltaMsg passes size_for().
72template <class M>
73constexpr void init_header(M& m,
74 EventType type,
75 InstrumentId inst = {},
76 VenueId venue = {},
77 std::uint32_t len = static_cast<std::uint32_t>(sizeof(M))) noexcept {
78 static_assert(std::is_trivially_copyable_v<M>);
79 FASTMM_ASSERT(len % 64 == 0 && len >= sizeof(EventHeader));
80 m.hdr = EventHeader{};
81 m.hdr.len = len;
82 m.hdr.type = type;
83 m.hdr.version = kMessageVersion;
84 m.hdr.venue = venue;
85 m.hdr.instrument = inst;
86}
87
88// ---- market data ---------------------------------------------------------------------
89
90// Bids then asks follow the fixed part as a flexible array of Level (bid_count + ask_count).
91// Used both for deltas (qty == 0 means delete) and full snapshots (flag kSnapshot).
92//
93// Never construct a BookDeltaMsg by value, not even with zero levels. The fixed part is 96
94// bytes but hdr.len is rounded to the 64-byte message granule, so size_for(0, 0) == 128.
95// Everything that forwards a message copies hdr.len bytes (MsgRing, journal, BookSyncer), so a
96// stack or member BookDeltaMsg is read 32 bytes past its end. Build it in place instead:
97// alignas(64) std::byte buf[BookDeltaMsg::size_for(bids, asks)]; or ring.try_reserve(len)
98struct BookDeltaMsg {
100 std::uint32_t bid_count;
101 std::uint32_t ask_count;
102 std::uint64_t first_update_id; // Binance U
103 std::uint64_t last_update_id; // Binance u / Bybit u
104 std::uint64_t prev_update_id; // Binance futures pu (0 if n/a)
106 [[nodiscard]] static constexpr std::uint32_t size_for(std::uint32_t bids,
107 std::uint32_t asks) noexcept {
108 const std::uint32_t raw =
109 static_cast<std::uint32_t>(sizeof(BookDeltaMsg)) + (bids + asks) * 16U;
110 return (raw + 63U) & ~63U;
111 }
112 [[nodiscard]] Level* levels() noexcept {
113 return reinterpret_cast<Level*>(reinterpret_cast<std::byte*>(this) + sizeof(BookDeltaMsg));
114 }
115 [[nodiscard]] const Level* levels() const noexcept {
116 return reinterpret_cast<const Level*>(reinterpret_cast<const std::byte*>(this) +
117 sizeof(BookDeltaMsg));
118 }
119 [[nodiscard]] std::span<const Level> bids() const noexcept { return {levels(), bid_count}; }
120 [[nodiscard]] std::span<const Level> asks() const noexcept {
122 }
123 [[nodiscard]] std::span<Level> bids() noexcept { return {levels(), bid_count}; }
124 [[nodiscard]] std::span<Level> asks() noexcept { return {levels() + bid_count, ask_count}; }
125 [[nodiscard]] bool is_snapshot() const noexcept {
127 }
128};
129static_assert(sizeof(BookDeltaMsg) == 96 && alignof(BookDeltaMsg) == 8);
130// The header flags of a delta whose bids and/or asks kept only the levels nearest the touch.
131[[nodiscard]] constexpr std::uint8_t truncation_flags(bool bids, bool asks) noexcept {
132 std::uint8_t f = 0;
133 if (bids) f |= EventHeader::kTruncatedBids;
134 if (asks) f |= EventHeader::kTruncatedAsks;
135 return f;
136}
137using BookSnapshotMsg = BookDeltaMsg; // same layout; hdr.type == BookSnapshot, kSnapshot set
139struct TradeMsg {
143 std::uint64_t trade_id;
145 std::uint8_t pad_[39];
147static_assert(sizeof(TradeMsg) == 128);
148
149struct BookTickerMsg {
155 std::uint8_t pad_[32];
157static_assert(sizeof(BookTickerMsg) == 128);
158
159// Options ticker (EventType::OptionTicker): the venue's mark, implied volatilities and greeks for
160// one option instrument. mark_price is in the instrument's price unit (the base coin for Deribit
161// inverse options); underlying_price (the forward the venue prices the option on) and
162// index_price are in the underlying's quote currency. Implied vols are annualised decimals
163// (0.312 = 31.2 %). Greeks are copied as the venue reports them (Deribit: Black-76 delta, gamma
164// per quote unit, vega and rho per 1 vol / rate point, theta per day, in the quote currency; see
165// core/options/black76.hpp). NaN marks a field the venue did not send.
166struct OptionTickerMsg {
171 double mark_iv; // 88
172 double bid_iv; // 96
173 double ask_iv; // 104
174 double delta; // 112
175 double gamma; // 120
176 double vega; // 128
177 double theta; // 136
178 double rho; // 144
179 double interest_rate; // 152 annualised decimal
180 std::uint8_t pad_[32]; // 160
182static_assert(sizeof(OptionTickerMsg) == 192);
183static_assert(offsetof(OptionTickerMsg, mark_iv) == 88 &&
184 offsetof(OptionTickerMsg, interest_rate) == 152);
185
186// ---- order events (venue -> engine) ----------------------------------------------------
187
189 // The venue amended the resting order in place (Binance Spot order.amend.keepPriority,
190 // execution type REPLACED): same venue order, same queue position, fills so far kept. Without
191 // it an ack under a new client id means a new venue order whose cumulative quantity is zero.
192 static constexpr std::uint8_t kAmendedInPlace = 1U << 0;
193
197 std::uint8_t flags;
198 std::uint8_t pad_[14];
199};
200static_assert(sizeof(OrderAckMsg) == 128);
201
206 std::uint8_t pad0_[3];
207 std::int32_t venue_code;
208 FixedString<40> text;
209 std::uint8_t pad_[7];
210};
211static_assert(sizeof(OrderRejectMsg) == 128);
212
217 std::uint8_t pad0_[7];
218 Qty cum_qty; // filled before the cancel took effect
219};
220static_assert(sizeof(OrderCancelAckMsg) == 128);
221
225 RejectReason reason; // VenueUnknownOrder => the venue has no such order
226 std::uint8_t pad0_[3];
227 std::int32_t venue_code;
228 FixedString<40> text;
229 std::uint8_t pad_[7];
230};
231static_assert(sizeof(OrderCancelRejectMsg) == 128);
232
234 // The execution comes from the venue's trade history (Venue::request_executions), not from the
235 // private stream: it may already have been booked, so cum_qty and leaves_qty are not reported and
236 // the OMS works out how much of it is new (Oms::on_fill, OmsUpdate::corrected_qty).
237 static constexpr std::uint8_t kReplayed = 1U << 0;
238 // A replayed execution naming no order whose order the connector could not look up yet and will
239 // ask for again (ReplayScheduler): a later copy with the same exec_id names it, or, once the
240 // connector gives up, a last copy without this flag says it never will. fastmm-gateway holds it
241 // back from every strategy until then; an engine books it as any fill naming no order.
242 static constexpr std::uint8_t kUnresolved = 1U << 1;
246 ExecId exec_id; // dedupe key
247 std::uint8_t pad0_[6];
249 Qty qty; // this execution
250 Qty cum_qty; // cumulative after this execution (0 with kReplayed: the venue did not say)
252 Notional fee; // >= 0 paid, < 0 rebate; in units of fee_asset
255 FeeAsset fee_asset; // Quote: `fee` is a quote amount; Base: base units; Other: not convertible
256 std::uint8_t flags; // kReplayed, kUnresolved
257 std::uint8_t pad_[52];
258};
259static_assert(sizeof(OrderFillMsg) == 256);
260
268static_assert(sizeof(OrderExpiredMsg) == 128);
269
279static_assert(sizeof(PositionUpdateMsg) == 128);
280
281// A perpetual funding payment the venue booked on the account's position in hdr.instrument
282// (EventType::Funding). `amount` is signed, in `asset` (the settlement currency): negative paid,
283// positive received. hdr.exch_ts is the venue's time of the payment. `funding_id` is the venue's
284// id of it (Binance tranId, Bybit execId); the engine and the gateway book one id per instrument
285// once, so the private stream and a replay from the venue's history may both deliver it.
287 // From the venue's history (Venue::request_executions), not the private stream.
288 static constexpr std::uint8_t kReplayed = 1U << 0;
291 ExecId funding_id; // 72 -> 113
292 FixedString<8> asset; // 113 -> 122
293 std::uint8_t flags; // 122 kReplayed
294 std::uint8_t pad_[5]; // -> 128
295};
296static_assert(sizeof(FundingMsg) == 128 && offsetof(FundingMsg, funding_id) == 72 &&
297 offsetof(FundingMsg, flags) == 122);
298// The account's holding of one asset on one venue (EventType::Balance), as the venue reports it at
299// its time hdr.exch_ts. Every amount is absolute, in `asset`: a venue update replaces the last one
300// (a delta would turn one lost message into a lasting error). hdr.instrument is invalid.
301// spot free (spendable now) and locked (held by open orders); total = free + locked;
302// equity = total; maintenance 0.
303// derivatives free = available for new orders, locked = initial margin in use (positions and
304// orders), total = wallet balance, equity = wallet + unrealised PnL, maintenance =
305// maintenance margin.
306// kAccount: the account's cross-collateral margin (Bybit's unified account, OKX's multi-currency
307// modes, Binance USD-M multi-assets mode) valued in `asset`, usually USD; the derivatives of the
308// venue draw on it instead of their settlement asset.
309// A snapshot (the balance leg of a reconciliation, a REST refresh) is a run of messages flagged
310// kSnapshot whose last one also carries kSnapshotEnd: an asset of the venue it did not name holds
311// nothing. A snapshot naming no asset is one message with an empty `asset`.
312// kWithdrawable: `withdrawable` is what the venue lets leave the account now by an internal
313// transfer (Binance USD-M maxWithdrawAmount, which unrealised profit does not count towards).
314// Without the flag a venue reports none and `free` is what can leave.
316 static constexpr std::uint8_t kSnapshot = 1U << 0;
317 static constexpr std::uint8_t kSnapshotEnd = 1U << 1;
318 static constexpr std::uint8_t kAccount = 1U << 2;
319 static constexpr std::uint8_t kWithdrawable = 1U << 3;
326 FixedString<8> asset; // 104 -> 113
327 std::uint8_t flags; // 113
328 std::uint8_t pad_[6]; // -> 120
329 Notional withdrawable; // 120, with kWithdrawable
330};
331static_assert(sizeof(BalanceMsg) == 128 && offsetof(BalanceMsg, asset) == 104 &&
332 offsetof(BalanceMsg, flags) == 113 && offsetof(BalanceMsg, withdrawable) == 120);
333
334// The venue's reference prices and funding of one derivative (EventType::PerpState), from its
335// public market data. Market data: it rides the market-data ring and the journal, so a replay sees
336// the same values at the same engine times. hdr.exch_ts is the venue's time of the values.
337// `fields` names what the message carries; the engine keeps the last value of each field with the
338// time it arrived (core/perp_book.hpp), so a venue that publishes mark, index and funding on
339// separate channels sends one message per channel.
340// mark_price kMark: the price the venue values positions and liquidations at
341// index_price kIndex: the spot index the mark and the funding follow
342// funding_rate kFunding: the rate the venue will apply at next_funding, per funding
343// interval, as a decimal (0.0001 = 1 bp); positive: longs pay shorts
344// funding_interval kFunding: how often funding is paid (a continuous venue reports the rate
345// over this interval: Deribit's current_funding, 8 h)
346// next_funding kFunding: venue time of the next payment; zero when funding is continuous
347// open_interest kOpenInterest: contracts open
349 static constexpr std::uint8_t kMark = 1U << 0;
350 static constexpr std::uint8_t kIndex = 1U << 1;
351 static constexpr std::uint8_t kFunding = 1U << 2;
352 static constexpr std::uint8_t kOpenInterest = 1U << 3;
356 double funding_rate; // 80
360 std::uint8_t fields; // 112
361 std::uint8_t pad_[15]; // -> 128
362};
363static_assert(sizeof(PerpStateMsg) == 128 && offsetof(PerpStateMsg, funding_rate) == 80 &&
364 offsetof(PerpStateMsg, fields) == 112);
365
366// A funding id in the list of venue ids a restarted session's store already holds
367// (store::Recovery::VenueResume::known_exec_ids, next to the trade ids): the prefix keeps the two
368// id spaces apart.
369inline constexpr std::string_view kFundingIdPrefix = "funding:";
370
371// ---- engine-internal -------------------------------------------------------------------
373struct TimerMsg {
376 std::uint8_t engine; // 1: the engine's own timer (max_param_age), not the strategy's
377 std::uint8_t pad0_[3];
378 std::uint64_t user_data;
380 std::uint8_t pad_[40];
381};
382static_assert(sizeof(TimerMsg) == 128);
387 std::uint8_t pad0_[7];
388 std::uint64_t arg;
389 std::uint8_t pad_[48];
390};
391static_assert(sizeof(ControlMsg) == 128);
392// ControlCommand::TripKill's arg for a stop that was asked for (fastmm-live's --duration, a signal,
393// fastmm-ctl stop): the engine pulls its quotes and cancels as for any trip, and logs it as a stop.
394inline constexpr std::uint64_t kTripKillPlannedStop = 1;
395
396// ControlCommand::SetLimits: a ControlMsg with the new limits after it. The prefix is a ControlMsg
397// (same type, same offsets), so the engine's dispatch reads `command` from either and only this
398// command looks past it; hdr.len tells the rings, the journal and a replay how long the record is.
402 std::uint8_t pad0_[7];
403 std::uint64_t arg;
405 std::uint8_t pad_[16];
406};
407static_assert(sizeof(ControlLimitsMsg) == 192 && std::is_trivially_copyable_v<ControlLimitsMsg>);
408static_assert(offsetof(ControlLimitsMsg, command) == offsetof(ControlMsg, command) &&
409 offsetof(ControlLimitsMsg, arg) == offsetof(ControlMsg, arg));
410
411// ControlCommand::SetUnderlyingLimit: a ControlMsg whose `arg` is the new max_net (raw Qty, base
412// units; 0 lifts the limit) of the underlying at index `underlying` of the session's plan
413// (core/underlying.hpp), named in `name` for the log and a journal reader.
417 std::uint8_t underlying;
418 std::uint8_t pad0_[6];
419 std::uint64_t arg;
420 FixedString<8> name;
421 std::uint8_t pad_[39];
422};
423static_assert(sizeof(ControlUnderlyingMsg) == sizeof(ControlMsg) &&
424 std::is_trivially_copyable_v<ControlUnderlyingMsg>);
425static_assert(offsetof(ControlUnderlyingMsg, command) == offsetof(ControlMsg, command) &&
426 offsetof(ControlUnderlyingMsg, arg) == offsetof(ControlMsg, arg));
427
428// ControlCommand::Transfer: one step of a pool treasury's transfer (core/treasury.hpp), on the
429// treasury's ring into the engine, which journals it. hdr.venue is the pool's primary; `arg` the
430// amount (raw Notional) of `asset` moved from account `from` to account `to`.
434 std::uint8_t event; // TreasuryEventKind: planned (dry run), sent, done, failed, timed out
435 std::uint8_t state; // TransferState of the venue's answer; Unknown without one
438 std::uint8_t pad0_[3];
439 std::uint64_t arg;
440 FixedString<8> asset; // 80
441 FixedString<31> client_id; // 89
442 FixedString<23> venue_ref; // 121: the venue's id of the transfer
443 std::uint8_t pad_[47]; // 145 -> 192
444};
445static_assert(sizeof(ControlTransferMsg) == 192 &&
446 std::is_trivially_copyable_v<ControlTransferMsg>);
447static_assert(offsetof(ControlTransferMsg, command) == offsetof(ControlMsg, command) &&
448 offsetof(ControlTransferMsg, arg) == offsetof(ControlMsg, arg) &&
449 offsetof(ControlTransferMsg, asset) == 80 &&
450 offsetof(ControlTransferMsg, client_id) == 89 &&
451 offsetof(ControlTransferMsg, venue_ref) == 121);
456 std::uint8_t channel; // 0 = market data, 1 = order/user stream
457 std::uint8_t pad0_[2];
458 std::int32_t reason_code;
459 std::uint8_t pad_[56];
460};
461static_assert(sizeof(ConnectionStateMsg) == 128);
462
463// Control thread injects the venue's view after a reconnect (5.8). A reconciliation is a
464// Begin, N OpenOrder / Position records, then End.
465//
466// Begin with kSentWatermark set carries the highest client order id (New or Replace) the venue had
467// taken from the outbound ring when it requested the snapshot. Orders with a higher id were not yet
468// sent, so the snapshot cannot contain them and End must not mark them cancelled. Without the flag
469// every order of the venue missing from the snapshot is cancelled.
471 enum class Kind : std::uint8_t { Begin = 0, OpenOrder = 1, Position = 2, End = 3 };
472 static constexpr std::uint8_t kSentWatermark = 1U << 0;
473 // Begin: every execution the venue made since the last one the engine booked was replayed before
474 // this snapshot (Venue::request_executions succeeded), so the snapshot's quantities are the
475 // venue's own and nothing in it has to be guessed at. Without it the connector could not ask, and
476 // a quantity the snapshot reports that no fill covered is an estimate: see
477 // Engine::book_missed_fill and Oms::reconcile_end.
478 static constexpr std::uint8_t kExecutionsExact = 1U << 1;
483 std::uint8_t pad0_[5];
486 std::uint8_t pad1_[7];
490 Qty position_qty; // Kind::Position
491 Price avg_px; // Kind::Position
492 ClientOrderId sent_watermark; // Kind::Begin, valid with kSentWatermark
493 std::uint8_t flags; // Kind::Begin: kSentWatermark
494 std::uint8_t pad_[15];
495};
496static_assert(sizeof(ReconcileMsg) == 192);
500 std::uint8_t interval; // LatencyInterval index
501 std::uint8_t pad0_[7];
502 std::uint64_t count;
503 std::int64_t p50_ns;
504 std::int64_t p90_ns;
505 std::int64_t p99_ns;
506 std::int64_t p999_ns;
507 std::int64_t max_ns;
508 std::uint8_t pad_[8];
509};
510static_assert(sizeof(LatencySampleMsg) == 128);
511
512// Journal only: what a replay or a backtest over the journal can start from. The bytes the strategy
513// was handed to restore() at the start (Kind::Restored, flagged kAccepted when it took them), and
514// every [strategy] state_snapshot_interval_s its state() with the engine's positions
515// (Kind::Snapshot). One state is written as records of at most kChunkBytes each: `id` numbers the
516// states of the session, `part` says what the bytes are (kStatePart: the strategy's state;
517// kPositionsPart: StatePosition entries), and `offset` / `total` place them in it. A record is
518// the 128-byte head and its bytes padded to 64. Never dispatched.
520 enum class Kind : std::uint8_t { Restored = 0, Snapshot = 1 };
521 static constexpr std::uint8_t kStatePart = 0;
522 static constexpr std::uint8_t kPositionsPart = 1;
523 static constexpr std::uint8_t kAccepted = 1U << 0;
524 static constexpr std::uint32_t kChunkBytes = 16384;
526 std::uint64_t id;
527 std::uint32_t total; // bytes of the part
528 std::uint32_t offset; // of this record's bytes in the part
529 std::uint32_t bytes; // after the head
531 std::uint8_t part;
532 std::uint8_t flags;
533 std::uint8_t pad_[37];
534 [[nodiscard]] static constexpr std::uint32_t size_for(std::uint32_t n) noexcept {
535 return 128 + (n + 63) / 64 * 64;
537 [[nodiscard]] const std::byte* data() const noexcept {
538 return reinterpret_cast<const std::byte*>(this) + 128;
539 }
540};
541static_assert(sizeof(StrategyStateMsg) == 128);
542
543// One instrument's position in a StrategyStateMsg's kPositionsPart: on the account (venue) whose
544// Reconcile Position would set it.
546 std::uint32_t instrument;
547 std::uint8_t venue;
548 std::uint8_t pad_[3];
549 std::int64_t qty_raw;
550 std::int64_t avg_px_raw;
551};
552static_assert(sizeof(StatePosition) == 24 && std::is_trivially_copyable_v<StatePosition>);
553
554// Journal only (format v2): the engine clock as an absolute value. Written when the engine starts
555// and finishes, and before a consumed event whose clock delta does not fit kEngineTime's int32 ns.
556// Never dispatched.
558 enum class Kind : std::uint8_t { Sync = 0, Start = 1, Finish = 2 };
562 std::uint8_t pad_[55];
563};
564static_assert(sizeof(EngineTimeMsg) == 128);
565
566// New strategy parameter values (ADR-0013): up to kMaxFields (field index, raw value) pairs, built
567// and validated off the engine thread (strategies/param_publisher.hpp). The engine applies them
568// together at one event, journals the message and calls on_params. A field index is the position
569// of the parameter in the strategy's schema; the journal header records the schema, so a replay
570// resolves indices by name. A raw value is the field's int64 form (ParamDesc::get_raw): the value
571// of an integer or bool, the raw fixed-point value of Price, Qty, Notional and Ratio, the
572// nanoseconds of a Duration and the IEEE-754 bits of a double. `origin` names the publisher (the
573// control socket's sequence is the one fastmm-ctl waits on) and `source` who asked for the change
574// (`fastmm-ctl param --source`), both zero in journals written before they existed.
576 static constexpr std::size_t kMaxFields = 32;
577 static constexpr std::size_t kSourceLen = 40; // `source`, NUL-terminated
578 // hdr.instrument of an update for every instrument: the invalid id.
579 static constexpr InstrumentId kAllInstruments{};
580 enum class Origin : std::uint8_t {
581 Strategy = 0, // the strategy's own publisher (a slow tier, a model), or not recorded
582 Control = 1, // the control socket (fastmm-ctl param)
583 };
586 std::uint32_t count; // pairs used
588 std::uint8_t pad0_[3]; //
589 std::uint64_t publish_seq; // the publisher's sequence number, from 1
590 std::uint16_t field[kMaxFields]; // schema index of each pair
591 char source[kSourceLen]; // who asked for it, e.g. "manual", "scheduled:drain"
592 std::uint8_t pad1_[8]; //
593 std::int64_t value[kMaxFields]; // raw value of each pair
595 [[nodiscard]] bool all_instruments() const noexcept { return !hdr.instrument.valid(); }
596 [[nodiscard]] std::string_view source_view() const noexcept {
597 std::size_t n = 0;
598 while (n < kSourceLen && source[n] != '\0') ++n;
599 return {source, n};
600 }
601 // Copies `s` into `source`, cut to kSourceLen - 1 bytes.
602 void set_source(std::string_view s) noexcept {
603 const std::size_t n = s.size() < kSourceLen - 1 ? s.size() : kSourceLen - 1;
604 for (std::size_t i = 0; i < kSourceLen; ++i) source[i] = i < n ? s[i] : '\0';
605 }
606};
607static_assert(sizeof(ParamUpdateMsg) == 448 && std::is_trivially_copyable_v<ParamUpdateMsg>);
608static_assert(offsetof(ParamUpdateMsg, count) == 64 && offsetof(ParamUpdateMsg, origin) == 68 &&
609 offsetof(ParamUpdateMsg, field) == 80 && offsetof(ParamUpdateMsg, source) == 144 &&
610 offsetof(ParamUpdateMsg, value) == 192);
611
612// ---- outbound (engine -> venue) --------------------------------------------------------
622 std::uint8_t reduce_only;
623 std::uint8_t pad_[36];
624};
625static_assert(sizeof(OutNewOrderMsg) == 128);
630 VenueOrderId venue_order_id; // may be empty if not yet acked
631 std::uint8_t pad_[15];
632};
633static_assert(sizeof(OutCancelMsg) == 128);
638 ClientOrderId orig_cl_ord_id; // order being replaced
640 std::uint8_t pad0_[7];
642 Qty qty;
643 std::uint8_t pad_[48];
644};
645static_assert(sizeof(OutReplaceMsg) == 192);
647// ---- L3 (ITCH-style) -------------------------------------------------------------------
651 std::uint64_t order_ref;
653 Qty qty;
654 Side side;
655 std::uint8_t pad_[39];
657static_assert(sizeof(OrderAddL3Msg) == 128);
659struct OrderExecL3Msg {
660 // exec_flags. Zero (E, and records written before the field existed) is a printable execution.
661 static constexpr std::uint8_t kNonPrintable = 1U << 0; // ITCH C with Printable = N
664 std::uint64_t order_ref;
666 Price exec_price; // zero -> at the order's price
667 std::uint64_t match_id;
668 std::uint8_t exec_flags;
669 std::uint8_t pad_[31];
670
671 [[nodiscard]] bool printable() const noexcept { return (exec_flags & kNonPrintable) == 0; }
673static_assert(sizeof(OrderExecL3Msg) == 128);
677 std::uint64_t order_ref;
678 Qty canceled_qty; // zero -> delete the whole order
679 std::uint8_t pad_[48];
681static_assert(sizeof(OrderCancelL3Msg) == 128);
685 std::uint64_t old_order_ref;
686 std::uint64_t new_order_ref;
687 Price price;
688 Qty qty;
689 std::uint8_t pad_[32];
690};
691static_assert(sizeof(OrderReplaceL3Msg) == 128);
693// Largest fixed-size message; BookDelta is bounded separately by kMaxBookLevelsPerMsg.
694inline constexpr std::uint32_t kMaxBookLevelsPerMsg = 1024;
695inline constexpr std::uint32_t kMaxMsgBytes =
697
698// Every message: trivially copyable with the EventHeader first. Fixed-size messages are
699// additionally a multiple of 64 bytes (BookDeltaMsg is variable-length: see size_for()).
700template <class M>
701concept MessageLike = std::is_trivially_copyable_v<M> &&
702 std::is_same_v<decltype(M::hdr), EventHeader> && alignof(M) <= 64;
703template <class M>
704concept FixedSizeMessage = MessageLike<M> && (sizeof(M) % 64 == 0);
720
721template <MessageLike M>
722[[nodiscard]] FASTMM_FORCE_INLINE const M& msg_cast(const EventHeader* h) noexcept {
723 return *reinterpret_cast<const M*>(h);
724}
725
726} // namespace fastmm
Definition messages.hpp:701
Every message: trivially copyable with the EventHeader first.
Definition messages.hpp:698
All engine enumerations.
Fixed<Tag>: int64 fixed point with a global 1e-8 scale (ADR-0001).
Definition strategy.hpp:16
constexpr std::uint8_t kMessageVersion
Definition messages.hpp:27
OrderType
Definition enums.hpp:23
OrderState
Definition enums.hpp:79
constexpr std::string_view kFundingIdPrefix
A funding id in the list of venue ids a restarted session's store already holds (store::Recovery::Ven...
Definition messages.hpp:369
ConnState
Definition enums.hpp:404
FixedString< 40 > VenueOrderId
Definition strong_id.hpp:42
EventType
Message discriminator carried in EventHeader::type.
Definition enums.hpp:300
RejectReason
Ordered exactly like RiskEngine::check_new evaluates them (5.7), followed by OMS / transport / venue ...
Definition enums.hpp:123
constexpr std::uint64_t kTripKillPlannedStop
ControlCommand::TripKill's arg for a stop that was asked for (fastmm-live's --duration,...
Definition messages.hpp:393
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().
Definition messages.hpp:75
Side
Definition enums.hpp:12
FeeAsset
The asset a fill's commission is charged in.
Definition enums.hpp:432
constexpr std::uint32_t kMaxMsgBytes
Definition messages.hpp:692
constexpr std::uint32_t kMaxBookLevelsPerMsg
Largest fixed-size message; BookDelta is bounded separately by kMaxBookLevelsPerMsg.
Definition messages.hpp:691
BookDeltaMsg BookSnapshotMsg
same layout; hdr.type == BookSnapshot, kSnapshot set
Definition messages.hpp:138
FASTMM_FORCE_INLINE const M & msg_cast(const EventHeader *h) noexcept
Definition messages.hpp:719
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.
Definition messages.hpp:132
FixedString< 40 > ExecId
Definition strong_id.hpp:44
TimeInForce
Definition enums.hpp:36
Liquidity
Definition enums.hpp:434
ControlCommand
Definition enums.hpp:447
StrongId< struct VenueTag, std::uint8_t > VenueId
Definition strong_id.hpp:39
RiskLimits: the pre-trade limits a session runs with ([risk] in the configuration),...
Strongly typed identifiers.
The account's holding of one asset on one venue (EventType::Balance), as the venue reports it at its ...
Definition messages.hpp:315
Notional locked
72
Definition messages.hpp:322
static constexpr std::uint8_t kSnapshotEnd
Definition messages.hpp:317
static constexpr std::uint8_t kSnapshot
Definition messages.hpp:316
static constexpr std::uint8_t kWithdrawable
Definition messages.hpp:319
Notional equity
88
Definition messages.hpp:324
EventHeader hdr
Definition messages.hpp:320
Notional free
64
Definition messages.hpp:321
Notional total
80
Definition messages.hpp:323
FixedString< 8 > asset
104 -> 113
Definition messages.hpp:326
Notional maintenance
96
Definition messages.hpp:325
static constexpr std::uint8_t kAccount
Definition messages.hpp:318
Notional withdrawable
120, with kWithdrawable
Definition messages.hpp:329
std::uint8_t pad_[6]
-> 120
Definition messages.hpp:328
std::uint8_t flags
113
Definition messages.hpp:327
Bids then asks follow the fixed part as a flexible array of Level (bid_count + ask_count).
Definition messages.hpp:99
EventHeader hdr
Definition messages.hpp:100
static constexpr std::uint32_t size_for(std::uint32_t bids, std::uint32_t asks) noexcept
Definition messages.hpp:107
std::uint64_t first_update_id
Binance U.
Definition messages.hpp:103
std::uint32_t bid_count
Definition messages.hpp:101
std::uint64_t last_update_id
Binance u / Bybit u.
Definition messages.hpp:104
bool is_snapshot() const noexcept
Definition messages.hpp:126
Level * levels() noexcept
Definition messages.hpp:113
std::span< const Level > bids() const noexcept
Definition messages.hpp:120
std::uint32_t ask_count
Definition messages.hpp:102
std::uint64_t prev_update_id
Binance futures pu (0 if n/a)
Definition messages.hpp:105
std::span< const Level > asks() const noexcept
Definition messages.hpp:121
Definition messages.hpp:150
Qty ask_qty
Definition messages.hpp:155
Price ask_px
Definition messages.hpp:154
std::uint8_t pad_[32]
Definition messages.hpp:156
Price bid_px
Definition messages.hpp:152
Qty bid_qty
Definition messages.hpp:153
EventHeader hdr
Definition messages.hpp:151
Definition messages.hpp:452
ConnState state
Definition messages.hpp:454
EventHeader hdr
Definition messages.hpp:453
std::uint8_t channel
0 = market data, 1 = order/user stream
Definition messages.hpp:455
std::uint8_t pad_[56]
Definition messages.hpp:458
std::uint8_t pad0_[2]
Definition messages.hpp:456
std::int32_t reason_code
Definition messages.hpp:457
ControlCommand::SetLimits: a ControlMsg with the new limits after it.
Definition messages.hpp:398
RiskLimits limits
Definition messages.hpp:403
EventHeader hdr
Definition messages.hpp:399
std::uint8_t pad0_[7]
Definition messages.hpp:401
ControlCommand command
Definition messages.hpp:400
std::uint64_t arg
Definition messages.hpp:402
std::uint8_t pad_[16]
Definition messages.hpp:404
Definition messages.hpp:383
std::uint8_t pad_[48]
Definition messages.hpp:388
ControlCommand command
Definition messages.hpp:385
EventHeader hdr
Definition messages.hpp:384
std::uint64_t arg
Definition messages.hpp:387
std::uint8_t pad0_[7]
Definition messages.hpp:386
ControlCommand::Transfer: one step of a pool treasury's transfer (core/treasury.hpp),...
Definition messages.hpp:430
std::uint64_t arg
Definition messages.hpp:438
VenueId to
Definition messages.hpp:436
ControlCommand command
Definition messages.hpp:432
VenueId from
Definition messages.hpp:435
std::uint8_t state
TransferState of the venue's answer; Unknown without one.
Definition messages.hpp:434
std::uint8_t pad0_[3]
Definition messages.hpp:437
FixedString< 8 > asset
80
Definition messages.hpp:439
FixedString< 23 > venue_ref
121: the venue's id of the transfer
Definition messages.hpp:441
std::uint8_t pad_[47]
145 -> 192
Definition messages.hpp:442
std::uint8_t event
TreasuryEventKind: planned (dry run), sent, done, failed, timed out.
Definition messages.hpp:433
FixedString< 31 > client_id
89
Definition messages.hpp:440
EventHeader hdr
Definition messages.hpp:431
ControlCommand::SetUnderlyingLimit: a ControlMsg whose arg is the new max_net (raw Qty,...
Definition messages.hpp:413
ControlCommand command
Definition messages.hpp:415
std::uint8_t pad_[39]
Definition messages.hpp:420
FixedString< 8 > name
Definition messages.hpp:419
EventHeader hdr
Definition messages.hpp:414
std::uint8_t pad0_[6]
Definition messages.hpp:417
std::uint64_t arg
Definition messages.hpp:418
std::uint8_t underlying
Definition messages.hpp:416
Definition time.hpp:59
Definition time.hpp:22
Journal only (format v2): the engine clock as an absolute value.
Definition messages.hpp:556
Timestamp engine_ts
Definition messages.hpp:559
std::uint8_t pad_[55]
Definition messages.hpp:561
EventHeader hdr
Definition messages.hpp:558
Kind
Definition messages.hpp:557
Kind kind
Definition messages.hpp:560
Definition messages.hpp:37
std::uint8_t flags
Definition messages.hpp:58
Cycles t0_cycles
T0 raw TSC at recv (48)
Definition messages.hpp:65
VenueId venue
Definition messages.hpp:57
std::uint64_t venue_seq
venue update id / sequence number (24)
Definition messages.hpp:62
std::uint32_t reserved0
journal: engine-time delta when kEngineTime (offset 12)
Definition messages.hpp:60
std::uint8_t version
kMessageVersion
Definition messages.hpp:56
std::uint64_t seq
engine consumption order; assigned by JournalWriter (16)
Definition messages.hpp:61
Timestamp recv_ts
T0 wall-clock (40)
Definition messages.hpp:64
Timestamp exch_ts
venue event time (32)
Definition messages.hpp:63
std::uint32_t len
total bytes incl. header, multiple of 64 (offset 0)
Definition messages.hpp:54
Flags
Definition messages.hpp:38
@ kDropped
journal only: outbound message the transport did not accept
Definition messages.hpp:46
@ kTruncatedBids
BookDelta: the venue's update changed more levels on this side than the message carries,...
Definition messages.hpp:50
@ kEngineTime
Journal only (format v2, ADR-0010): reserved0 holds the engine clock at consumption as a signed ns de...
Definition messages.hpp:45
@ kReplayed
came from a journal
Definition messages.hpp:40
@ kSnapshot
BookDelta carries a full snapshot.
Definition messages.hpp:41
@ kSynthetic
generated locally (reconcile fill, sim), not from the venue
Definition messages.hpp:39
@ kTruncatedAsks
Definition messages.hpp:51
@ kOutbound
engine -> venue message copied into the journal
Definition messages.hpp:42
std::uint32_t t2_delta
cycles T0->T2 (book applied) (60)
Definition messages.hpp:67
InstrumentId instrument
dense id, invalid for non-instrument events (offset 8)
Definition messages.hpp:59
std::uint32_t t1_delta
cycles T0->T1 (decoded) (56)
Definition messages.hpp:66
EventType type
(offset 4)
Definition messages.hpp:55
A perpetual funding payment the venue booked on the account's position in hdr.instrument (EventType::...
Definition messages.hpp:286
std::uint8_t flags
122 kReplayed
Definition messages.hpp:293
FixedString< 8 > asset
113 -> 122
Definition messages.hpp:292
ExecId funding_id
72 -> 113
Definition messages.hpp:291
static constexpr std::uint8_t kReplayed
From the venue's history (Venue::request_executions), not the private stream.
Definition messages.hpp:288
EventHeader hdr
Definition messages.hpp:289
std::uint8_t pad_[5]
-> 128
Definition messages.hpp:294
Notional amount
64
Definition messages.hpp:290
Definition messages.hpp:497
std::uint8_t pad_[8]
Definition messages.hpp:507
std::int64_t max_ns
Definition messages.hpp:506
std::int64_t p90_ns
Definition messages.hpp:503
EventHeader hdr
Definition messages.hpp:498
std::int64_t p99_ns
Definition messages.hpp:504
std::uint8_t pad0_[7]
Definition messages.hpp:500
std::uint64_t count
Definition messages.hpp:501
std::int64_t p999_ns
Definition messages.hpp:505
std::uint8_t interval
LatencyInterval index.
Definition messages.hpp:499
std::int64_t p50_ns
Definition messages.hpp:502
One price level. Shared by book messages and the L2 book.
Definition messages.hpp:30
constexpr bool operator==(const Level &) const noexcept=default
Price price
Definition messages.hpp:31
Qty qty
Definition messages.hpp:32
Options ticker (EventType::OptionTicker): the venue's mark, implied volatilities and greeks for one o...
Definition messages.hpp:167
double vega
128
Definition messages.hpp:177
double ask_iv
104
Definition messages.hpp:174
std::uint8_t pad_[32]
160
Definition messages.hpp:181
Price index_price
80
Definition messages.hpp:171
double delta
112
Definition messages.hpp:175
EventHeader hdr
Definition messages.hpp:168
double gamma
120
Definition messages.hpp:176
Price underlying_price
72
Definition messages.hpp:170
double theta
136
Definition messages.hpp:178
double bid_iv
96
Definition messages.hpp:173
double mark_iv
88
Definition messages.hpp:172
double rho
144
Definition messages.hpp:179
Price mark_price
64
Definition messages.hpp:169
double interest_rate
152 annualised decimal
Definition messages.hpp:180
Definition messages.hpp:188
std::uint8_t flags
Definition messages.hpp:197
static constexpr std::uint8_t kAmendedInPlace
The venue amended the resting order in place (Binance Spot order.amend.keepPriority,...
Definition messages.hpp:192
VenueOrderId venue_order_id
Definition messages.hpp:196
ClientOrderId cl_ord_id
Definition messages.hpp:195
std::uint8_t pad_[14]
Definition messages.hpp:198
EventHeader hdr
Definition messages.hpp:194
Definition messages.hpp:646
EventHeader hdr
Definition messages.hpp:647
Price price
Definition messages.hpp:649
Qty qty
Definition messages.hpp:650
std::uint8_t pad_[39]
Definition messages.hpp:652
Side side
Definition messages.hpp:651
std::uint64_t order_ref
Definition messages.hpp:648
Definition messages.hpp:213
Qty cum_qty
filled before the cancel took effect
Definition messages.hpp:218
VenueOrderId venue_order_id
Definition messages.hpp:216
std::uint8_t pad0_[7]
Definition messages.hpp:217
EventHeader hdr
Definition messages.hpp:214
ClientOrderId cl_ord_id
Definition messages.hpp:215
Definition messages.hpp:672
std::uint8_t pad_[48]
Definition messages.hpp:676
EventHeader hdr
Definition messages.hpp:673
std::uint64_t order_ref
Definition messages.hpp:674
Qty canceled_qty
zero -> delete the whole order
Definition messages.hpp:675
Definition messages.hpp:222
EventHeader hdr
Definition messages.hpp:223
ClientOrderId cl_ord_id
Definition messages.hpp:224
std::int32_t venue_code
Definition messages.hpp:227
FixedString< 40 > text
Definition messages.hpp:228
std::uint8_t pad0_[3]
Definition messages.hpp:226
RejectReason reason
VenueUnknownOrder => the venue has no such order.
Definition messages.hpp:225
std::uint8_t pad_[7]
Definition messages.hpp:229
Definition messages.hpp:656
Price exec_price
zero -> at the order's price
Definition messages.hpp:663
std::uint64_t match_id
Definition messages.hpp:664
std::uint8_t exec_flags
Definition messages.hpp:665
bool printable() const noexcept
Definition messages.hpp:668
std::uint64_t order_ref
Definition messages.hpp:661
EventHeader hdr
Definition messages.hpp:660
static constexpr std::uint8_t kNonPrintable
exec_flags. Zero (E, and records written before the field existed) is a printable execution.
Definition messages.hpp:658
Qty exec_qty
Definition messages.hpp:662
std::uint8_t pad_[31]
Definition messages.hpp:666
Definition messages.hpp:261
ClientOrderId cl_ord_id
Definition messages.hpp:263
VenueOrderId venue_order_id
Definition messages.hpp:264
Qty cum_qty
Definition messages.hpp:266
EventHeader hdr
Definition messages.hpp:262
std::uint8_t pad0_[7]
Definition messages.hpp:265
Definition messages.hpp:233
ExecId exec_id
dedupe key
Definition messages.hpp:246
std::uint8_t pad_[52]
Definition messages.hpp:257
FeeAsset fee_asset
Quote: fee is a quote amount; Base: base units; Other: not convertible.
Definition messages.hpp:255
static constexpr std::uint8_t kReplayed
The execution comes from the venue's trade history (Venue::request_executions), not from the private ...
Definition messages.hpp:237
Qty leaves_qty
Definition messages.hpp:251
Liquidity liquidity
Definition messages.hpp:254
Qty cum_qty
cumulative after this execution (0 with kReplayed: the venue did not say)
Definition messages.hpp:250
Notional fee
>= 0 paid, < 0 rebate; in units of fee_asset
Definition messages.hpp:252
std::uint8_t flags
kReplayed, kUnresolved
Definition messages.hpp:256
std::uint8_t pad0_[6]
Definition messages.hpp:247
VenueOrderId venue_order_id
Definition messages.hpp:245
EventHeader hdr
Definition messages.hpp:243
Side side
Definition messages.hpp:253
ClientOrderId cl_ord_id
Definition messages.hpp:244
Price price
Definition messages.hpp:248
static constexpr std::uint8_t kUnresolved
A replayed execution naming no order whose order the connector could not look up yet and will ask for...
Definition messages.hpp:242
Qty qty
this execution
Definition messages.hpp:249
Definition messages.hpp:202
EventHeader hdr
Definition messages.hpp:203
FixedString< 40 > text
Definition messages.hpp:208
std::int32_t venue_code
Definition messages.hpp:207
ClientOrderId cl_ord_id
Definition messages.hpp:204
std::uint8_t pad_[7]
Definition messages.hpp:209
std::uint8_t pad0_[3]
Definition messages.hpp:206
RejectReason reason
Definition messages.hpp:205
Definition messages.hpp:680
std::uint64_t old_order_ref
Definition messages.hpp:682
Price price
Definition messages.hpp:684
std::uint8_t pad_[32]
Definition messages.hpp:686
std::uint64_t new_order_ref
Definition messages.hpp:683
EventHeader hdr
Definition messages.hpp:681
Qty qty
Definition messages.hpp:685
Definition messages.hpp:625
EventHeader hdr
Definition messages.hpp:626
VenueOrderId venue_order_id
may be empty if not yet acked
Definition messages.hpp:628
std::uint8_t pad_[15]
Definition messages.hpp:629
ClientOrderId cl_ord_id
Definition messages.hpp:627
Definition messages.hpp:612
std::uint8_t reduce_only
Definition messages.hpp:620
Price price
Definition messages.hpp:615
Qty qty
Definition messages.hpp:616
OrderType type
Definition messages.hpp:618
ClientOrderId cl_ord_id
Definition messages.hpp:614
std::uint8_t pad_[36]
Definition messages.hpp:621
Side side
Definition messages.hpp:617
TimeInForce tif
Definition messages.hpp:619
EventHeader hdr
Definition messages.hpp:613
Definition messages.hpp:633
Qty qty
Definition messages.hpp:640
ClientOrderId cl_ord_id
new id
Definition messages.hpp:635
ClientOrderId orig_cl_ord_id
order being replaced
Definition messages.hpp:636
std::uint8_t pad0_[7]
Definition messages.hpp:638
EventHeader hdr
Definition messages.hpp:634
Price price
Definition messages.hpp:639
VenueOrderId venue_order_id
Definition messages.hpp:637
std::uint8_t pad_[48]
Definition messages.hpp:641
New strategy parameter values (ADR-0013): up to kMaxFields (field index, raw value) pairs,...
Definition messages.hpp:574
Origin
Definition messages.hpp:579
@ Strategy
the strategy's own publisher (a slow tier, a model), or not recorded
@ Control
the control socket (fastmm-ctl param)
std::uint32_t count
pairs used
Definition messages.hpp:585
std::uint8_t pad1_[8]
Definition messages.hpp:591
bool all_instruments() const noexcept
Definition messages.hpp:594
std::int64_t value[kMaxFields]
raw value of each pair
Definition messages.hpp:592
std::uint16_t field[kMaxFields]
schema index of each pair
Definition messages.hpp:589
std::uint8_t pad0_[3]
Definition messages.hpp:587
static constexpr std::size_t kMaxFields
Definition messages.hpp:575
static constexpr InstrumentId kAllInstruments
hdr.instrument of an update for every instrument: the invalid id.
Definition messages.hpp:578
void set_source(std::string_view s) noexcept
Copies s into source, cut to kSourceLen - 1 bytes.
Definition messages.hpp:601
static constexpr std::size_t kSourceLen
source, NUL-terminated
Definition messages.hpp:576
Origin origin
Definition messages.hpp:586
std::string_view source_view() const noexcept
Definition messages.hpp:595
char source[kSourceLen]
who asked for it, e.g. "manual", "scheduled:drain"
Definition messages.hpp:590
std::uint64_t publish_seq
the publisher's sequence number, from 1
Definition messages.hpp:588
EventHeader hdr
Definition messages.hpp:584
The venue's reference prices and funding of one derivative (EventType::PerpState),...
Definition messages.hpp:348
Duration funding_interval
88
Definition messages.hpp:357
std::uint8_t pad_[15]
-> 128
Definition messages.hpp:361
static constexpr std::uint8_t kOpenInterest
Definition messages.hpp:352
Price mark_price
64
Definition messages.hpp:354
Qty open_interest
104
Definition messages.hpp:359
Timestamp next_funding
96
Definition messages.hpp:358
EventHeader hdr
Definition messages.hpp:353
Price index_price
72
Definition messages.hpp:355
static constexpr std::uint8_t kMark
Definition messages.hpp:349
double funding_rate
80
Definition messages.hpp:356
static constexpr std::uint8_t kFunding
Definition messages.hpp:351
static constexpr std::uint8_t kIndex
Definition messages.hpp:350
std::uint8_t fields
112
Definition messages.hpp:360
Definition messages.hpp:270
Notional unrealized
Definition messages.hpp:275
std::uint8_t pad_[24]
Definition messages.hpp:277
EventHeader hdr
Definition messages.hpp:271
Qty qty
signed net position
Definition messages.hpp:272
Price avg_px
Definition messages.hpp:273
Notional realized
Definition messages.hpp:274
Notional fees
Definition messages.hpp:276
Definition position.hpp:20
Control thread injects the venue's view after a reconnect (5.8).
Definition messages.hpp:469
std::uint8_t pad1_[7]
Definition messages.hpp:485
EventHeader hdr
Definition messages.hpp:478
std::uint8_t pad_[15]
Definition messages.hpp:493
Qty cum_qty
Definition messages.hpp:488
Kind kind
Definition messages.hpp:479
Side side
Definition messages.hpp:480
std::uint8_t flags
Kind::Begin: kSentWatermark.
Definition messages.hpp:492
ClientOrderId sent_watermark
Kind::Begin, valid with kSentWatermark.
Definition messages.hpp:491
Kind
Definition messages.hpp:470
OrderState state
Definition messages.hpp:481
Price price
Definition messages.hpp:486
static constexpr std::uint8_t kExecutionsExact
Begin: every execution the venue made since the last one the engine booked was replayed before this s...
Definition messages.hpp:477
static constexpr std::uint8_t kSentWatermark
Definition messages.hpp:471
Qty position_qty
Kind::Position.
Definition messages.hpp:489
ClientOrderId cl_ord_id
Definition messages.hpp:483
VenueOrderId venue_order_id
Definition messages.hpp:484
std::uint8_t pad0_[5]
Definition messages.hpp:482
Price avg_px
Kind::Position.
Definition messages.hpp:490
Qty orig_qty
Definition messages.hpp:487
Definition risk_limits.hpp:17
One instrument's position in a StrategyStateMsg's kPositionsPart: on the account (venue) whose Reconc...
Definition messages.hpp:544
std::uint8_t venue
Definition messages.hpp:546
std::int64_t avg_px_raw
Definition messages.hpp:549
std::int64_t qty_raw
Definition messages.hpp:548
std::uint32_t instrument
Definition messages.hpp:545
std::uint8_t pad_[3]
Definition messages.hpp:547
Journal only: what a replay or a backtest over the journal can start from.
Definition messages.hpp:518
std::uint32_t bytes
after the head
Definition messages.hpp:528
std::uint64_t id
Definition messages.hpp:525
EventHeader hdr
Definition messages.hpp:524
static constexpr std::uint8_t kAccepted
Definition messages.hpp:522
Kind kind
Definition messages.hpp:529
static constexpr std::uint8_t kStatePart
Definition messages.hpp:520
static constexpr std::uint32_t size_for(std::uint32_t n) noexcept
Definition messages.hpp:533
std::uint32_t total
bytes of the part
Definition messages.hpp:526
const std::byte * data() const noexcept
Definition messages.hpp:536
std::uint8_t part
Definition messages.hpp:530
std::uint8_t flags
Definition messages.hpp:531
static constexpr std::uint32_t kChunkBytes
Definition messages.hpp:523
Kind
Definition messages.hpp:519
static constexpr std::uint8_t kPositionsPart
Definition messages.hpp:521
std::uint8_t pad_[37]
Definition messages.hpp:532
std::uint32_t offset
of this record's bytes in the part
Definition messages.hpp:527
constexpr bool valid() const noexcept
Definition strong_id.hpp:31
Definition messages.hpp:372
std::uint64_t user_data
Definition messages.hpp:377
std::uint8_t engine
1: the engine's own timer (max_param_age), not the strategy's
Definition messages.hpp:375
TimerId timer_id
Definition messages.hpp:374
Timestamp fire_ts
Definition messages.hpp:378
std::uint8_t pad0_[3]
Definition messages.hpp:376
EventHeader hdr
Definition messages.hpp:373
std::uint8_t pad_[40]
Definition messages.hpp:379
Definition time.hpp:45
Definition messages.hpp:140
std::uint8_t pad_[39]
Definition messages.hpp:146
EventHeader hdr
Definition messages.hpp:141
Price price
Definition messages.hpp:142
Side aggressor
Definition messages.hpp:145
std::uint64_t trade_id
Definition messages.hpp:144
Qty qty
Definition messages.hpp:143
Time primitives.