![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
A backtest's clock: the current instant and market phase, moved by the replayed events. More...
#include <algotradelib/src/backtest/clock.hpp>
Public Member Functions | |
| ReplayClock (strategy::SessionWindow session=strategy::SessionWindow::krx()) | |
| Constructs a clock. | |
| const strategy::SessionWindow & | session () const noexcept |
| Returns the session window. | |
| std::chrono::system_clock::time_point | now () const noexcept |
| Returns the instant the replay has reached. | |
| strategy::MarketPhase | phase () const noexcept |
| Returns the market phase at the current instant. | |
| bool | advance (const strategy::BarEvent &event, std::optional< bool > trading_day) |
| Moves the clock to a bar's period end and recomputes the phase. | |
| bool | advance_to (std::chrono::system_clock::time_point at, std::optional< bool > trading_day) |
| Moves the clock to an instant and recomputes the phase, for an event that is not a bar (such as a quote). | |
Static Public Member Functions | |
| static bool | contiguous (const strategy::BarEvent &previous, const strategy::BarEvent &event) |
| Tests whether a bar follows the previous one with no gap. | |
A backtest's clock: the current instant and market phase, moved by the replayed events.
It never reads the wall clock. "Now" is the period end of the last bar (the earliest moment it could be known), or the instant of a quote.
|
inlineexplicit |
|
inline |
Moves the clock to a bar's period end and recomputes the phase.
| event | The bar. |
| trading_day | Whether the bar's date trades, as the calendar said; empty gives UNKNOWN, in which the default risk limits refuse to open positions. |
|
inline |
Moves the clock to an instant and recomputes the phase, for an event that is not a bar (such as a quote).
The clock goes wherever it is told, even backwards; feeding events in time order is the caller's job (see Backtester::feed).
| at | The instant. |
| trading_day | Whether that date trades; empty gives UNKNOWN. |
Definition at line 128 of file clock.hpp.
Referenced by advance().
|
inlinestatic |
Tests whether a bar follows the previous one with no gap.
| previous | The earlier bar. |
| event | The later bar. |
Definition at line 148 of file clock.hpp.
Referenced by algotradelib::backtest::Backtester< Strategy, CapsType >::feed().
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Returns the session window.
Definition at line 91 of file clock.hpp.
Referenced by ReplayClock().