algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::strategy::dispatch Namespace Reference

Calls a strategy's handlers, skipping the ones it does not declare. More...

Functions

template<typename S, typename Ctx>
void start (S &strategy, Ctx &context)
 Calls strategy.on_start(context) if the strategy declares on_start; otherwise does nothing.
template<typename S, typename Ctx>
void stop (S &strategy, Ctx &context)
 Calls strategy.on_stop(context) if the strategy declares on_stop; otherwise does nothing.
template<typename S, typename Ctx>
void bar (S &strategy, Ctx &context, const BarEvent &event)
 Calls strategy.on_bar(context, event) if the strategy declares on_bar; otherwise does nothing.
template<typename S, typename Ctx>
void bars (S &strategy, Ctx &context, const BarSlice &slice)
 Calls strategy.on_bars(context, slice) if the strategy declares on_bars; otherwise does nothing.
template<typename S, typename Ctx>
void quote (S &strategy, Ctx &context, const QuoteEvent &event)
 Calls strategy.on_quote(context, event) if the strategy declares on_quote; otherwise does nothing.
template<typename S, typename Ctx>
void fill (S &strategy, Ctx &context, const Fill &event)
 Calls strategy.on_fill(context, event) if the strategy declares on_fill; otherwise does nothing.
template<typename S, typename Ctx>
void order_update (S &strategy, Ctx &context, const OrderSnapshot &event)
 Calls strategy.on_order_update(context, event) if the strategy declares on_order_update; otherwise does nothing.
template<typename S, typename Ctx>
void phase (S &strategy, Ctx &context, const MarketPhase &event)
 Calls strategy.on_phase(context, event) if the strategy declares on_phase; otherwise does nothing.

Detailed Description

Calls a strategy's handlers, skipping the ones it does not declare.

A handler the strategy declares is always called; if its signature does not fit the call (a non-const event, a missing event, a context taken by value), compilation fails here rather than the handler being skipped. A wrapper strategy that forwards to an inner strategy through these functions gets the same check for the inner one.

Function Documentation

◆ bar()

template<typename S, typename Ctx>
void algotradelib::strategy::dispatch::bar ( S & strategy,
Ctx & context,
const BarEvent & event )

Calls strategy.on_bar(context, event) if the strategy declares on_bar; otherwise does nothing.

Does not compile for a strategy that declares on_bars: its bars go through bars, so a path that still delivers one BarEvent at a time fails to build instead of skipping the strategy in silence.

Template Parameters
SThe strategy type; a class that is not final.
CtxThe context type.
Parameters
strategyThe strategy.
contextThe context passed to the handler.
eventThe event passed to the handler.

Definition at line 191 of file concept.hpp.

Referenced by bar().

◆ bars()

template<typename S, typename Ctx>
void algotradelib::strategy::dispatch::bars ( S & strategy,
Ctx & context,
const BarSlice & slice )

Calls strategy.on_bars(context, slice) if the strategy declares on_bars; otherwise does nothing.

Template Parameters
SThe strategy type; a class that is not final.
CtxThe context type.
Parameters
strategyThe strategy.
contextThe context passed to the handler.
sliceThe slice passed to the handler.

Definition at line 218 of file concept.hpp.

Referenced by bars().

◆ fill()

template<typename S, typename Ctx>
void algotradelib::strategy::dispatch::fill ( S & strategy,
Ctx & context,
const Fill & event )

Calls strategy.on_fill(context, event) if the strategy declares on_fill; otherwise does nothing.

Template Parameters
SThe strategy type; a class that is not final.
CtxThe context type.
Parameters
strategyThe strategy.
contextThe context passed to the handler.
eventThe event passed to the handler.

Definition at line 261 of file concept.hpp.

Referenced by fill().

◆ order_update()

template<typename S, typename Ctx>
void algotradelib::strategy::dispatch::order_update ( S & strategy,
Ctx & context,
const OrderSnapshot & event )

Calls strategy.on_order_update(context, event) if the strategy declares on_order_update; otherwise does nothing.

Template Parameters
SThe strategy type; a class that is not final.
CtxThe context type.
Parameters
strategyThe strategy.
contextThe context passed to the handler.
eventThe event passed to the handler.

Definition at line 282 of file concept.hpp.

Referenced by order_update().

◆ phase()

template<typename S, typename Ctx>
void algotradelib::strategy::dispatch::phase ( S & strategy,
Ctx & context,
const MarketPhase & event )

Calls strategy.on_phase(context, event) if the strategy declares on_phase; otherwise does nothing.

Template Parameters
SThe strategy type; a class that is not final.
CtxThe context type.
Parameters
strategyThe strategy.
contextThe context passed to the handler.
eventThe new phase, passed as a const reference.

Definition at line 304 of file concept.hpp.

Referenced by phase().

◆ quote()

template<typename S, typename Ctx>
void algotradelib::strategy::dispatch::quote ( S & strategy,
Ctx & context,
const QuoteEvent & event )

Calls strategy.on_quote(context, event) if the strategy declares on_quote; otherwise does nothing.

Template Parameters
SThe strategy type; a class that is not final.
CtxThe context type.
Parameters
strategyThe strategy.
contextThe context passed to the handler.
eventThe event passed to the handler.

Definition at line 240 of file concept.hpp.

Referenced by quote().

◆ start()

template<typename S, typename Ctx>
void algotradelib::strategy::dispatch::start ( S & strategy,
Ctx & context )

Calls strategy.on_start(context) if the strategy declares on_start; otherwise does nothing.

Template Parameters
SThe strategy type; a class that is not final.
CtxThe context type.
Parameters
strategyThe strategy.
contextThe context passed to the handler.

Definition at line 149 of file concept.hpp.

Referenced by start().

◆ stop()

template<typename S, typename Ctx>
void algotradelib::strategy::dispatch::stop ( S & strategy,
Ctx & context )

Calls strategy.on_stop(context) if the strategy declares on_stop; otherwise does nothing.

Template Parameters
SThe strategy type; a class that is not final.
CtxThe context type.
Parameters
strategyThe strategy.
contextThe context passed to the handler.

Definition at line 168 of file concept.hpp.

Referenced by stop().