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

Holds a fixed quantity of one instrument. More...

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

Collaboration diagram for algotradelib::strategy::vanilla::BuyAndHold:

Classes

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

Public Member Functions

template<class Ctx>
void on_bar (Ctx &ctx, const BarEvent &bar)
 States the target position on each bar of the instrument.

Public Attributes

Params params_
 The settings.

Static Public Attributes

static constexpr std::size_t warmup_bars = 1
 One bar of history is enough.

Detailed Description

Holds a fixed quantity of one instrument.

States the same target position on every bar, so it buys once and then sends nothing while the holding matches, including after a restart. Useful as a benchmark.

Definition at line 21 of file buy_and_hold.hpp.

Member Function Documentation

◆ on_bar()

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

States the target position on each bar of the instrument.

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

Definition at line 45 of file buy_and_hold.hpp.

Member Data Documentation

◆ params_

Params algotradelib::strategy::vanilla::BuyAndHold::params_

The settings.

Definition at line 33 of file buy_and_hold.hpp.

Referenced by on_bar().

◆ warmup_bars

std::size_t algotradelib::strategy::vanilla::BuyAndHold::warmup_bars = 1
staticconstexpr

One bar of history is enough.

Definition at line 36 of file buy_and_hold.hpp.


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