Expand description
§optionstratlib-backtest
Strategy backtests over simulated paths: a strategy is evaluated on every
path of a simulator (backtesting::Simulate), each path ends by an exit
policy, and the run is summarised as backtesting::SimulationStatsResult
with its report types and metrics. It depends on optionstratlib-core,
optionstratlib-pricing, optionstratlib-simulation,
optionstratlib-analytics and optionstratlib-strategies, and on no
option-chain I/O, plotting or async code.
backtesting:backtesting::Simulateand its single-leg implementations, the adapters from the simulation engine’s genericPathOutcome/PathStatisticsto the backtest results, run statistics, report types and performance metrics.error: theerror::BacktestErrortype.
The generic engine (random walks, exit policies, path evaluation and
statistics) is optionstratlib-simulation’s; this crate adapts it to
strategies and owns the reports. Charts stay with the visualization layer,
optionstratlib-visualization, which the optionstratlib facade
re-exports.
§Imports
There is no prelude, as in the other component crates (ADR-0001 D7): the
module roots re-export each capability, and the optionstratlib facade
prelude serves broad imports.
§Place in the workspace
- Depends on
optionstratlib-core,optionstratlib-pricing,optionstratlib-simulation,optionstratlib-analyticsandoptionstratlib-strategies. - Must not depend on
optionstratlib-visualization;make check-graphenforces the layering (ADR-0001 D9). - In the facade:
optionstratlib::backtestingandBacktestErrorinoptionstratlib::error, under the facade featurebacktest. The facade paths are the same types as the paths here; the ownership map lists every one with its feature.
Moving from 0.21? The 0.22 architecture and adoption guide maps each redesign to its replacement workflow; 0.22 keeps no compatibility with 0.21.
§Minimal example
use optionstratlib_backtest::backtesting::SimulationStatsResult;
// A run's statistics start empty; `Simulate::simulate` fills them from a
// `Simulator`'s paths (see the runnable example below).
let stats = SimulationStatsResult::default();
assert_eq!(stats.total_simulations, 0);§Runnable example
A runnable program that depends on this crate directly, with the smallest
dependency set and no facade, is osl-example-direct-backtest; make tree-example-direct-backtest
asserts its resolved graph.
§Features
schema(off by default): derivesutoipa::ToSchemaon the backtest types and enablesschemain core, pricing, simulation, analytics and strategies.
Modules§
- backtesting
- Strategy backtests over simulated paths: evaluation, statistics, reports and metrics. Backtesting
- error
- Errors raised by the backtest layer. Errors owned by the backtest layer.
Constants§
- VERSION
- Version of the
optionstratlib-backtestcrate.