![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
A context for testing a strategy without a runner: it records what the strategy asks for. More...
#include <algotradelib/src/strategy/concept.hpp>
Classes | |
| class | Log |
| A log that keeps each line in memory for a test to read. More... | |
Public Types | |
| using | Broker = ProbeBroker |
| The broker tag; see ProbeBroker. | |
| using | caps = CapsType |
| The broker capabilities the strategy sees. | |
Public Member Functions | |
| ProbeContextT ()=default | |
| Constructs an empty probe. | |
| ProbeContextT (const ProbeContextT &)=delete | |
| Deleted: like a runner's context, a probe cannot be copied. | |
| ProbeContextT & | operator= (const ProbeContextT &)=delete |
| Deleted: a probe cannot be copied. | |
| ProbeContextT (ProbeContextT &&)=default | |
| Move constructor: takes the other probe's state. | |
| ProbeContextT & | operator= (ProbeContextT &&)=default |
| Move assignment: takes the other probe's state. | |
| std::chrono::system_clock::time_point | now () const noexcept |
| Returns the current instant. | |
| MarketPhase | phase () const noexcept |
| Returns the market phase. | |
| const TradingCalendar & | calendar () const noexcept |
| Returns the trading calendar. | |
| const Portfolio< ProbeBroker > & | portfolio () const noexcept |
| Returns the portfolio. | |
| std::optional< Instrument > | instrument (const InstrumentId &id) const |
| Looks up an instrument's reference data in instruments_. | |
| void | submit (OrderIntent intent) |
| Records an order intent. | |
| void | submit (TargetPosition target) |
| Records a target position. | |
| void | cancel (const OrderRef< ProbeBroker > &ref) |
| Records a cancellation. | |
| Log & | log () noexcept |
| Returns the log. | |
| const std::vector< OrderIntent > & | submitted () const noexcept |
| Returns the order intents submitted. | |
| const std::vector< TargetPosition > & | targets () const noexcept |
| Returns the target positions submitted. | |
| const std::vector< CancelIntent< ProbeBroker > > & | canceled () const noexcept |
| Returns the cancellations requested. | |
Public Attributes | |
| std::chrono::system_clock::time_point | now_ {} |
| The instant now() returns. | |
| MarketPhase | phase_ {MarketPhase::OPEN} |
| The phase phase() returns. | |
| TradingCalendar | calendar_ |
| The calendar calendar() returns. | |
| Portfolio< ProbeBroker > | portfolio_ |
| The portfolio portfolio() returns. | |
| std::vector< Instrument > | instruments_ |
| The reference data instrument() searches. | |
A context for testing a strategy without a runner: it records what the strategy asks for.
Set the public fields (now_, phase_, calendar_, portfolio_, instruments_), call a handler, then read submitted(), targets(), canceled() and log().lines(). ATL_ASSERT_STRATEGY(S, MinimalContext) compiles a strategy's handlers against it.
It has no series accessors (bars, frame, panel), so it needs no linear algebra backend; a strategy that reads series is checked by the runner it is bound to.
| CapsType | The broker capabilities the strategy sees as Ctx::caps; see NoCaps and AllCaps. |
Definition at line 509 of file concept.hpp.
| using algotradelib::strategy::ProbeContextT< CapsType >::Broker = ProbeBroker |
The broker tag; see ProbeBroker.
Definition at line 512 of file concept.hpp.
| using algotradelib::strategy::ProbeContextT< CapsType >::caps = CapsType |
The broker capabilities the strategy sees.
Definition at line 514 of file concept.hpp.
|
inlinenoexcept |
|
inline |
Records a cancellation.
| ref | The order to cancel, appended to canceled(). |
Definition at line 606 of file concept.hpp.
|
inlinenoexcept |
Returns the cancellations requested.
Definition at line 630 of file concept.hpp.
|
inline |
Looks up an instrument's reference data in instruments_.
| id | The instrument. |
Definition at line 581 of file concept.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
delete |
Deleted: a probe cannot be copied.
|
default |
Move assignment: takes the other probe's state.
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
Records an order intent.
| intent | The intent, appended to submitted(). |
Definition at line 594 of file concept.hpp.
|
inline |
Records a target position.
| target | The target, appended to targets(). |
Definition at line 600 of file concept.hpp.
|
inlinenoexcept |
Returns the order intents submitted.
Definition at line 620 of file concept.hpp.
|
inlinenoexcept |
Returns the target positions submitted.
Definition at line 625 of file concept.hpp.
| TradingCalendar algotradelib::strategy::ProbeContextT< CapsType >::calendar_ |
The calendar calendar() returns.
Definition at line 637 of file concept.hpp.
| std::vector<Instrument> algotradelib::strategy::ProbeContextT< CapsType >::instruments_ |
The reference data instrument() searches.
Definition at line 641 of file concept.hpp.
| std::chrono::system_clock::time_point algotradelib::strategy::ProbeContextT< CapsType >::now_ {} |
The instant now() returns.
Definition at line 633 of file concept.hpp.
| MarketPhase algotradelib::strategy::ProbeContextT< CapsType >::phase_ {MarketPhase::OPEN} |
The phase phase() returns.
Definition at line 635 of file concept.hpp.
| Portfolio<ProbeBroker> algotradelib::strategy::ProbeContextT< CapsType >::portfolio_ |
The portfolio portfolio() returns.
Definition at line 639 of file concept.hpp.