![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
The replay's executor: accepts orders and holds them until they fill or are withdrawn. More...
#include <algotradelib/src/backtest/engine.hpp>
Classes | |
| class | Queue |
| Every outstanding order, oldest first: a view over the queue, valid until the queue changes. More... | |
Public Member Functions | |
| QueueingExecutor ()=default | |
| An executor with nothing queued. | |
| QueueingExecutor (const QueueingExecutor &other)=default | |
| Copies an executor and its queue. | |
| QueueingExecutor (QueueingExecutor &&other) noexcept(std::is_nothrow_move_constructible< ByInstrument >::value) | |
| Moves an executor; the source is left with nothing queued. | |
| QueueingExecutor & | operator= (QueueingExecutor &&other) noexcept |
| Replaces this executor with a move of another, which is left with nothing queued. | |
| QueueingExecutor & | operator= (const QueueingExecutor &other) |
| Replaces this executor with a copy of another, entirely or not at all. | |
| runner::SendOutcome | place (const strategy::PlannedOrder &order) |
| Accepts and queues an order, issuing it a reference. | |
| runner::SendOutcome | cancel (const WorkingOrder< BrokerTag > &working) |
| Withdraws the order a working row names, matched by reference. | |
| std::optional< OrderRef< BrokerTag > > | last_ref () const |
| Returns the reference issued to the most recently accepted order. | |
| Queue | queued () const noexcept |
| Returns every outstanding order, oldest first. | |
| template<typename Each> | |
| void | for_each_queued_in (const InstrumentId &instrument, Each &&each) const |
| Calls each with every outstanding order in one instrument, oldest first. | |
| const QueuedOrder< BrokerTag > * | find (const OrderRef< BrokerTag > &ref) const |
| Finds an outstanding order. | |
| void | assign_session (const OrderRef< BrokerTag > &ref, Date session) |
| Records the session date of a queued order; see QueuedOrder::session_. | |
| bool | withdraw (const OrderRef< BrokerTag > &ref) |
| Removes an order from the queue. | |
| bool | release (const OrderRef< BrokerTag > &ref) |
| Marks a queued stop-limit order as released. | |
| void | open_bar () noexcept |
| Starts the next bar; orders accepted from now on cannot fill against it. | |
| std::uint64_t | bar () const noexcept |
| Returns the bar being replayed. | |
| std::uint64_t | changes () const noexcept |
| Returns how many times the queue gained or lost an order (place, cancel, withdraw). | |
| template<typename PriceOf> | |
| void | stamp_decision_prices (PriceOf &&price_of) |
| Stamps the orders accepted since the last call with their instrument's price now, and when it was observed. | |
| void | deciding_at (std::chrono::system_clock::time_point at, bool exact=true) |
| Sets the decision instant stamped on orders accepted from now on. | |
Static Public Member Functions | |
| static bool | can_model (const strategy::PlannedOrder &order) noexcept |
| Tests whether a replay can price an order from bars. | |
| static constexpr bool | models_time_in_force (TimeInForce condition) noexcept |
| Tests whether the replay models a limit or market order's time in force. | |
Static Public Attributes | |
| static constexpr bool | reaches_a_broker = false |
| false: a replay reaches no broker. | |
The replay's executor: accepts orders and holds them until they fill or are withdrawn.
queued() is always the complete set of outstanding orders; the engine shows them to the strategy as working orders.
| BrokerTag | The order-reference tag. |
Definition at line 103 of file engine.hpp.
|
default |
Copies an executor and its queue.
| other | The executor to copy. |
|
inlinenoexcept |
Moves an executor; the source is left with nothing queued.
noexcept exactly when the standard library moves an std::unordered_map without throwing (libc++ and libstdc++ do; Microsoft's allocates).
| other | The executor to move from. |
| std::bad_alloc | If the map cannot be moved; the source is then unchanged. |
Definition at line 127 of file engine.hpp.
|
inline |
Records the session date of a queued order; see QueuedOrder::session_.
| ref | The order. |
| session | The session's market-local date. |
Definition at line 462 of file engine.hpp.
|
inlinenoexcept |
Returns the bar being replayed.
Definition at line 519 of file engine.hpp.
|
inlinestaticnoexcept |
Tests whether a replay can price an order from bars.
Only regular-session limit and market orders without a trigger, and DAY stop-limit orders with both a trigger and a limit price. Best-limit, primary-limit, mid-price, conditional-limit and closing-price orders need a book or a session close that bars do not carry.
| order | The order. |
Definition at line 226 of file engine.hpp.
|
inline |
Withdraws the order a working row names, matched by reference.
| working | The working row. |
Definition at line 276 of file engine.hpp.
|
inlinenoexcept |
|
inline |
Sets the decision instant stamped on orders accepted from now on.
| at | The instant. |
| exact | Whether at is exact or only an upper bound; see QueuedOrder::decision_is_exact_. |
Definition at line 554 of file engine.hpp.
|
inline |
Finds an outstanding order.
| ref | The reference. |
Definition at line 452 of file engine.hpp.
|
inline |
Calls each with every outstanding order in one instrument, oldest first.
Visits only that instrument's orders, however many others are queued. each must not change the queue.
| instrument | The instrument. |
| each | Called as each(const QueuedOrder&). |
Definition at line 437 of file engine.hpp.
|
inline |
Returns the reference issued to the most recently accepted order.
Definition at line 284 of file engine.hpp.
|
inlinestaticconstexprnoexcept |
Tests whether the replay models a limit or market order's time in force.
A day order rests on later bars until the session ends; every other condition is filled or not on the next bar and not kept after it (NextBarFillModel::rests_unfilled), which is how an UNKNOWN one is replayed too.
| condition | The condition. |
Definition at line 259 of file engine.hpp.
|
inlinenoexcept |
Starts the next bar; orders accepted from now on cannot fill against it.
Definition at line 511 of file engine.hpp.
|
inline |
Replaces this executor with a copy of another, entirely or not at all.
| other | The executor to copy. |
| std::bad_alloc | If the copy cannot be made; this executor is then unchanged. |
Definition at line 168 of file engine.hpp.
|
inlinenoexcept |
Replaces this executor with a move of another, which is left with nothing queued.
| other | The executor to move from. |
Definition at line 145 of file engine.hpp.
|
inline |
Accepts and queues an order, issuing it a reference.
A replay invents no transport failure.
| order | The order. |
Definition at line 189 of file engine.hpp.
|
inlinenoexcept |
Returns every outstanding order, oldest first.
Definition at line 424 of file engine.hpp.
|
inline |
Marks a queued stop-limit order as released.
| ref | The order. |
Definition at line 499 of file engine.hpp.
|
inline |
Stamps the orders accepted since the last call with their instrument's price now, and when it was observed.
| PriceOf | A callable from an InstrumentId to a pair of an optional price and an optional instant. |
| price_of | The price lookup. |
Definition at line 540 of file engine.hpp.
|
inline |
Removes an order from the queue.
| ref | The order. |
Definition at line 473 of file engine.hpp.
|
staticconstexpr |
false: a replay reaches no broker.
Definition at line 177 of file engine.hpp.