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

Holds an equal fraction of portfolio value in each instrument of a universe. More...

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

Collaboration diagram for algotradelib::strategy::vanilla::EqualWeightRebalance:

Classes

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

Public Member Functions

template<class Ctx>
void on_phase (Ctx &ctx, MarketPhase phase)
 Submits an equal-weight buy intent for every instrument when phase is rebalance_at_.

Public Attributes

Params params_
 The settings.

Static Public Attributes

static constexpr std::size_t warmup_bars = 0
 No history is needed before the first live bar.

Detailed Description

Holds an equal fraction of portfolio value in each instrument of a universe.

Rebalances only when the market enters rebalance_at_ (via on_phase), not on every bar. Each weight is 1 / n truncated at weight_scale_ decimal places (three names get 0.3333); the residual stays unallocated. Each weight is a holding (SizeSpec::target_weight), so a rebalance trades only the drift; set a notional TradeTolerance to skip one-share drifts.

Note
Live, the runner refuses weights (no_portfolio_value) until you call Runner::set_portfolio_value.
In a backtest on daily bars, on_phase fires about once in the whole run, because the replay clock visits only bar ends; replay intraday bars to rebalance each session. In a multi-instrument replay the other instruments are sized at their previous close; on a mixed-currency replay the portfolio value counts one currency only; and quotes move prices while the value stays at the last bar's marks.

Definition at line 124 of file sizing.hpp.

Member Function Documentation

◆ on_phase()

template<class Ctx>
void algotradelib::strategy::vanilla::EqualWeightRebalance::on_phase ( Ctx & ctx,
MarketPhase phase )
inline

Submits an equal-weight buy intent for every instrument when phase is rebalance_at_.

Template Parameters
CtxThe runner's context type.
Parameters
ctxThe context.
phaseThe new market phase.

Definition at line 150 of file sizing.hpp.

Member Data Documentation

◆ params_

Params algotradelib::strategy::vanilla::EqualWeightRebalance::params_

The settings.

Definition at line 138 of file sizing.hpp.

Referenced by on_phase().

◆ warmup_bars

std::size_t algotradelib::strategy::vanilla::EqualWeightRebalance::warmup_bars = 0
staticconstexpr

No history is needed before the first live bar.

Definition at line 141 of file sizing.hpp.


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