Expand description
Strategies over historical and live bars, and the Backtest engine that runs them.
A Strategy computes the studies it needs once, then decides on each closed bar by placing
named entry and exit orders through a StrategyContext. Backtest::run fills those orders
along each bar’s price path and returns a StrategyReport, so
the report’s metrics, its panel and its CSV export work on the result. Needs no egui, so a
server can run the same code.
StrategyFactory supplies ten price-action strategies and, with studies, twelve
strategies using the chart studies’ public values. Hosts can register their own constructors.
Use Strategy::study_inputs and Strategy::set_input to edit bounded parameters before
a run. Gap and inside/outside strategies take the host instrument’s tick_size input; their
exits are distances from the actual position fill price. The engine’s settings supply size
and pyramiding. Built-ins ignore fill callbacks; live tick recalculation follows the run settings.
Backtest::update retains the execution state as the host appends bars or changes the
forming bar, and returns StrategyFill events. Backtest::report exposes its report.
Feed those events to services::AlertEngine::strategy_fills with both engine features enabled.
optimise runs a lazy grid of input combinations on fresh strategies and yields each
combination’s StrategyTrial, using the same bars and backtest settings throughout.
Structs§
- Backtest
- Runs a
Strategyover bars and reports the result as aStrategyReport. - Backtest
Settings - Account and execution assumptions of a
Backtest. - Strategy
Context - What a
Strategysees at a decision: the bars up to it and the open position. It places and cancels working orders by id. - Strategy
Factory - Creates built-in and host strategies by name.
- Strategy
Fill - One executed order, including an entry, an exit or a margin liquidation. A reversal is one fill whose quantity includes closing the previous position.
- Strategy
Trial - The input values and report metrics of one optimisation trial.
Enums§
- Commission
- Commission charged once on the entire quantity of a fill, including a reversal.
- Order
Size - The default entry size, converted to units at the execution price.
- Slippage
- Adverse execution adjustment for market and stop fills. Limits never slip.
Traits§
- Strategy
- A trading strategy that decides on closed bars and, when enabled, live ticks.
Functions§
- optimise
- Runs one fresh strategy per combination of
inputs, on the same backtest and bars.