|
FastMM C++ API 0.6.0
Public headers, tier 1 and tier 2
|
What the previous session left behind, for the operator who is about to start a new one. More...
#include <fastmm/store/reader.hpp>
Classes | |
| struct | Duplicate |
| Executions and funding payments the engine's store holds more than once (Reader::duplicates): a restart booked them a second time, so the positions and the PnL of the sessions holding the copies count them twice. More... | |
| struct | PastOrder |
| The orders of those sessions that were not terminal at their last record and that the venue had acknowledged (a venue order id), newest first, at most kMaxPastOrders. More... | |
| struct | PositionState |
| The positions a session carries over (fastmm-live restores them before it connects; see Venue::resume_executions): per venue and symbol, the last one the engine's store holds, from this session or, for a venue and symbol it recorded nothing about (it crashed first), the newest earlier session that did. More... | |
| struct | TradeIdMark |
| The highest numeric trade id per (venue, symbol) the store holds up to the newest session that got past its replay on the venue (see above), and the ids above it that the sessions after that one stored. More... | |
| struct | VenueResume |
Public Attributes | |
| bool | found = false |
| std::uint64_t | session_id = 0 |
| std::string | started_utc |
| std::string | stopped_utc |
| empty: the session never recorded a close (it was killed) | |
| std::string | strategy |
| std::string | kill_reason |
| bool | kill_latched = false |
| bool | clean_shutdown = false |
| int | exit_code = 0 |
| std::string | realized |
| decimal, settlement currency | |
| std::string | funding |
| the part of realized that is funding (schema 4; "0" before) | |
| std::string | unrealized |
| std::string | fees |
| std::string | net |
| std::uint64_t | fills = 0 |
| std::uint64_t | records_dropped = 0 |
| bool | journal_complete = true |
| std::vector< std::string > | journals |
| std::vector< std::string > | positions |
| "SYMBOL qty \@ avg_px realized=... fees=..." per instrument with a position or a fill. | |
| std::vector< std::string > | open_orders |
| "cl_ord_id SYMBOL side qty \@ price state" per order that was not terminal at the last record. | |
| std::vector< PositionState > | position_state |
| std::vector< std::uint16_t > | session_epochs |
| std::vector< PastOrder > | past_orders |
| std::vector< VenueResume > | venue_resume |
| One entry per venue that recorded a fill with a venue time. | |
| std::vector< TradeIdMark > | last_trade_ids |
| std::int64_t | last_fill_ns = 0 |
| engine time of the newest session's last fill (0: none) | |
| std::int64_t | fallback_since_ms = 0 |
| 0: no replay | |
| std::vector< std::string > | fallback_exec_ids |
| of every session that ran inside kFallbackIdsNs | |
| std::int64_t | unbooked_since_ms = 0 |
| Where the replay of a venue with no stored fill starts (no venue_resume entry, in a store whose fills carry the venue's time or that holds none): the start of the newest session that shut down cleanly, else of the oldest session, less kFallbackOverlapNs, engine clock. | |
| std::vector< Duplicate > | duplicates |
| std::uint64_t | duplicate_count = 0 |
Static Public Attributes | |
| static constexpr std::size_t | kMaxSessionEpochs = 64 |
| The session epochs (the high bits of their client order ids) of the sessions a restart carries over, newest first, at most kMaxSessionEpochs: behind fastmm-gateway, executions of their orders are this engine's, whichever session placed them. | |
| static constexpr std::size_t | kMaxPastOrders = 256 |
| static constexpr std::int64_t | kResumeOverlapMs = 1000 |
| Where each venue's execution replay resumes (Venue::resume_executions): from the venue time of the last fill or funding payment the store holds for it (in the newest session that stored one), minus kResumeOverlapMs, skipping the trade ids and funding ids (kFundingIdPrefix + id) the store holds from there on. | |
| static constexpr std::size_t | kMaxKnownExecIds = 128 |
| The most trade ids a venue's resume carries (the gateway's attach request holds gw::kMaxKnownExecIds over all its venues). | |
| static constexpr std::int64_t | kFallbackOverlapNs = 10'000'000'000 |
| The fallback for a venue with no entry above (a store from before schema 3, or a venue whose fills carry no venue time): the engine clock, as before. | |
| static constexpr std::int64_t | kFallbackIdsNs = 2 * kFallbackOverlapNs |
| static constexpr std::size_t | kMaxDuplicates = 32 |
What the previous session left behind, for the operator who is about to start a new one.
| bool fastmm::store::Recovery::found = false |
| std::uint64_t fastmm::store::Recovery::session_id = 0 |
| std::string fastmm::store::Recovery::started_utc |
| std::string fastmm::store::Recovery::stopped_utc |
empty: the session never recorded a close (it was killed)
| std::string fastmm::store::Recovery::strategy |
| std::string fastmm::store::Recovery::kill_reason |
| bool fastmm::store::Recovery::kill_latched = false |
| bool fastmm::store::Recovery::clean_shutdown = false |
| int fastmm::store::Recovery::exit_code = 0 |
| std::string fastmm::store::Recovery::realized |
decimal, settlement currency
| std::string fastmm::store::Recovery::funding |
the part of realized that is funding (schema 4; "0" before)
| std::string fastmm::store::Recovery::unrealized |
| std::string fastmm::store::Recovery::fees |
| std::string fastmm::store::Recovery::net |
| std::uint64_t fastmm::store::Recovery::fills = 0 |
| std::uint64_t fastmm::store::Recovery::records_dropped = 0 |
| bool fastmm::store::Recovery::journal_complete = true |
| std::vector<std::string> fastmm::store::Recovery::journals |
| std::vector<std::string> fastmm::store::Recovery::positions |
"SYMBOL qty \@ avg_px realized=... fees=..." per instrument with a position or a fill.
| std::vector<std::string> fastmm::store::Recovery::open_orders |
"cl_ord_id SYMBOL side qty \@ price state" per order that was not terminal at the last record.
| std::vector<PositionState> fastmm::store::Recovery::position_state |
|
staticconstexpr |
The session epochs (the high bits of their client order ids) of the sessions a restart carries over, newest first, at most kMaxSessionEpochs: behind fastmm-gateway, executions of their orders are this engine's, whichever session placed them.
| std::vector<std::uint16_t> fastmm::store::Recovery::session_epochs |
|
staticconstexpr |
| std::vector<PastOrder> fastmm::store::Recovery::past_orders |
|
staticconstexpr |
Where each venue's execution replay resumes (Venue::resume_executions): from the venue time of the last fill or funding payment the store holds for it (in the newest session that stored one), minus kResumeOverlapMs, skipping the trade ids and funding ids (kFundingIdPrefix + id) the store holds from there on.
The funding replay starts there too, so a payment made while no session ran is booked by the next one. Both ends are the venue's clock, so the engine's clock (which follows the host's and may be seconds off, a WSL2 clock step) does not enter.
The ids are those of every session of the engine, not of the session the start comes from: a session killed seconds after it started stores only what its own replay booked, and the next replay's window still reaches the executions the sessions before it stored. An execution the store holds, in whichever session, is never handed to a replay as new.
The start is where the record is known to be whole: the last fill stored up to the newest session that got past its own replay on the venue (the store records a reconciliation that began with the venue's executions complete, schema 6; a session from before that counts when it placed an order there - none goes out before the venue has reconciled - or shut down cleanly). A session after that one died while its replay was still reading, and can hold a fill newer than one the replay had not reached: its fills are known, and the start is not later than the earliest of their last ones. When no session at all got past its replay the start is no later than unbooked_since_ms.
The overlap covers one thing: the order in which a venue publishes executions against their trade times. Executions of different symbols (and a Bybit batch, a Deribit per-instrument channel) can reach the store out of trade-time order; a restart must not skip one that traded just before the last stored fill but had not arrived when the process stopped. That spread is milliseconds to a few hundred; 1 s covers it with margin.
|
staticconstexpr |
The most trade ids a venue's resume carries (the gateway's attach request holds gw::kMaxKnownExecIds over all its venues).
A venue with more stored fills inside the overlap has its start moved later, past the oldest millisecond that does not fit whole, and VenueResume::shrunk says so: dropping an id instead would book that execution twice.
| std::vector<VenueResume> fastmm::store::Recovery::venue_resume |
One entry per venue that recorded a fill with a venue time.
| std::vector<TradeIdMark> fastmm::store::Recovery::last_trade_ids |
|
staticconstexpr |
The fallback for a venue with no entry above (a store from before schema 3, or a venue whose fills carry no venue time): the engine clock, as before.
The replay starts kFallbackOverlapNs before the session's last fill, and the ids reach kFallbackIdsNs back, further than the start, because the start is local time and the venue compares it with its own. At most kMaxKnownExecIds, with the start moved later when more fall inside.
|
staticconstexpr |
| std::int64_t fastmm::store::Recovery::last_fill_ns = 0 |
engine time of the newest session's last fill (0: none)
| std::int64_t fastmm::store::Recovery::fallback_since_ms = 0 |
0: no replay
| std::vector<std::string> fastmm::store::Recovery::fallback_exec_ids |
of every session that ran inside kFallbackIdsNs
| std::int64_t fastmm::store::Recovery::unbooked_since_ms = 0 |
Where the replay of a venue with no stored fill starts (no venue_resume entry, in a store whose fills carry the venue's time or that holds none): the start of the newest session that shut down cleanly, else of the oldest session, less kFallbackOverlapNs, engine clock.
Whatever the venue executed since is unbooked: a fill of a session that crashed before storing it, or one made while nothing ran.
|
staticconstexpr |
| std::vector<Duplicate> fastmm::store::Recovery::duplicates |
| std::uint64_t fastmm::store::Recovery::duplicate_count = 0 |