Holds an equal fraction of portfolio value in each instrument of a universe.
More...
#include <algotradelib/src/strategy/vanilla/sizing.hpp>
|
| template<class Ctx> |
| void | on_phase (Ctx &ctx, MarketPhase phase) |
| | Submits an equal-weight buy intent for every instrument when phase is rebalance_at_.
|
|
| static constexpr std::size_t | warmup_bars = 0 |
| | No history is needed before the first live bar.
|
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.
◆ 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
-
| Ctx | The runner's context type. |
- Parameters
-
| ctx | The context. |
| phase | The new market phase. |
Definition at line 150 of file sizing.hpp.
◆ params_
| Params algotradelib::strategy::vanilla::EqualWeightRebalance::params_ |
◆ 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: