7#include "fastmm/core/fill_audit.hpp"
19struct BookedFillQuery {
28 std::vector<std::string>
columns;
29 std::vector<std::vector<std::string>>
rows;
236 return fail(std::string(
"this store backend has no fill ledger"));
241 return fail(std::string(
"this store backend has no order timeline"));
249 return fail(std::string(
"this store backend cannot list booked fills"));
258 return fail(std::string(
"this store backend keeps no parameter history"));
263 return fail(std::string(
"this store backend keeps no parameter history"));
270 return fail(std::string(
"this store backend keeps no parameter history"));
277 return fail(std::string(
"this store backend keeps no rejects"));
281 return fail(std::string(
"this store backend keeps no rejects"));
285 return fail(std::string(
"this store backend keeps no configuration"));
Storage backend interface: what a session's fills, orders, positions, PnL and kill events are handed ...
Definition reader.hpp:203
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:278
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:264
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:220
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:237
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:282
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:226
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:270
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:286
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:259
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:249
virtual Result< Rows, std::string > pnl(const QueryFilter &f)=0
One row per UTC day and instrument: realised, fees, unrealised, position, settlement currency.
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:242
virtual ~Reader()=default
Minimal expected<T, E>: the hot path never throws, it returns Result.
Definition backend.hpp:39
constexpr Unexpected< std::decay_t< E > > fail(E &&e) noexcept
Definition result.hpp:25
What a backend is built with.
Definition backend.hpp:43
The executions an engine stored for one venue (Reader::booked_fills): the engine's side of a fill aud...
Definition reader.hpp:21
std::string instrument
symbol (empty: every instrument)
Definition reader.hpp:24
std::int64_t from_ms
the venue's time of the trade, inclusive (0: from the beginning)
Definition reader.hpp:25
std::string engine
[engine] name (empty: every engine)
Definition reader.hpp:22
std::string venue
[venues.<name>] (empty: every venue)
Definition reader.hpp:23
std::int64_t to_ms
inclusive (0: to the end)
Definition reader.hpp:26
Every query takes the same filter; a backend ignores the fields its query has no use for.
Definition reader.hpp:37
std::string engine
[engine] name (empty: every engine)
Definition reader.hpp:38
std::uint64_t session_id
0: the newest session that started by at_ns
Definition reader.hpp:39
std::string instrument
symbol: its own values and the shared ones (empty: every scope)
Definition reader.hpp:41
std::int64_t at_ns
wall clock; 0: now (the session's last update)
Definition reader.hpp:40
std::string from
inclusive UTC day, "YYYY-MM-DD" (empty: from the beginning)
Definition reader.hpp:48
std::string engine
[engine] name (empty: every engine)
Definition reader.hpp:45
std::uint64_t session_id
0: every session
Definition reader.hpp:46
std::string to
inclusive UTC day (empty: to the end)
Definition reader.hpp:49
std::string instrument
symbol (empty: every instrument)
Definition reader.hpp:47
std::string order
client order id (order_timeline; empty: none)
Definition reader.hpp:51
std::size_t limit
0: no limit
Definition reader.hpp:50
Executions and funding payments the engine's store holds more than once (Reader::duplicates): a resta...
Definition reader.hpp:188
std::uint32_t copies
Definition reader.hpp:195
std::string side
empty for a funding payment
Definition reader.hpp:193
std::string sessions
the sessions holding it, oldest first, space separated
Definition reader.hpp:194
std::string id
the venue's trade id or funding id
Definition reader.hpp:191
std::string symbol
Definition reader.hpp:190
std::string venue
its [venues.<name>]; "\#<id>" when the store predates schema 3
Definition reader.hpp:189
bool funding
Definition reader.hpp:196
std::string qty
decimal: the execution's quantity, the funding payment's amount
Definition reader.hpp:192
The orders of those sessions that were not terminal at their last record and that the venue had ackno...
Definition reader.hpp:100
std::string cl_ord_id
Definition reader.hpp:104
std::string symbol
Definition reader.hpp:102
std::string venue
its [venues.<name>]; empty when the store predates schema 3
Definition reader.hpp:101
std::string venue_order_id
Definition reader.hpp:103
The positions a session carries over (fastmm-live restores them before it connects; see Venue::resume...
Definition reader.hpp:83
std::string symbol
Definition reader.hpp:86
std::int64_t qty_raw
Definition reader.hpp:87
std::int64_t avg_px_raw
Definition reader.hpp:88
std::uint8_t venue_id
in the session that recorded it
Definition reader.hpp:84
std::string venue
its [venues.<name>]; empty when the store predates schema 3
Definition reader.hpp:85
The highest numeric trade id per (venue, symbol) the store holds up to the newest session that got pa...
Definition reader.hpp:157
std::string venue
empty when the store predates schema 3
Definition reader.hpp:159
std::vector< std::int64_t > known_after
ascending
Definition reader.hpp:162
std::uint8_t venue_id
Definition reader.hpp:158
std::int64_t last_id
Definition reader.hpp:161
std::string symbol
Definition reader.hpp:160
Definition reader.hpp:140
std::int64_t since_ms
the replay's start, venue time, inclusive
Definition reader.hpp:145
bool shrunk
since_ms moved later than last_fill_ms - kResumeOverlapMs
Definition reader.hpp:148
std::uint8_t venue_id
the session's VenueId
Definition reader.hpp:141
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:147
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:144
std::string venue
its [venues.
Definition reader.hpp:142
What the previous session left behind, for the operator who is about to start a new one.
Definition reader.hpp:55
std::vector< Duplicate > duplicates
Definition reader.hpp:199
std::vector< std::string > journals
Definition reader.hpp:73
static constexpr std::size_t kMaxPastOrders
Definition reader.hpp:106
bool clean_shutdown
Definition reader.hpp:63
std::uint64_t fills
Definition reader.hpp:70
std::uint64_t records_dropped
Definition reader.hpp:71
std::string started_utc
Definition reader.hpp:58
std::vector< std::uint16_t > session_epochs
Definition reader.hpp:95
std::int64_t fallback_since_ms
0: no replay
Definition reader.hpp:174
std::vector< VenueResume > venue_resume
One entry per venue that recorded a fill with a venue time.
Definition reader.hpp:151
bool found
Definition reader.hpp:56
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:134
std::vector< std::string > fallback_exec_ids
of every session that ran inside kFallbackIdsNs
Definition reader.hpp:175
std::vector< TradeIdMark > last_trade_ids
Definition reader.hpp:164
std::string stopped_utc
empty: the session never recorded a close (it was killed)
Definition reader.hpp:59
std::string unrealized
Definition reader.hpp:67
std::string fees
Definition reader.hpp:68
std::vector< PositionState > position_state
Definition reader.hpp:90
std::string funding
the part of realized that is funding (schema 4; "0" before)
Definition reader.hpp:66
std::string net
Definition reader.hpp:69
std::uint64_t duplicate_count
Definition reader.hpp:200
std::string kill_reason
Definition reader.hpp:61
bool journal_complete
Definition reader.hpp:72
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:94
bool kill_latched
Definition reader.hpp:62
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:139
std::vector< std::string > positions
"SYMBOL qty \@ avg_px realized=... fees=..." per instrument with a position or a fill.
Definition reader.hpp:75
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:171
std::string strategy
Definition reader.hpp:60
static constexpr std::size_t kMaxDuplicates
Definition reader.hpp:198
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:77
std::vector< PastOrder > past_orders
Definition reader.hpp:107
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:182
static constexpr std::int64_t kFallbackIdsNs
Definition reader.hpp:172
std::string realized
decimal, settlement currency
Definition reader.hpp:65
std::uint64_t session_id
Definition reader.hpp:57
int exit_code
Definition reader.hpp:64
std::int64_t last_fill_ns
engine time of the newest session's last fill (0: none)
Definition reader.hpp:173
std::vector< std::string > columns
Definition reader.hpp:30
std::vector< std::vector< std::string > > rows
Definition reader.hpp:31
bool empty() const noexcept
Definition reader.hpp:32