FastMM documentation
FastMM C++ API 0.14.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
record_stream.hpp
Go to the documentation of this file.
1#pragma once
2// Record stream: the engine's second outbound queue, next to the journal.
3//
4// engine thread --RecordWriter--> MsgRing --store thread--> a storage backend
5//
6// The journal is the byte-exact stream a replay consumes; this is the interpreted one, the fills,
7// orders, positions and kill events a store turns into rows. Both are written the same way: the
8// engine copies a trivially copyable record into an SPSC ring and never waits. A full ring drops
9// the record and counts it (EngineStats::records_dropped); nothing in the trading path depends on
10// a record being consumed, so a slow or broken store cannot stall or kill a session. The journal
11// is the authority for anything a drop lost (docs/reference/storage.md).
12//
13// Records share the MsgRing prefix (4-byte length, 1-byte non-zero type) and are a multiple of 64
14// bytes, like the event messages, but they carry their own RecordType space and version: the store
15// format is free to change without touching the journal format.
17#include "fastmm/core/config_macros.hpp"
18#include "fastmm/core/enums.hpp"
21#include "fastmm/core/msg_ring.hpp"
22#include "fastmm/core/order.hpp"
26#include "fastmm/core/time.hpp"
27
28#include <cstddef>
29#include <cstdint>
30#include <cstring>
31#include <string_view>
32#include <type_traits>
33
34namespace fastmm {
35
36inline constexpr std::uint8_t kRecordVersion = 1;
37
38// Never 0: the ring reserves type 0 for padding.
39enum class RecordType : std::uint8_t {
40 Fill = 1,
41 Order = 2,
42 Position = 3,
43 Kill = 4,
44 Funding = 5,
45 Replayed = 6,
46 Param = 7,
47 Reject = 8,
48 Limits = 9,
49 Markout = 10,
50 Capacity = 11,
51 ContextNames = 12,
52};
53[[nodiscard]] constexpr std::string_view to_string(RecordType t) noexcept {
54 switch (t) {
56 return "Fill";
58 return "Order";
60 return "Position";
62 return "Kill";
64 return "Funding";
66 return "Replayed";
68 return "Param";
70 return "Reject";
72 return "Limits";
74 return "Markout";
76 return "Capacity";
78 return "ContextNames";
79 }
80 return "?";
81}
82
83struct RecordHeader {
84 enum Flags : std::uint8_t {
85 kSynthetic = 1U << 0, // booked by the engine, not reported by the venue (a cum_qty jump)
86 kLate = 1U << 1, // fill for an order that was already terminal; on an order record,
87 // that fill's update of the order (only cum_qty and state are valid)
88 kUnknown = 1U << 2, // fill for an order id the OMS does not know
89 kTerminal = 1U << 3, // the order reached a terminal state with this record
90 kVenue = 1U << 4, // kill record: one venue's switch, not the global one
91 kReplayed = 1U << 5, // funding record: from the venue's history, not its private stream
92 };
94 std::uint32_t len; // total bytes, a multiple of 64 (offset 0)
95 RecordType type; // (4)
96 std::uint8_t version; // kRecordVersion (5)
97 VenueId venue; // (6)
98 std::uint8_t flags; // (7)
99 InstrumentId instrument; // invalid when the record is not per instrument (8)
100 std::uint8_t aux[4]; // record-specific small fields (12)
101 std::uint64_t seq; // record order within the session, from 1 (16)
102 Timestamp engine_ts; // the engine clock the record was made at (24)
103 Timestamp wall_ts; // wall clock at the same point (32)
104 std::uint64_t session_id; // (40)
105 // The venue's time of the event behind the record (a fill: the trade time the venue reported),
106 // 0 when there is none. A restart resumes the venue's execution replay from it
107 // (store/reader.hpp).
108 Timestamp exch_ts; // (48)
109 std::uint8_t pad_[8]; // -> 64
111static_assert(sizeof(RecordHeader) == 64 && std::is_trivially_copyable_v<RecordHeader>);
112static_assert(offsetof(RecordHeader, len) == 0 && offsetof(RecordHeader, type) == 4 &&
113 offsetof(RecordHeader, seq) == 16 && offsetof(RecordHeader, exch_ts) == 48);
114
115// One execution. `fee` is the engine's booked fee in the instrument's settlement currency;
116// `fee_amount` is what the venue reported, in units of `fee_asset` (a commission in a third asset
117// is reported but not booked, so `fee` is then zero).
118//
119// From offset 256, the fill's decision record: how its order got where it was filled (the OMS's
120// OrderTrail) and what the strategy said about the side (StrategyContext::quote_context), so a
121// fill can be explained afterwards without a replay. `trail` is 0 when the fill named no order the
122// OMS remembers; the order fields are zero then and only fill_context is set. Engine clock
123// throughout.
124struct FillRecord {
128 Qty qty; // 80 this execution, as the venue reported it
129 Qty booked_qty; // 88 what the position moved by (base-asset fees deducted)
132 Notional fee; // 112 settlement currency, booked
133 Notional fee_amount; // 120 as reported, in fee_asset units
134 Qty position_qty; // 128 the instrument's position after this fill
138 // The part of this execution that named an estimate (a synthetic fill of the same order booked
139 // before it, Engine::book_missed_fill): the position already held it and only took the rest,
140 // booked_qty, while the estimate's price and missing fee were corrected to this execution's.
141 // Zero on a synthetic fill and on an ordinary execution.
142 Qty named_qty; // 160
143 VenueOrderId venue_order_id; // 168 -> 209
144 ExecId exec_id; // 209 -> 250
145 Side side; // 250
148 std::uint8_t arm; // 253 its order's Order::arm
149 std::uint8_t pad0_[2]; // -> 256
150 Timestamp placed_ts; // 256 the order's first leg went out
151 Timestamp sent_ts; // 264 the working leg went out: placed_ts, or the last accepted
152 // replace's send
153 Timestamp venue_ack_ts; // 272 the working leg's ack, venue time (invalid: none)
154 Timestamp local_ack_ts; // 280 the same ack, when it reached the engine
155 // A cancel or replace was in flight when the fill arrived (order_state PendingCancel or
156 // PendingReplace): when it went out. On a late fill, the cancel that ended the order.
157 Timestamp pending_ts; // 288
158 Price placed_px; // 296 the first leg's price
159 Price pending_px; // 304 the replace in flight: its price
160 QuoteContext order_context; // 312 the side's context when the working leg went out
161 QuoteContext fill_context; // 344 the side's context when the fill arrived
162 std::uint32_t amends; // 376 replaces the venue accepted before the fill
163 OrderState order_state; // 380 the order's state when the fill arrived, before it
164 std::uint8_t trail; // 381 1: the order fields above are set
165 std::uint8_t pad_[2]; // -> 384
167static_assert(sizeof(FillRecord) == 384 && std::is_trivially_copyable_v<FillRecord>);
168static_assert(offsetof(FillRecord, named_qty) == 160 &&
169 offsetof(FillRecord, venue_order_id) == 168 && offsetof(FillRecord, exec_id) == 209 &&
170 offsetof(FillRecord, placed_ts) == 256 &&
171 offsetof(FillRecord, order_context) == 312 && offsetof(FillRecord, amends) == 376);
172
173// The OMS record after a transition. hdr.aux[0] is the previous OrderState, hdr.aux[1] the
174// OmsAction as an integer, and hdr.aux[2] is 1 when this closes the client order id a
175// cancel-replace superseded (order.cl_ord_id is that id; every other field belongs to the order
176// that carries on, so a store updates only the state). With RecordHeader::kLate the order had
177// already ended and a fill that arrived after it changed its cum_qty, and its state when the fill
178// completed it (Filled instead of Canceled): a store updates those two.
179struct OrderRecord {
183static_assert(sizeof(OrderRecord) == 192 && std::is_trivially_copyable_v<OrderRecord>);
184
185// One instrument's position and the portfolio totals at the same instant.
186struct PositionRecord {
188 Position pos; // 64 -> 128
192 Notional pnl_carry; // 152 carried in from earlier sessions (EngineConfig::pnl_carry)
193 Notional funding; // 160 this instrument's funding so far, part of pos.realized
194 Notional total_funding; // 168 over every instrument, part of total_realized
195 std::uint8_t pad_[16]; // -> 192
197static_assert(sizeof(PositionRecord) == 192 && std::is_trivially_copyable_v<PositionRecord>);
198
199// A funding payment the engine booked (FundingMsg): `amount` in the instrument's settlement
200// currency, negative paid. hdr.exch_ts is the venue's time of it; hdr.flags kReplayed when it came
201// from the venue's history. A position record follows it.
202struct FundingRecord {
205 Qty position_qty; // 72 the position it was paid on
206 Notional position_realized; // 80 the instrument's realized after it
207 Notional position_funding; // 88 the instrument's funding after it
208 Notional total_funding; // 96 over every instrument
209 ExecId funding_id; // 104 -> 145
210 FixedString<8> asset; // 145 -> 154
211 std::uint8_t pad_[38]; // -> 192
213static_assert(sizeof(FundingRecord) == 192 && std::is_trivially_copyable_v<FundingRecord>);
214
215// A kill switch trip. hdr.flags & kVenue marks a per-venue trip (hdr.venue names it).
216struct KillRecord {
219 std::uint8_t pad0_[3]; // -> 68
220 std::uint32_t kill_flags; // 68 RiskEngine::kill_flags()
221 std::uint64_t kills; // 72 global trips so far
222 std::uint64_t venue_kills; // 80
227 std::uint8_t pad_[8]; // -> 128
229static_assert(sizeof(KillRecord) == 128 && std::is_trivially_copyable_v<KillRecord>);
230
231// A venue's execution replay ended complete (a reconciliation began with
232// ReconcileMsg::kExecutionsExact): every execution the venue made before it is in the records
233// before this one. hdr.venue is the venue. A restart reads it as "this session got past its replay
234// on that venue": the fills of a session without one may have a hole behind them (it died while
235// the replay was still reading), and the next replay starts before them (store/reader.hpp).
236struct ReplayedRecord {
239static_assert(sizeof(ReplayedRecord) == 64 && std::is_trivially_copyable_v<ReplayedRecord>);
240
241// A strategy parameter update the engine applied (ParamUpdateMsg): after the header, the message's
242// bytes past its own header, so the fields sit at the same offsets. hdr.instrument is the update's
243// target, invalid for every instrument. The store names the fields through the session's
244// parameter table (SessionOpen::param_table).
245struct ParamRecord {
247 std::uint32_t count; // 64 pairs used
249 std::uint8_t arm; // 69 ParamUpdateMsg::arm
250 std::uint8_t flags; // 70 ParamUpdateMsg::flags
251 std::uint8_t pad0_[1]; //
252 std::uint64_t publish_seq; // 72
253 std::uint16_t field[ParamUpdateMsg::kMaxFields]; // 80 index in the parameter table
254 char source[ParamUpdateMsg::kSourceLen]; // 144 NUL-terminated
255 std::uint8_t pad1_[8]; //
256 std::int64_t value[ParamUpdateMsg::kMaxFields]; // 192 raw value of each pair
258 [[nodiscard]] std::string_view source_view() const noexcept {
259 std::size_t n = 0;
260 while (n < ParamUpdateMsg::kSourceLen && source[n] != '\0') ++n;
261 return {source, n};
262 }
263};
264static_assert(sizeof(ParamRecord) == sizeof(ParamUpdateMsg) &&
265 std::is_trivially_copyable_v<ParamRecord>);
266static_assert(offsetof(ParamRecord, count) == offsetof(ParamUpdateMsg, count) &&
267 offsetof(ParamRecord, origin) == offsetof(ParamUpdateMsg, origin) &&
268 offsetof(ParamRecord, arm) == offsetof(ParamUpdateMsg, arm) &&
269 offsetof(ParamRecord, flags) == offsetof(ParamUpdateMsg, flags) &&
270 offsetof(ParamRecord, publish_seq) == offsetof(ParamUpdateMsg, publish_seq) &&
271 offsetof(ParamRecord, field) == offsetof(ParamUpdateMsg, field) &&
272 offsetof(ParamRecord, source) == offsetof(ParamUpdateMsg, source) &&
273 offsetof(ParamRecord, value) == offsetof(ParamUpdateMsg, value));
274
275// An operator's `limits` command the engine applied (ControlCommand::SetLimits or
276// SetUnderlyingLimit): the [risk] limits and check_balance before and after it, or one
277// underlying's max_net. `forced`: it turned a limit off (fastmm-ctl limits --force).
278struct LimitsRecord {
279 enum Kind : std::uint8_t { kRisk = 0, kUnderlying = 1 };
283 std::int64_t underlying_before; // 256 kUnderlying: max_net, raw Qty in base units
284 std::int64_t underlying_after; // 264
285 FixedString<8> underlying; // 272 kUnderlying: the base asset
286 std::uint8_t kind; //
287 std::uint8_t forced; //
288 std::uint8_t check_balance_before; //
289 std::uint8_t check_balance_after; //
290 std::uint8_t pad_[320 - 276 - sizeof(FixedString<8>)];
292static_assert(sizeof(LimitsRecord) == 320 && std::is_trivially_copyable_v<LimitsRecord>);
293
294// What refused an order (RejectRecord::source): the limit behind a rate-limit refusal, or the
295// side that refused it otherwise. Rate limits stay apart by where they are counted: the engine's
296// [risk] bucket, the engine's view of an account's order windows (ctx.order_budget, pool routing),
297// the connector's own limiter (never sent), and the venue's answer.
298enum class RejectSource : std::uint8_t {
299 Risk = 0, // a pre-trade check other than the rate limits (`reason` says which)
300 RiskBucket = 1, // the [risk] orders_per_sec token bucket, shared by every account
301 AccountPaused = 2, // the account's connector is paused (429 Retry-After, 418)
302 AccountOrders10s = 3, // the account's order window at the connector's cap
303 AccountOrders1m = 4,
304 AccountOrders1d = 5,
305 VenueLocal = 6, // the connector's own limiter refused it before sending (OrderReject text)
306 Venue = 7, // the venue refused it (venue_code, text)
307 Capacity = 8, // worth less than the order slot it takes ([capacity], RejectReason::PricedOut)
308};
309[[nodiscard]] constexpr std::string_view to_string(RejectSource s) noexcept {
310 switch (s) {
312 return "risk";
314 return "risk_bucket";
316 return "account_paused";
318 return "account_orders_10s";
320 return "account_orders_1m";
322 return "account_orders_1d";
324 return "venue_local";
326 return "venue";
328 return "capacity";
329 }
330 return "?";
331}
332
333// One order refused: by the pre-trade checks (the engine's) or by its venue (an OrderReject),
334// with the account's order budget as the engine saw it then (ctx.order_budget). hdr.venue is the
335// account the order went to or was routed to, hdr.instrument its instrument. Refusals of the
336// same instrument, side, account, reason, source and flags within a hold of the last one recorded
337// for them are counted into the next record's `folded` rather than recorded one by one: the counts
338// stay exact per account, a strategy retrying on every event does not fill the store. The hold
339// starts at RejectRecord::kFoldNs and doubles with each record of an unbroken run, up to
340// kFoldMaxNs.
341struct RejectRecord {
342 static constexpr std::int64_t kFoldNs = 100'000'000;
343 static constexpr std::int64_t kFoldMaxNs = 60'000'000'000;
344 enum Flags : std::uint8_t {
345 kReplace = 1U << 0, // a replace, not a new order
346 kReduces = 1U << 1, // with the open orders on its side, it only takes the position to zero
347 kReduceOnly = 1U << 2,
348 kFromVenue = 1U << 3, // an OrderReject, not a pre-trade check
349 };
351 RejectReason reason; // 64
353 Side side; // 66
354 std::uint8_t flags; // 67
355 std::uint32_t folded; // 68 refusals of the same key folded in since the last record
357 Qty qty; // 80
358 ClientOrderId cl_ord_id; // 88 the venue's refusals; 0 for a pre-trade one
359 std::int64_t local_tokens; // 96 [risk] bucket tokens left (OrderBudget::kUnlimited: off)
360 std::int64_t local_wait_ns; // 104
361 // The account's windows: used and what the connector admits (RateWindow::admits; 0 unknown).
362 std::int64_t orders_10s_used; // 112
363 std::int64_t orders_10s_admits; // 120
364 std::int64_t orders_1m_used; // 128
365 std::int64_t orders_1m_admits; // 136
366 std::int64_t orders_1d_used; // 144
367 std::int64_t orders_1d_admits; // 152
368 std::int64_t weight_used; // 160
369 std::int64_t weight_admits; // 168
370 std::int32_t venue_code; // 176 the venue's error code (OrderRejectMsg::venue_code)
371 std::uint8_t budget_known; // 180 the account's connector has published a budget
372 std::uint8_t paused; // 181
373 std::uint8_t pad0_[2]; //
374 FixedString<40> text; // 184 the venue's text (OrderRejectMsg::text)
375 std::uint8_t pad_[31]; // -> 256
377static_assert(sizeof(RejectRecord) == 256 && std::is_trivially_copyable_v<RejectRecord>);
378
379// The instrument's mid `horizon_ms` after one of its fills, 0 at the fill ([engine] markout_ms).
380// hdr.engine_ts is when the engine read the mid: at the first event or timer from the horizon on.
381struct MarkoutRecord {
383 std::uint64_t fill_seq; // 64 the FillRecord's hdr.seq
384 Timestamp fill_ts; // 72 the fill's engine time
385 Price mid; // 80
386 std::int32_t horizon_ms; // 88
387 std::uint8_t pad_[36]; // -> 128
389static_assert(sizeof(MarkoutRecord) == 128 && std::is_trivially_copyable_v<MarkoutRecord>);
390
391// A minute of one account's capacity price ([capacity], core/capacity_price.hpp): the actions
392// priced, those refused below their price and those that would have been (observe), and the
393// price paid. hdr.venue is the account; hdr.engine_ts the end of the minute.
394struct CapacityRecord {
396 std::uint32_t decided; // 64 actions priced
397 std::uint32_t sent; // 68 new orders and replaces sent
398 std::uint32_t priced_out_new; // 72
399 std::uint32_t priced_out_move; // 76
400 std::uint32_t observed_new; // 80 would have been priced out
401 std::uint32_t observed_move; // 84
402 std::uint32_t peak_used; // 88 the most orders in one window
404 std::uint8_t pad0_[3]; //
405 double price_min; // 96 quote currency
406 double price_max; // 104
407 double price_mean; // 112
408 double floor; // 120 L, the value of a minimum-notional order
409 double day_price; // 128 the account's and the strategy's day prices
410 std::uint8_t pad_[56]; // -> 192
412static_assert(sizeof(CapacityRecord) == 192 && std::is_trivially_copyable_v<CapacityRecord>);
413
414// The names the strategy gave the values of its quote context (StrategyContext::
415// quote_context_names), in slot order; an empty name leaves a slot unnamed. Written when the
416// strategy names them, normally once from on_start.
417struct ContextNamesRecord {
418 static constexpr std::size_t kNameLen = 23; // bytes kept of a name
420 FixedString<kNameLen> names[kQuoteContextSize]; // 64 -> 160
421 std::uint8_t pad_[32]; // -> 192
423static_assert(sizeof(ContextNamesRecord) == 192 &&
424 std::is_trivially_copyable_v<ContextNamesRecord>);
425
426// Engine-side producer. Every method is allocation-free, wait-free and safe to call from the
427// trading thread; a full ring increments dropped() and returns false.
428class RecordWriter {
429 public:
430 explicit RecordWriter(MsgRing* ring = nullptr, std::uint64_t session_id = 0) noexcept
431 : ring_(ring), session_id_(session_id) {}
433 [[nodiscard]] bool enabled() const noexcept { return ring_ != nullptr; }
434 [[nodiscard]] std::uint64_t written() const noexcept { return written_; }
435 [[nodiscard]] std::uint64_t dropped() const noexcept { return dropped_; }
437 [[nodiscard]] FASTMM_FORCE_INLINE bool put(const RecordHeader& r) noexcept {
438 if (ring_ == nullptr) return true; // disabled: callers guard with enabled()
439 std::byte* p = ring_->try_reserve(r.len);
440 if (FASTMM_UNLIKELY(p == nullptr)) {
441 ++dropped_;
442 return false;
443 }
444 std::memcpy(p, &r, r.len);
445 auto* h = reinterpret_cast<RecordHeader*>(p);
447 h->seq = ++written_;
448 h->session_id = session_id_;
449 ring_->commit();
450 return true;
451 }
452
453 // Fills in the parts every record shares. The caller sets the record-specific fields and calls
454 // put(). `len` is sizeof the record.
455 template <class R>
456 FASTMM_FORCE_INLINE void init(R& r,
457 RecordType type,
459 VenueId venue,
460 Timestamp engine_ts,
461 Timestamp wall_ts) noexcept {
462 static_assert(std::is_trivially_copyable_v<R> && sizeof(R) % 64 == 0);
463 r.hdr = RecordHeader{};
464 r.hdr.len = static_cast<std::uint32_t>(sizeof(R));
465 r.hdr.type = type;
466 r.hdr.version = kRecordVersion;
467 r.hdr.instrument = inst;
468 r.hdr.venue = venue;
469 r.hdr.engine_ts = engine_ts;
470 r.hdr.wall_ts = wall_ts;
471 }
472
473 private:
474 MsgRing* ring_;
475 std::uint64_t session_id_;
476 std::uint64_t written_ = 0;
477 std::uint64_t dropped_ = 0;
478};
479
480} // namespace fastmm
The capacity price ([capacity]): every action that uses an order slot is a purchase.
Engine-side producer.
Definition record_stream.hpp:430
bool enabled() const noexcept
Definition record_stream.hpp:435
FASTMM_FORCE_INLINE bool put(const RecordHeader &r) noexcept
Definition record_stream.hpp:439
std::uint64_t written() const noexcept
Definition record_stream.hpp:436
std::uint64_t dropped() const noexcept
Definition record_stream.hpp:437
FASTMM_FORCE_INLINE void init(R &r, RecordType type, InstrumentId inst, VenueId venue, Timestamp engine_ts, Timestamp wall_ts) noexcept
Fills in the parts every record shares.
Definition record_stream.hpp:458
All engine enumerations.
Fixed<Tag>: int64 fixed point with a global 1e-8 scale (ADR-0001).
Event bus message structs (5.5).
Definition strategy.hpp:23
constexpr std::size_t kQuoteContextSize
The numbers a strategy publishes about its quotes on one side of an instrument (StrategyContext::quot...
Definition order.hpp:71
RejectSource
What refused an order (RejectRecord::source): the limit behind a rate-limit refusal,...
Definition record_stream.hpp:300
@ Capacity
worth less than the order slot it takes ([capacity], RejectReason::PricedOut)
@ VenueLocal
the connector's own limiter refused it before sending (OrderReject text)
@ Risk
a pre-trade check other than the rate limits (reason says which)
@ AccountPaused
the account's connector is paused (429 Retry-After, 418)
@ Venue
the venue refused it (venue_code, text)
@ RiskBucket
the [risk] orders_per_sec token bucket, shared by every account
@ AccountOrders10s
the account's order window at the connector's cap
OrderState
Definition enums.hpp:79
FixedString< 40 > VenueOrderId
Definition strong_id.hpp:42
KillReason
Why a kill switch (global or one venue's) was tripped.
Definition enums.hpp:603
@ Funding
a perpetual funding payment booked by the venue (FundingMsg)
RejectReason
Ordered exactly like RiskEngine::check_new evaluates them (5.7), followed by OMS / transport / venue ...
Definition enums.hpp:123
RecordType
Never 0: the ring reserves type 0 for padding.
Definition record_stream.hpp:41
Side
Definition enums.hpp:12
FeeAsset
The asset a fill's commission is charged in.
Definition enums.hpp:481
constexpr std::uint8_t kRecordVersion
Definition record_stream.hpp:38
CapacityMode
Definition capacity_price.hpp:51
FixedString< 40 > ExecId
Definition strong_id.hpp:44
constexpr std::string_view to_string(ParamType t) noexcept
Definition params.hpp:63
Liquidity
Definition enums.hpp:483
Order: the OMS's 128-byte record for one order across its lifetime.
Position tracking, average-cost method (5.8).
RiskLimits: the pre-trade limits a session runs with ([risk] in the configuration),...
Strongly typed identifiers.
A minute of one account's capacity price ([capacity], core/capacity_price.hpp): the actions priced,...
Definition record_stream.hpp:396
RecordHeader hdr
Definition record_stream.hpp:397
std::uint8_t pad0_[3]
Definition record_stream.hpp:406
std::uint32_t decided
64 actions priced
Definition record_stream.hpp:398
std::uint32_t observed_new
80 would have been priced out
Definition record_stream.hpp:402
std::uint32_t priced_out_move
76
Definition record_stream.hpp:401
double price_max
104
Definition record_stream.hpp:408
double day_price
128 the account's and the strategy's day prices
Definition record_stream.hpp:411
double price_mean
112
Definition record_stream.hpp:409
std::uint32_t sent
68 new orders and replaces sent
Definition record_stream.hpp:399
CapacityMode mode
92
Definition record_stream.hpp:405
double price_min
96 quote currency
Definition record_stream.hpp:407
std::uint32_t peak_used
88 the most orders in one window
Definition record_stream.hpp:404
std::uint8_t pad_[56]
-> 192
Definition record_stream.hpp:412
std::uint32_t observed_move
84
Definition record_stream.hpp:403
std::uint32_t priced_out_new
72
Definition record_stream.hpp:400
double floor
120 L, the value of a minimum-notional order
Definition record_stream.hpp:410
The names the strategy gave the values of its quote context (StrategyContext:: quote_context_names),...
Definition record_stream.hpp:419
RecordHeader hdr
Definition record_stream.hpp:421
static constexpr std::size_t kNameLen
bytes kept of a name
Definition record_stream.hpp:420
FixedString< kNameLen > names[kQuoteContextSize]
64 -> 160
Definition record_stream.hpp:422
std::uint8_t pad_[32]
-> 192
Definition record_stream.hpp:423
One execution.
Definition record_stream.hpp:126
std::uint8_t trail
381 1: the order fields above are set
Definition record_stream.hpp:166
Qty named_qty
The part of this execution that named an estimate (a synthetic fill of the same order booked before i...
Definition record_stream.hpp:144
Side side
250
Definition record_stream.hpp:147
ExecId exec_id
209 -> 250
Definition record_stream.hpp:146
std::uint8_t arm
253 its order's Order::arm
Definition record_stream.hpp:150
std::uint8_t pad0_[2]
-> 256
Definition record_stream.hpp:151
Qty leaves_qty
104
Definition record_stream.hpp:133
QuoteContext fill_context
344 the side's context when the fill arrived
Definition record_stream.hpp:163
Price price
72
Definition record_stream.hpp:129
ClientOrderId cl_ord_id
64
Definition record_stream.hpp:128
Notional fee
112 settlement currency, booked
Definition record_stream.hpp:134
Liquidity liquidity
251
Definition record_stream.hpp:148
Timestamp sent_ts
264 the working leg went out: placed_ts, or the last accepted replace's send
Definition record_stream.hpp:153
std::uint8_t pad_[2]
-> 384
Definition record_stream.hpp:167
Price position_avg_px
136
Definition record_stream.hpp:137
OrderState order_state
380 the order's state when the fill arrived, before it
Definition record_stream.hpp:165
Notional fee_amount
120 as reported, in fee_asset units
Definition record_stream.hpp:135
Qty booked_qty
88 what the position moved by (base-asset fees deducted)
Definition record_stream.hpp:131
RecordHeader hdr
Definition record_stream.hpp:127
Price pending_px
304 the replace in flight: its price
Definition record_stream.hpp:161
Timestamp pending_ts
A cancel or replace was in flight when the fill arrived (order_state PendingCancel or PendingReplace)...
Definition record_stream.hpp:159
Qty position_qty
128 the instrument's position after this fill
Definition record_stream.hpp:136
Price placed_px
296 the first leg's price
Definition record_stream.hpp:160
Qty cum_qty
96
Definition record_stream.hpp:132
FeeAsset fee_asset
252
Definition record_stream.hpp:149
Timestamp venue_ack_ts
272 the working leg's ack, venue time (invalid: none)
Definition record_stream.hpp:155
Qty qty
80 this execution, as the venue reported it
Definition record_stream.hpp:130
Timestamp placed_ts
256 the order's first leg went out
Definition record_stream.hpp:152
std::uint32_t amends
376 replaces the venue accepted before the fill
Definition record_stream.hpp:164
Notional position_realized
144
Definition record_stream.hpp:138
QuoteContext order_context
312 the side's context when the working leg went out
Definition record_stream.hpp:162
Notional position_fees
152
Definition record_stream.hpp:139
Timestamp local_ack_ts
280 the same ack, when it reached the engine
Definition record_stream.hpp:156
VenueOrderId venue_order_id
168 -> 209
Definition record_stream.hpp:145
One execution as a strategy sees it (on_fill).
Definition hooks.hpp:56
A funding payment the engine booked (FundingMsg): amount in the instrument's settlement currency,...
Definition record_stream.hpp:204
Notional position_realized
80 the instrument's realized after it
Definition record_stream.hpp:208
Notional amount
64
Definition record_stream.hpp:206
ExecId funding_id
104 -> 145
Definition record_stream.hpp:211
RecordHeader hdr
Definition record_stream.hpp:205
FixedString< 8 > asset
145 -> 154
Definition record_stream.hpp:212
Notional position_funding
88 the instrument's funding after it
Definition record_stream.hpp:209
std::uint8_t pad_[38]
-> 192
Definition record_stream.hpp:213
Qty position_qty
72 the position it was paid on
Definition record_stream.hpp:207
Notional total_funding
96 over every instrument
Definition record_stream.hpp:210
A kill switch trip. hdr.flags & kVenue marks a per-venue trip (hdr.venue names it).
Definition record_stream.hpp:218
RecordHeader hdr
Definition record_stream.hpp:219
std::uint8_t pad_[8]
-> 128
Definition record_stream.hpp:229
Notional unrealized
96
Definition record_stream.hpp:226
std::uint8_t pad0_[3]
-> 68
Definition record_stream.hpp:221
std::uint64_t venue_kills
80
Definition record_stream.hpp:224
std::uint64_t kills
72 global trips so far
Definition record_stream.hpp:223
Notional pnl_carry
112
Definition record_stream.hpp:228
Notional fees
104
Definition record_stream.hpp:227
KillReason reason
64
Definition record_stream.hpp:220
std::uint32_t kill_flags
68 RiskEngine::kill_flags()
Definition record_stream.hpp:222
Notional realized
88
Definition record_stream.hpp:225
An operator's limits command the engine applied (ControlCommand::SetLimits or SetUnderlyingLimit): th...
Definition record_stream.hpp:280
std::int64_t underlying_before
256 kUnderlying: max_net, raw Qty in base units
Definition record_stream.hpp:285
std::uint8_t kind
Definition record_stream.hpp:288
RecordHeader hdr
Definition record_stream.hpp:282
Kind
Definition record_stream.hpp:281
@ kRisk
Definition record_stream.hpp:281
@ kUnderlying
Definition record_stream.hpp:281
std::int64_t underlying_after
264
Definition record_stream.hpp:286
FixedString< 8 > underlying
272 kUnderlying: the base asset
Definition record_stream.hpp:287
std::uint8_t check_balance_after
Definition record_stream.hpp:291
std::uint8_t check_balance_before
Definition record_stream.hpp:290
std::uint8_t pad_[320 - 276 - sizeof(FixedString< 8 >)]
Definition record_stream.hpp:292
RiskLimits after
160
Definition record_stream.hpp:284
RiskLimits before
64
Definition record_stream.hpp:283
std::uint8_t forced
Definition record_stream.hpp:289
The instrument's mid horizon_ms after one of its fills, 0 at the fill ([engine] markout_ms).
Definition record_stream.hpp:383
RecordHeader hdr
Definition record_stream.hpp:384
std::int32_t horizon_ms
88
Definition record_stream.hpp:388
std::uint64_t fill_seq
64 the FillRecord's hdr.seq
Definition record_stream.hpp:385
Price mid
80
Definition record_stream.hpp:387
Timestamp fill_ts
72 the fill's engine time
Definition record_stream.hpp:386
std::uint8_t pad_[36]
-> 128
Definition record_stream.hpp:389
The OMS record after a transition.
Definition record_stream.hpp:181
RecordHeader hdr
Definition record_stream.hpp:182
Order order
Definition record_stream.hpp:183
Definition order.hpp:16
A strategy parameter update the engine applied (ParamUpdateMsg): after the header,...
Definition record_stream.hpp:247
std::uint8_t pad0_[1]
Definition record_stream.hpp:253
std::uint8_t arm
69 ParamUpdateMsg::arm
Definition record_stream.hpp:251
std::uint64_t publish_seq
72
Definition record_stream.hpp:254
RecordHeader hdr
Definition record_stream.hpp:248
ParamUpdateMsg::Origin origin
68
Definition record_stream.hpp:250
char source[ParamUpdateMsg::kSourceLen]
144 NUL-terminated
Definition record_stream.hpp:256
std::int64_t value[ParamUpdateMsg::kMaxFields]
192 raw value of each pair
Definition record_stream.hpp:258
std::uint8_t flags
70 ParamUpdateMsg::flags
Definition record_stream.hpp:252
std::uint32_t count
64 pairs used
Definition record_stream.hpp:249
std::string_view source_view() const noexcept
Definition record_stream.hpp:260
std::uint16_t field[ParamUpdateMsg::kMaxFields]
80 index in the parameter table
Definition record_stream.hpp:255
std::uint8_t pad1_[8]
Definition record_stream.hpp:257
Origin
Definition messages.hpp:802
static constexpr std::size_t kMaxFields
Definition messages.hpp:796
static constexpr std::size_t kSourceLen
source, NUL-terminated
Definition messages.hpp:797
One instrument's position and the portfolio totals at the same instant.
Definition record_stream.hpp:188
Position pos
64 -> 128
Definition record_stream.hpp:190
RecordHeader hdr
Definition record_stream.hpp:189
Notional pnl_carry
152 carried in from earlier sessions (EngineConfig::pnl_carry)
Definition record_stream.hpp:194
Notional total_unrealized
136
Definition record_stream.hpp:192
Notional total_funding
168 over every instrument, part of total_realized
Definition record_stream.hpp:196
Notional funding
160 this instrument's funding so far, part of pos.realized
Definition record_stream.hpp:195
Notional total_fees
144
Definition record_stream.hpp:193
Notional total_realized
128
Definition record_stream.hpp:191
std::uint8_t pad_[16]
-> 192
Definition record_stream.hpp:197
Definition position.hpp:20
Definition order.hpp:72
Definition record_stream.hpp:85
std::uint32_t len
total bytes, a multiple of 64 (offset 0)
Definition record_stream.hpp:96
std::uint64_t seq
record order within the session, from 1 (16)
Definition record_stream.hpp:103
Timestamp wall_ts
wall clock at the same point (32)
Definition record_stream.hpp:105
std::uint8_t pad_[8]
-> 64
Definition record_stream.hpp:111
std::uint8_t flags
(7)
Definition record_stream.hpp:100
Timestamp exch_ts
The venue's time of the event behind the record (a fill: the trade time the venue reported),...
Definition record_stream.hpp:110
RecordType type
(4)
Definition record_stream.hpp:97
std::uint8_t aux[4]
record-specific small fields (12)
Definition record_stream.hpp:102
std::uint64_t session_id
(40)
Definition record_stream.hpp:106
std::uint8_t version
kRecordVersion (5)
Definition record_stream.hpp:98
Flags
Definition record_stream.hpp:86
@ kLate
fill for an order that was already terminal; on an order record, that fill's update of the order (onl...
Definition record_stream.hpp:88
@ kReplayed
funding record: from the venue's history, not its private stream
Definition record_stream.hpp:93
@ kSynthetic
booked by the engine, not reported by the venue (a cum_qty jump)
Definition record_stream.hpp:87
@ kTerminal
the order reached a terminal state with this record
Definition record_stream.hpp:91
@ kVenue
kill record: one venue's switch, not the global one
Definition record_stream.hpp:92
@ kUnknown
fill for an order id the OMS does not know
Definition record_stream.hpp:90
InstrumentId instrument
invalid when the record is not per instrument (8)
Definition record_stream.hpp:101
VenueId venue
(6)
Definition record_stream.hpp:99
Timestamp engine_ts
the engine clock the record was made at (24)
Definition record_stream.hpp:104
One order refused: by the pre-trade checks (the engine's) or by its venue (an OrderReject),...
Definition record_stream.hpp:343
Qty qty
80
Definition record_stream.hpp:359
FixedString< 40 > text
184 the venue's text (OrderRejectMsg::text)
Definition record_stream.hpp:376
Side side
66
Definition record_stream.hpp:355
std::int64_t orders_1d_used
144
Definition record_stream.hpp:368
std::int64_t orders_10s_admits
120
Definition record_stream.hpp:365
RejectReason reason
64
Definition record_stream.hpp:353
std::uint8_t pad0_[2]
Definition record_stream.hpp:375
std::int64_t local_tokens
96 [risk] bucket tokens left (OrderBudget::kUnlimited: off)
Definition record_stream.hpp:361
static constexpr std::int64_t kFoldMaxNs
Definition record_stream.hpp:345
ClientOrderId cl_ord_id
88 the venue's refusals; 0 for a pre-trade one
Definition record_stream.hpp:360
std::uint8_t budget_known
180 the account's connector has published a budget
Definition record_stream.hpp:373
RejectSource source
65
Definition record_stream.hpp:354
std::int64_t weight_used
160
Definition record_stream.hpp:370
std::int64_t local_wait_ns
104
Definition record_stream.hpp:362
std::int64_t orders_1m_used
128
Definition record_stream.hpp:366
std::int64_t weight_admits
168
Definition record_stream.hpp:371
Price price
72
Definition record_stream.hpp:358
std::int64_t orders_10s_used
The account's windows: used and what the connector admits (RateWindow::admits; 0 unknown).
Definition record_stream.hpp:364
Flags
Definition record_stream.hpp:346
@ kFromVenue
an OrderReject, not a pre-trade check
Definition record_stream.hpp:350
@ kReduceOnly
Definition record_stream.hpp:349
@ kReplace
a replace, not a new order
Definition record_stream.hpp:347
@ kReduces
with the open orders on its side, it only takes the position to zero
Definition record_stream.hpp:348
std::uint32_t folded
68 refusals of the same key folded in since the last record
Definition record_stream.hpp:357
std::int64_t orders_1m_admits
136
Definition record_stream.hpp:367
std::int64_t orders_1d_admits
152
Definition record_stream.hpp:369
std::uint8_t pad_[31]
-> 256
Definition record_stream.hpp:377
static constexpr std::int64_t kFoldNs
Definition record_stream.hpp:344
std::int32_t venue_code
176 the venue's error code (OrderRejectMsg::venue_code)
Definition record_stream.hpp:372
std::uint8_t paused
181
Definition record_stream.hpp:374
std::uint8_t flags
67
Definition record_stream.hpp:356
RecordHeader hdr
Definition record_stream.hpp:352
A venue's execution replay ended complete (a reconciliation began with ReconcileMsg::kExecutionsExact...
Definition record_stream.hpp:238
RecordHeader hdr
Definition record_stream.hpp:239
Definition risk_limits.hpp:18
Definition time.hpp:45
Time primitives.