algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::strategy::vanilla::ZScoreReversion Struct Reference

Long-only mean reversion on the z-score of the close. More...

#include <algotradelib/src/strategy/vanilla/reversion.hpp>

Collaboration diagram for algotradelib::strategy::vanilla::ZScoreReversion:

Classes

struct  Params
 The strategy's settings. More...

Public Member Functions

std::size_t warmup_bars () const
 Returns how many bars to load before the first live bar.
template<class Ctx>
void on_bar (Ctx &ctx, const BarEvent &bar)
 States a target position for the instrument when its signal enters or exits.

Public Attributes

Params params_
 The settings.

Detailed Description

Long-only mean reversion on the z-score of the close.

Buys quantity_ when flat and the z-score over window_ closes is at or below -entry_; goes flat when holding and the z-score has risen to -exit_ or above. Exiting before the mean (exit_ > 0) keeps it from re-entering on the next small dip.

Definition at line 25 of file reversion.hpp.

Member Function Documentation

◆ on_bar()

template<class Ctx>
void algotradelib::strategy::vanilla::ZScoreReversion::on_bar ( Ctx & ctx,
const BarEvent & bar )
inline

States a target position for the instrument when its signal enters or exits.

Template Parameters
CtxThe runner's context type.
Parameters
ctxThe context.
barThe new bar.

Definition at line 58 of file reversion.hpp.

◆ warmup_bars()

std::size_t algotradelib::strategy::vanilla::ZScoreReversion::warmup_bars ( ) const
inline

Returns how many bars to load before the first live bar.

Returns
window_ + 1.

Definition at line 49 of file reversion.hpp.

Member Data Documentation

◆ params_

Params algotradelib::strategy::vanilla::ZScoreReversion::params_

The settings.

Definition at line 43 of file reversion.hpp.

Referenced by on_bar(), and warmup_bars().


The documentation for this struct was generated from the following file: