An executor wrapper that records each instruction in a journal before sending it.
More...
|
| | JournalingExecutor (Inner inner, Journal &journal, Clock clock={}) |
| | Wraps an executor.
|
| void | set_id_prefix (std::string prefix) |
| | Sets the prefix of line ids.
|
| template<typename E = Inner> |
| auto | route_of (const strategy::PlannedOrder &order, int) const -> decltype(std::declval< const E & >().effective_route(order.venue_)) |
| | Returns the venue the wrapped executor says an order will reach.
|
| Venue | route_of (const strategy::PlannedOrder &order, long) const |
| | Returns the venue an order asked for, when the wrapped executor cannot resolve routes (the fallback of route_of(order, 0); the second argument's value is ignored).
|
| Venue | effective_route_of (const strategy::PlannedOrder &order) const |
| | Returns the venue to record for an order: the binding's route, or the venue asked for.
|
| SendOutcome | place (const strategy::PlannedOrder &order) |
| | Records and places one order.
|
| SendOutcome | place (const strategy::PlannedOrder &order, std::optional< Decimal64 > baseline) |
| | Records and places one order, stating the holding it was decided against (a serialized Runner calls this).
|
| const std::optional< JournalEntry > & | last_entry () const noexcept |
| | Returns the answering line last written (or attempted) for a placement the wrapped executor was asked to place, sent or refused before sending.
|
| bool | record (JournalEntry &entry) |
| | Appends a line the caller built, such as a serialized Runner's CONFIRMED line.
|
| template<typename BrokerTag> |
| SendOutcome | cancel (const WorkingOrder< BrokerTag > &working) |
| | Records and sends one cancellation.
|
| const Inner & | inner () const noexcept |
| | Returns the wrapped executor.
|
| Inner & | inner () noexcept |
| | Returns the wrapped executor.
|
| const Journal & | journal () const noexcept |
| | Returns the journal.
|
| const std::string & | last_journal_error () const noexcept |
| | Returns the first journal failure's description.
|
| std::size_t | unjournaled_refusals () const noexcept |
| | Returns how many instructions were not sent because their PENDING line could not be written.
|
| std::size_t | journal_failures () const noexcept |
| | Returns how many journal writes have failed; Runner compares it with the count it last acknowledged to tell a new failure from an old one.
|
| template<typename Executor = Inner> |
| auto | requested_route (Venue asked) const noexcept -> decltype(std::declval< const Executor & >().requested_route(asked)) |
| | Returns the wrapped executor's route for a requested venue.
|
| template<typename Executor = Inner> |
| auto | last_ref () const noexcept -> decltype(std::declval< const Executor & >().last_ref()) |
| | Returns the reference of the last order the wrapped executor placed.
|
| template<typename Executor = Inner> |
| auto | last_error () const noexcept -> decltype(std::declval< const Executor & >().last_error()) |
| | Returns why the last instruction failed, from the wrapped executor.
|
template<typename Inner, typename Journal, typename Clock = SteadyClock>
class algotradelib::runner::JournalingExecutor< Inner, Journal, Clock >
An executor wrapper that records each instruction in a journal before sending it.
place and cancel append a PENDING line, call the wrapped executor only if the append succeeded, and append its outcome. The line is as durable as the journal makes it before append returns: FileJournal flushes it to disk, MemoryJournal (for tests and dry runs) loses it at exit. A journal of your own must write durably before returning success if it is to be recovered from after a crash. The wrapped executor's outcome is returned unchanged, except that if the PENDING line cannot be written, nothing is sent and the outcome is SendOutcome::UNAVAILABLE (which stops the runner). If only the answering line fails, the send has happened; the failure is recorded and the instruction will look unresolved to recovery. A backtest does not use it.
- Template Parameters
-
| Inner | The wrapped executor. |
| Journal | The journal type (MemoryJournal or FileJournal). |
| Clock | The clock lines are stamped with. |
Definition at line 695 of file journal.hpp.
template<typename Inner, typename Journal, typename Clock = SteadyClock>
template<typename Executor = Inner>
Returns why the last instruction failed, from the wrapped executor.
- Template Parameters
-
| Executor | The wrapped executor type (deduced). |
- Returns
- The error, if the wrapped executor reports one.
Definition at line 932 of file journal.hpp.
Referenced by last_error().
template<typename Inner, typename Journal, typename Clock = SteadyClock>
template<typename Executor = Inner>
Returns the reference of the last order the wrapped executor placed.
- Template Parameters
-
| Executor | The wrapped executor type (deduced). |
- Returns
- The reference, if the wrapped executor reports one.
Definition at line 922 of file journal.hpp.
Referenced by last_ref().
template<typename Inner, typename Journal, typename Clock = SteadyClock>
template<typename E = Inner>
Returns the venue the wrapped executor says an order will reach.
Call it as route_of(order, 0); the second argument selects this overload over the fallback, and its value is ignored.
- Template Parameters
-
| E | The wrapped executor type (deduced). |
- Parameters
-
- Returns
- The wrapped executor's effective_route for the order's venue.
Definition at line 734 of file journal.hpp.
Referenced by effective_route_of().
template<typename Inner, typename Journal, typename Clock = SteadyClock>
Sets the prefix of line ids.
Ids are the prefix, a hyphen and a counter starting at one (<prefix>-1), and recovery pairs lines by id, so the prefix must differ between every executor run that shares a journal. The default is the wall-clock construction time in microseconds (not the injected clock's), which is distinct only if no two executors on the journal are made at the same instant.
- Parameters
-
Definition at line 721 of file journal.hpp.