FastMM documentation
FastMM C++ API 0.14.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
reader.hpp
Go to the documentation of this file.
1#pragma once
2// Query side of a storage backend: what fastmm-pnl and a restarting session read back.
3//
4// Rows are strings. The store is queried by people and by tools, never on a hot path, and a
5// string column keeps the interface small enough for a backend to implement in an afternoon;
6// raw fixed-point columns are rendered as exact decimals (Fixed::to_string).
7#include "fastmm/core/fill_audit.hpp"
9#include "fastmm/store/ab_readout.hpp"
11
12#include <cstdint>
13#include <string>
14#include <vector>
15
16namespace fastmm::store {
17
18// The executions an engine stored for one venue (Reader::booked_fills): the engine's side of a
19// fill audit (core/fill_audit.hpp).
20struct BookedFillQuery {
21 std::string engine; // [engine] name (empty: every engine)
22 std::string venue; // [venues.<name>] (empty: every venue)
23 std::string instrument; // symbol (empty: every instrument)
24 std::int64_t from_ms = 0; // the venue's time of the trade, inclusive (0: from the beginning)
25 std::int64_t to_ms = 0; // inclusive (0: to the end)
26};
28struct Rows {
29 std::vector<std::string> columns;
30 std::vector<std::vector<std::string>> rows;
31 [[nodiscard]] bool empty() const noexcept { return rows.empty(); }
32};
34// Every query takes the same filter; a backend ignores the fields its query has no use for.
35// Which session, and when in it, for the parameter queries.
36struct ParamQuery {
37 std::string engine; // [engine] name (empty: every engine)
38 std::uint64_t session_id = 0; // 0: the newest session that started by at_ns
39 std::int64_t at_ns = 0; // wall clock; 0: now (the session's last update)
40 std::string instrument; // symbol: its own values and the shared ones (empty: every scope)
41};
43struct QueryFilter {
44 std::string engine; // [engine] name (empty: every engine)
45 std::uint64_t session_id = 0; // 0: every session
46 std::string instrument; // symbol (empty: every instrument)
47 std::string from; // inclusive UTC day, "YYYY-MM-DD" (empty: from the beginning)
48 std::string to; // inclusive UTC day (empty: to the end)
49 std::size_t limit = 0; // 0: no limit
50 std::string order; // client order id (order_timeline; empty: none)
51};
53// What the previous session left behind, for the operator who is about to start a new one.
54struct Recovery {
55 bool found = false;
56 std::uint64_t session_id = 0;
57 std::string started_utc;
58 std::string stopped_utc; // empty: the session never recorded a close (it was killed)
59 std::string strategy;
60 std::string kill_reason;
61 bool kill_latched = false;
62 // The newest session ended on a max-loss trip: it shut down with the trip latched, or it never
63 // recorded a shutdown and its kill events hold a global MaxLoss. fastmm-live refuses to start on
64 // it when [engine] kill_file is missing.
65 bool max_loss_tripped = false;
66 bool clean_shutdown = false;
67 int exit_code = 0;
68 std::string realized; // decimal, settlement currency
69 std::string funding; // the part of realized that is funding (schema 4; "0" before)
70 std::string unrealized;
71 std::string fees;
72 std::string net;
73 std::uint64_t fills = 0;
74 std::uint64_t records_dropped = 0;
75 bool journal_complete = true;
76 std::vector<std::string> journals;
77 // "SYMBOL qty @ avg_px realized=... fees=..." per instrument with a position or a fill.
78 std::vector<std::string> positions;
79 // "cl_ord_id SYMBOL side qty @ price state" per order that was not terminal at the last record.
80 std::vector<std::string> open_orders;
81
82 // The positions a session carries over (fastmm-live restores them before it connects; see
83 // Venue::resume_executions): per venue and symbol, the last one the engine's store holds, from
84 // this session or, for a venue and symbol it recorded nothing about (it crashed first), the
85 // newest earlier session that did. Two venues can list the same symbol.
86 struct PositionState {
87 std::uint8_t venue_id = 0; // in the session that recorded it
88 std::string venue; // its [venues.<name>]; empty when the store predates schema 3
89 std::string symbol;
90 std::int64_t qty_raw = 0;
91 std::int64_t avg_px_raw = 0;
92 };
93 std::vector<PositionState> position_state;
94 // The session epochs (the high bits of their client order ids) of the sessions a restart carries
95 // over, newest first, at most kMaxSessionEpochs: behind fastmm-gateway, executions of their
96 // orders are this engine's, whichever session placed them.
97 static constexpr std::size_t kMaxSessionEpochs = 64;
98 std::vector<std::uint16_t> session_epochs;
99 // The orders of those sessions that were not terminal at their last record and that the venue
100 // had acknowledged (a venue order id), newest first, at most kMaxPastOrders. A venue's trade
101 // history can name an execution by the venue's order id alone (Binance); behind fastmm-gateway,
102 // after a gateway restart, only this store can say whose order that was.
103 struct PastOrder {
104 std::string venue; // its [venues.<name>]; empty when the store predates schema 3
105 std::string symbol;
106 std::string venue_order_id;
107 std::string cl_ord_id;
108 };
109 static constexpr std::size_t kMaxPastOrders = 256;
110 std::vector<PastOrder> past_orders;
111 // Where each venue's execution replay resumes (Venue::resume_executions): from the venue time of
112 // the last fill or funding payment the store holds for it (in the newest session that stored
113 // one), minus kResumeOverlapMs, skipping the trade ids and funding ids (kFundingIdPrefix + id)
114 // the store holds from there on. The funding replay starts there too, so a payment made while no
115 // session ran is booked by the next one. Both ends are the venue's clock, so the engine's clock
116 // (which follows the host's and may be seconds off, a WSL2 clock step) does not enter.
117 //
118 // The ids are those of every session of the engine, not of the session the start comes from: a
119 // session killed seconds after it started stores only what its own replay booked, and the next
120 // replay's window still reaches the executions the sessions before it stored. An execution the
121 // store holds, in whichever session, is never handed to a replay as new.
122 //
123 // The start is where the record is known to be whole: the last fill stored up to the newest
124 // session that got past its own replay on the venue (the store records a reconciliation that
125 // began with the venue's executions complete, schema 6; a session from before that counts when it
126 // placed an order there - none goes out before the venue has reconciled - or shut down cleanly).
127 // A session after that one died while its replay was still reading, and can hold a fill newer
128 // than one the replay had not reached: its fills are known, and the start is not later than the
129 // earliest of their last ones. When no session at all got past its replay the start is no later
130 // than unbooked_since_ms.
131 //
132 // The overlap covers one thing: the order in which a venue publishes executions against their
133 // trade times. Executions of different symbols (and a Bybit batch, a Deribit per-instrument
134 // channel) can reach the store out of trade-time order; a restart must not skip one that traded
135 // just before the last stored fill but had not arrived when the process stopped. That spread is
136 // milliseconds to a few hundred; 1 s covers it with margin.
137 static constexpr std::int64_t kResumeOverlapMs = 1000;
138 // The most trade ids a venue's resume carries (the gateway's attach request holds
139 // gw::kMaxKnownExecIds over all its venues). A venue with more stored fills inside the overlap
140 // has its start moved later, past the oldest millisecond that does not fit whole, and
141 // VenueResume::shrunk says so: dropping an id instead would book that execution twice.
142 static constexpr std::size_t kMaxKnownExecIds = 128;
143 struct VenueResume {
144 std::uint8_t venue_id = 0; // the session's VenueId
145 std::string venue; // its [venues.<name>]; empty when the store predates schema 3
146 // Venue time of the stored fill or funding payment the start is taken from (see above).
147 std::int64_t last_fill_ms = 0;
148 std::int64_t since_ms = 0; // the replay's start, venue time, inclusive
149 // Stored fills and funding at or after since_ms, of every session of the engine.
150 std::vector<std::string> known_exec_ids;
151 bool shrunk = false; // since_ms moved later than last_fill_ms - kResumeOverlapMs
152 };
153 // One entry per venue that recorded a fill with a venue time.
154 std::vector<VenueResume> venue_resume;
155 // The highest numeric trade id per (venue, symbol) the store holds up to the newest session that
156 // got past its replay on the venue (see above), and the ids above it that the sessions after
157 // that one stored. Binance trade ids increase per symbol, so its replay resumes at last_id + 1
158 // exactly and skips known_after (Venue::resume_trade_ids). No entry for a venue no session got
159 // past its replay on: it replays by time.
160 struct TradeIdMark {
161 std::uint8_t venue_id = 0;
162 std::string venue; // empty when the store predates schema 3
163 std::string symbol;
164 std::int64_t last_id = 0;
165 std::vector<std::int64_t> known_after; // ascending
166 };
167 std::vector<TradeIdMark> last_trade_ids;
168
169 // The fallback for a venue with no entry above (a store from before schema 3, or a venue whose
170 // fills carry no venue time): the engine clock, as before. The replay starts kFallbackOverlapNs
171 // before the session's last fill, and the ids reach kFallbackIdsNs back, further than the start,
172 // because the start is local time and the venue compares it with its own. At most
173 // kMaxKnownExecIds, with the start moved later when more fall inside.
174 static constexpr std::int64_t kFallbackOverlapNs = 10'000'000'000; // 10 s
175 static constexpr std::int64_t kFallbackIdsNs = 2 * kFallbackOverlapNs;
176 std::int64_t last_fill_ns = 0; // engine time of the newest session's last fill (0: none)
177 std::int64_t fallback_since_ms = 0; // 0: no replay
178 std::vector<std::string> fallback_exec_ids; // of every session that ran inside kFallbackIdsNs
180 // Where the replay of a venue with no stored fill starts (no venue_resume entry, in a store
181 // whose fills carry the venue's time or that holds none): the start of the newest session that
182 // shut down cleanly, else of the oldest session, less kFallbackOverlapNs, engine clock. Whatever
183 // the venue executed since is unbooked: a fill of a session that crashed before storing it, or
184 // one made while nothing ran.
185 std::int64_t unbooked_since_ms = 0;
186
187 // Executions and funding payments the engine's store holds more than once (Reader::duplicates):
188 // a restart booked them a second time, so the positions and the PnL of the sessions holding the
189 // copies count them twice. Reported, never repaired: the rows stay as they were written. At most
190 // kMaxDuplicates are listed; duplicate_count is how many there are.
191 struct Duplicate {
192 std::string venue; // its [venues.<name>]; "#<id>" when the store predates schema 3
193 std::string symbol;
194 std::string id; // the venue's trade id or funding id
195 std::string qty; // decimal: the execution's quantity, the funding payment's amount
196 std::string side; // empty for a funding payment
197 std::string sessions; // the sessions holding it, oldest first, space separated
198 std::uint32_t copies = 0;
199 bool funding = false;
200 };
201 static constexpr std::size_t kMaxDuplicates = 32;
202 std::vector<Duplicate> duplicates;
203 std::uint64_t duplicate_count = 0;
204 // The executions the newest session stored a copy of though the store already held one (or
205 // stored twice itself), per venue and symbol: that session's last position (position_state)
206 // counts them more than once. Funding is left out: it moves the PnL, not the position.
207 struct DoubleBooked {
208 std::string venue; // its [venues.<name>]; "#<id>" when the store predates schema 3
209 std::string symbol;
210 std::uint64_t executions = 0;
211 };
212 std::vector<DoubleBooked> double_booked;
213};
215class Reader {
216 public:
217 Reader() = default;
218 virtual ~Reader() = default;
219 Reader(const Reader&) = delete;
220 Reader& operator=(const Reader&) = delete;
222 [[nodiscard]] virtual Result<void, std::string> open(const BackendOptions& opts) = 0;
223 // One row per session: id, engine, strategy, start, stop, PnL, fills, exit.
224 [[nodiscard]] virtual Result<Rows, std::string> sessions(const QueryFilter& f) = 0;
225 // One row per execution.
226 [[nodiscard]] virtual Result<Rows, std::string> fills(const QueryFilter& f) = 0;
227 // One row per order, in its last known state.
228 [[nodiscard]] virtual Result<Rows, std::string> orders(const QueryFilter& f) = 0;
229 // One row per UTC day, account and symbol: realised (funding included, `funding` says how much),
230 // fees, net, the quantity traded, the executions and the estimates it counts, in the settlement
231 // currency. Recomputed from the stored fills at average cost, so that an execution counts once
232 // however many records hold it (a copy another session stored, a repeat the engine booked again,
233 // fill_repeats), an estimate (a synthetic fill) counts only for what no execution named since,
234 // and a position carries from one session to the next by the name of the account holding it.
235 // `estimates`: the synthetic fills no execution has named, still counted at the order's price
236 // and no fee. `books_net`: the engine's own net for the day (books_pnl), for comparison. A
237 // backend or a store that cannot recompute it answers with books_pnl.
238 [[nodiscard]] virtual Result<Rows, std::string> pnl(const QueryFilter& f) = 0;
239 // The engine's day roll-up of its own position records, as it booked them: one row per UTC day,
240 // account and symbol. The default is pnl().
241 [[nodiscard]] virtual Result<Rows, std::string> books_pnl(const QueryFilter& f) { return pnl(f); }
242 // fastmm-pnl ab: the fills, markouts and arm assignments of the [ab] test `test` (empty: the
243 // newest session's) in the sessions and days `f` names (ab_readout.hpp).
244 [[nodiscard]] virtual Result<AbData, std::string> ab_data(const QueryFilter& /*f*/,
245 const std::string& /*test*/) {
246 return fail(std::string("this storage backend does not read [ab] tests"));
247 }
248 // One row per funding payment. The default has none (a backend without the table).
249 [[nodiscard]] virtual Result<Rows, std::string> funding(const QueryFilter& /*f*/) {
250 return Rows{};
252 // One row per venue execution or funding payment stored more than once (by venue, symbol and
253 // the venue's id of it, within an engine): what a restart booked a second time. Empty in a
254 // sound store; the default has none. Filtered by engine and instrument.
255 [[nodiscard]] virtual Result<Rows, std::string> duplicates(const QueryFilter& /*f*/) {
256 return Rows{};
258 // The economic fill ledger: one row per execution (the venue's id of it on an account, symbol
259 // and side, within an engine) however many sessions stored it, as the first one did, with when
260 // it was first received, the venue's time, the quantity the position took (booked), how many
261 // copies there are and its flags (synthetic: booked from a cum_qty jump, no venue report; late:
262 // for an order already ended; before_start: traded before the session that booked it started,
263 // so it came in through the restart's replay; repeated: stored more than once). `raw` lists
264 // every stored row instead, with its copy number. A session filter keeps the executions it
265 // booked first (raw: its rows). The default cannot answer.
266 [[nodiscard]] virtual Result<Rows, std::string> ledger(const QueryFilter& /*f*/, bool /*raw*/) {
267 return fail(std::string("this store backend has no fill ledger"));
269 // One row per execution with its decision record (schema 16): the order's state when the fill
270 // arrived, when it was placed and at what price, when its working leg went out (`sent`; after
271 // `amends` accepted replaces) and was acknowledged, how long it had rested, the cancel or replace
272 // in flight and for how long, and the strategy's quote context when the order went out and when
273 // the fill arrived. The context columns are named after the session's quote_context_names
274 // (sent_<name>, fill_<name>; ctx0..ctx3 where the sessions shown name them differently or not at
275 // all); a value no row has is left out. Filtered like fills(); also by `f.order`. The default
276 // cannot answer.
277 [[nodiscard]] virtual Result<Rows, std::string> fill_context(const QueryFilter& /*f*/) {
278 return fail(std::string("this store backend keeps no fill decision records"));
280 // Everything stored about one client order (`f.order`), in time order: sent, each refusal, each
281 // execution, and its last known state. The default cannot answer.
282 [[nodiscard]] virtual Result<Rows, std::string> order_timeline(const QueryFilter& /*f*/) {
283 return fail(std::string("this store backend has no order timeline"));
285 // The executions stored for `q.venue`, of every session of `q.engine`, by the venue's time of the
286 // trade: the venue's trade id, order ids, side, price, quantity and the commission as reported
287 // (AuditFill::fee_asset: quote, base or other). Estimates (no trade id) are left out. Needs the
288 // venue's names and times (schema 3); the default cannot answer.
289 [[nodiscard]] virtual Result<std::vector<AuditFill>, std::string> booked_fills(
290 const BookedFillQuery& /*q*/) {
291 return fail(std::string("this store backend cannot list booked fills"));
292 }
293 // The last position snapshot per session and instrument.
294 [[nodiscard]] virtual Result<Rows, std::string> positions(const QueryFilter& f) = 0;
295 // The strategy parameters in effect at `q.at_ns` (0: the session's last update) in the session
296 // `q.session_id`, else the newest of `q.engine` that started by then: one row per parameter and
297 // scope (every instrument, or one that has its own value), with when it was set, its origin
298 // (initial, control, strategy) and source. Needs schema 8; the default cannot answer.
299 [[nodiscard]] virtual Result<Rows, std::string> params(const ParamQuery& /*q*/) {
300 return fail(std::string("this store backend keeps no parameter history"));
302 // Every parameter update, one row per value it carried, in order: the starting set (origin
303 // initial) and each update the engine applied. Filtered by engine, session, day and instrument.
304 [[nodiscard]] virtual Result<Rows, std::string> param_changes(const QueryFilter& /*f*/) {
305 return fail(std::string("this store backend keeps no parameter history"));
307 // The parameters session `a` ended with against those session `b` started with: one row per
308 // parameter and scope that differs. `a` 0: the session of b's engine that started last before b
309 // (what a restart changed).
310 [[nodiscard]] virtual Result<Rows, std::string> param_diff(std::uint64_t /*a*/,
311 std::uint64_t /*b*/) {
312 return fail(std::string("this store backend keeps no parameter history"));
313 }
314 // One row per refused order the engine recorded (`count` with the ones folded into it): when,
315 // which account, instrument and side, whether it only reduced the position, the reason, the
316 // limit or side that refused it (source) and the account's budget then. Filtered by engine,
317 // session, day and instrument. Needs schema 9.
318 [[nodiscard]] virtual Result<Rows, std::string> rejects(const QueryFilter& /*f*/) {
319 return fail(std::string("this store backend keeps no rejects"));
321 // Every risk limit change an operator made at run time (fastmm-ctl limits), one row per key:
322 // when, the session, the key, its value before and after, and whether --force turned it off.
323 // Filtered by engine, session and day. Needs schema 11.
324 [[nodiscard]] virtual Result<Rows, std::string> limit_changes(const QueryFilter& /*f*/) {
325 return fail(std::string("this store backend keeps no limit changes"));
327 // The same summed: one row per account, instrument, side, reduces, reason and source.
328 [[nodiscard]] virtual Result<Rows, std::string> reject_summary(const QueryFilter& /*f*/) {
329 return fail(std::string("this store backend keeps no rejects"));
331 // The effective configuration (TOML, secrets omitted) of the session `q` picks as params() does.
332 [[nodiscard]] virtual Result<std::string, std::string> session_config(const ParamQuery& /*q*/) {
333 return fail(std::string("this store backend keeps no configuration"));
335 // The newest session of `f.engine`, summarised.
336 [[nodiscard]] virtual Result<Recovery, std::string> recovery(const QueryFilter& f) = 0;
337};
339} // namespace fastmm::store
Storage backend interface: what a session's fills, orders, positions, PnL and kill events are handed ...
Definition result.hpp:30
Definition reader.hpp:217
virtual Result< Rows, std::string > rejects(const QueryFilter &)
One row per refused order the engine recorded (count with the ones folded into it): when,...
Definition reader.hpp:320
virtual Result< Rows, std::string > param_changes(const QueryFilter &)
Every parameter update, one row per value it carried, in order: the starting set (origin initial) and...
Definition reader.hpp:306
virtual Result< Rows, std::string > funding(const QueryFilter &)
One row per funding payment. The default has none (a backend without the table).
Definition reader.hpp:251
virtual Result< Rows, std::string > ledger(const QueryFilter &, bool)
The economic fill ledger: one row per execution (the venue's id of it on an account,...
Definition reader.hpp:268
Reader & operator=(const Reader &)=delete
virtual Result< Rows, std::string > fills(const QueryFilter &f)=0
One row per execution.
virtual Result< Rows, std::string > reject_summary(const QueryFilter &)
The same summed: one row per account, instrument, side, reduces, reason and source.
Definition reader.hpp:330
virtual Result< Recovery, std::string > recovery(const QueryFilter &f)=0
The newest session of f.engine, summarised.
virtual Result< Rows, std::string > duplicates(const QueryFilter &)
One row per venue execution or funding payment stored more than once (by venue, symbol and the venue'...
Definition reader.hpp:257
virtual Result< Rows, std::string > positions(const QueryFilter &f)=0
The last position snapshot per session and instrument.
virtual Result< Rows, std::string > param_diff(std::uint64_t, std::uint64_t)
The parameters session a ended with against those session b started with: one row per parameter and s...
Definition reader.hpp:312
virtual Result< std::string, std::string > session_config(const ParamQuery &)
The effective configuration (TOML, secrets omitted) of the session q picks as params() does.
Definition reader.hpp:334
virtual Result< Rows, std::string > books_pnl(const QueryFilter &f)
The engine's day roll-up of its own position records, as it booked them: one row per UTC day,...
Definition reader.hpp:243
virtual Result< Rows, std::string > params(const ParamQuery &)
The strategy parameters in effect at q.at_ns (0: the session's last update) in the session q....
Definition reader.hpp:301
virtual Result< std::vector< AuditFill >, std::string > booked_fills(const BookedFillQuery &)
The executions stored for q.venue, of every session of q.engine, by the venue's time of the trade: th...
Definition reader.hpp:291
virtual Result< Rows, std::string > pnl(const QueryFilter &f)=0
One row per UTC day, account and symbol: realised (funding included, funding says how much),...
virtual Result< Rows, std::string > limit_changes(const QueryFilter &)
Every risk limit change an operator made at run time (fastmm-ctl limits), one row per key: when,...
Definition reader.hpp:326
virtual Result< Rows, std::string > sessions(const QueryFilter &f)=0
One row per session: id, engine, strategy, start, stop, PnL, fills, exit.
virtual Result< Rows, std::string > orders(const QueryFilter &f)=0
One row per order, in its last known state.
virtual Result< void, std::string > open(const BackendOptions &opts)=0
virtual Result< Rows, std::string > order_timeline(const QueryFilter &)
Everything stored about one client order (f.order), in time order: sent, each refusal,...
Definition reader.hpp:284
virtual Result< Rows, std::string > fill_context(const QueryFilter &)
One row per execution with its decision record (schema 16): the order's state when the fill arrived,...
Definition reader.hpp:279
virtual Result< AbData, std::string > ab_data(const QueryFilter &, const std::string &)
fastmm-pnl ab: the fills, markouts and arm assignments of the [ab] test test (empty: the newest sessi...
Definition reader.hpp:246
virtual ~Reader()=default
Minimal expected<T, E>: the hot path never throws, it returns Result.
Definition backend.hpp:40
constexpr Unexpected< std::decay_t< E > > fail(E &&e) noexcept
Definition result.hpp:25
What a backend is built with.
Definition backend.hpp:44
The executions an engine stored for one venue (Reader::booked_fills): the engine's side of a fill aud...
Definition reader.hpp:22
std::string instrument
symbol (empty: every instrument)
Definition reader.hpp:25
std::int64_t from_ms
the venue's time of the trade, inclusive (0: from the beginning)
Definition reader.hpp:26
std::string engine
[engine] name (empty: every engine)
Definition reader.hpp:23
std::string venue
[venues.<name>] (empty: every venue)
Definition reader.hpp:24
std::int64_t to_ms
inclusive (0: to the end)
Definition reader.hpp:27
Every query takes the same filter; a backend ignores the fields its query has no use for.
Definition reader.hpp:38
std::string engine
[engine] name (empty: every engine)
Definition reader.hpp:39
std::uint64_t session_id
0: the newest session that started by at_ns
Definition reader.hpp:40
std::string instrument
symbol: its own values and the shared ones (empty: every scope)
Definition reader.hpp:42
std::int64_t at_ns
wall clock; 0: now (the session's last update)
Definition reader.hpp:41
Definition reader.hpp:45
std::string from
inclusive UTC day, "YYYY-MM-DD" (empty: from the beginning)
Definition reader.hpp:49
std::string engine
[engine] name (empty: every engine)
Definition reader.hpp:46
std::uint64_t session_id
0: every session
Definition reader.hpp:47
std::string to
inclusive UTC day (empty: to the end)
Definition reader.hpp:50
std::string instrument
symbol (empty: every instrument)
Definition reader.hpp:48
std::string order
client order id (order_timeline; empty: none)
Definition reader.hpp:52
std::size_t limit
0: no limit
Definition reader.hpp:51
The executions the newest session stored a copy of though the store already held one (or stored twice...
Definition reader.hpp:209
std::uint64_t executions
Definition reader.hpp:212
std::string venue
its [venues.<name>]; "\#<id>" when the store predates schema 3
Definition reader.hpp:210
std::string symbol
Definition reader.hpp:211
Executions and funding payments the engine's store holds more than once (Reader::duplicates): a resta...
Definition reader.hpp:193
std::uint32_t copies
Definition reader.hpp:200
std::string side
empty for a funding payment
Definition reader.hpp:198
std::string sessions
the sessions holding it, oldest first, space separated
Definition reader.hpp:199
std::string id
the venue's trade id or funding id
Definition reader.hpp:196
std::string symbol
Definition reader.hpp:195
std::string venue
its [venues.<name>]; "\#<id>" when the store predates schema 3
Definition reader.hpp:194
bool funding
Definition reader.hpp:201
std::string qty
decimal: the execution's quantity, the funding payment's amount
Definition reader.hpp:197
The orders of those sessions that were not terminal at their last record and that the venue had ackno...
Definition reader.hpp:105
std::string cl_ord_id
Definition reader.hpp:109
std::string symbol
Definition reader.hpp:107
std::string venue
its [venues.<name>]; empty when the store predates schema 3
Definition reader.hpp:106
std::string venue_order_id
Definition reader.hpp:108
The positions a session carries over (fastmm-live restores them before it connects; see Venue::resume...
Definition reader.hpp:88
std::string symbol
Definition reader.hpp:91
std::int64_t qty_raw
Definition reader.hpp:92
std::int64_t avg_px_raw
Definition reader.hpp:93
std::uint8_t venue_id
in the session that recorded it
Definition reader.hpp:89
std::string venue
its [venues.<name>]; empty when the store predates schema 3
Definition reader.hpp:90
The highest numeric trade id per (venue, symbol) the store holds up to the newest session that got pa...
Definition reader.hpp:162
std::string venue
empty when the store predates schema 3
Definition reader.hpp:164
std::vector< std::int64_t > known_after
ascending
Definition reader.hpp:167
std::uint8_t venue_id
Definition reader.hpp:163
std::int64_t last_id
Definition reader.hpp:166
std::string symbol
Definition reader.hpp:165
Definition reader.hpp:145
std::int64_t since_ms
the replay's start, venue time, inclusive
Definition reader.hpp:150
bool shrunk
since_ms moved later than last_fill_ms - kResumeOverlapMs
Definition reader.hpp:153
std::uint8_t venue_id
the session's VenueId
Definition reader.hpp:146
std::vector< std::string > known_exec_ids
Stored fills and funding at or after since_ms, of every session of the engine.
Definition reader.hpp:152
std::int64_t last_fill_ms
Venue time of the stored fill or funding payment the start is taken from (see above).
Definition reader.hpp:149
std::string venue
its [venues.
Definition reader.hpp:147
What the previous session left behind, for the operator who is about to start a new one.
Definition reader.hpp:56
std::vector< Duplicate > duplicates
Definition reader.hpp:204
std::vector< std::string > journals
Definition reader.hpp:78
static constexpr std::size_t kMaxPastOrders
Definition reader.hpp:111
bool clean_shutdown
Definition reader.hpp:68
std::uint64_t fills
Definition reader.hpp:75
std::uint64_t records_dropped
Definition reader.hpp:76
std::string started_utc
Definition reader.hpp:59
std::vector< DoubleBooked > double_booked
Definition reader.hpp:214
std::vector< std::uint16_t > session_epochs
Definition reader.hpp:100
std::int64_t fallback_since_ms
0: no replay
Definition reader.hpp:179
std::vector< VenueResume > venue_resume
One entry per venue that recorded a fill with a venue time.
Definition reader.hpp:156
bool found
Definition reader.hpp:57
bool max_loss_tripped
The newest session ended on a max-loss trip: it shut down with the trip latched, or it never recorded...
Definition reader.hpp:67
static constexpr std::int64_t kResumeOverlapMs
Where each venue's execution replay resumes (Venue::resume_executions): from the venue time of the la...
Definition reader.hpp:139
std::vector< std::string > fallback_exec_ids
of every session that ran inside kFallbackIdsNs
Definition reader.hpp:180
std::vector< TradeIdMark > last_trade_ids
Definition reader.hpp:169
std::string stopped_utc
empty: the session never recorded a close (it was killed)
Definition reader.hpp:60
std::string unrealized
Definition reader.hpp:72
std::string fees
Definition reader.hpp:73
std::vector< PositionState > position_state
Definition reader.hpp:95
std::string funding
the part of realized that is funding (schema 4; "0" before)
Definition reader.hpp:71
std::string net
Definition reader.hpp:74
std::uint64_t duplicate_count
Definition reader.hpp:205
std::string kill_reason
Definition reader.hpp:62
bool journal_complete
Definition reader.hpp:77
static constexpr std::size_t kMaxSessionEpochs
The session epochs (the high bits of their client order ids) of the sessions a restart carries over,...
Definition reader.hpp:99
bool kill_latched
Definition reader.hpp:63
static constexpr std::size_t kMaxKnownExecIds
The most trade ids a venue's resume carries (the gateway's attach request holds gw::kMaxKnownExecIds ...
Definition reader.hpp:144
std::vector< std::string > positions
"SYMBOL qty \@ avg_px realized=... fees=..." per instrument with a position or a fill.
Definition reader.hpp:80
static constexpr std::int64_t kFallbackOverlapNs
The fallback for a venue with no entry above (a store from before schema 3, or a venue whose fills ca...
Definition reader.hpp:176
std::string strategy
Definition reader.hpp:61
static constexpr std::size_t kMaxDuplicates
Definition reader.hpp:203
std::vector< std::string > open_orders
"cl_ord_id SYMBOL side qty \@ price state" per order that was not terminal at the last record.
Definition reader.hpp:82
std::vector< PastOrder > past_orders
Definition reader.hpp:112
std::int64_t unbooked_since_ms
Where the replay of a venue with no stored fill starts (no venue_resume entry, in a store whose fills...
Definition reader.hpp:187
static constexpr std::int64_t kFallbackIdsNs
Definition reader.hpp:177
std::string realized
decimal, settlement currency
Definition reader.hpp:70
std::uint64_t session_id
Definition reader.hpp:58
int exit_code
Definition reader.hpp:69
std::int64_t last_fill_ns
engine time of the newest session's last fill (0: none)
Definition reader.hpp:178
Definition reader.hpp:30
std::vector< std::string > columns
Definition reader.hpp:31
std::vector< std::vector< std::string > > rows
Definition reader.hpp:32
bool empty() const noexcept
Definition reader.hpp:33