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

Holds a long position sized so its value volatility per bar matches a risk budget. More...

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

Collaboration diagram for algotradelib::strategy::vanilla::VolatilityTargetSizing:

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 the volatility-sized target position on each bar of the instrument.

Public Attributes

Params params_
 The settings.

Detailed Description

Holds a long position sized so its value volatility per bar matches a risk budget.

The target is q = budget / (price * s), where s is the sample standard deviation of the last window_ returns of the bars it is fed, capped at max_quantity_. The volatility is per bar of whatever interval arrives (a minute bar gives per-minute volatility); nothing converts it to a daily figure. Nothing is stated while the window is incomplete or flat. The budget is in currency, not a fraction of equity.

Definition at line 28 of file sizing.hpp.

Member Function Documentation

◆ on_bar()

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

States the volatility-sized target position on each bar of the instrument.

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

Definition at line 59 of file sizing.hpp.

◆ warmup_bars()

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

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

Returns
window_ + 2.

Definition at line 50 of file sizing.hpp.

Member Data Documentation

◆ params_

Params algotradelib::strategy::vanilla::VolatilityTargetSizing::params_

The settings.

Definition at line 44 of file sizing.hpp.

Referenced by on_bar(), and warmup_bars().


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