quantlab.backtest.config.ApproximateBacktestConfig#
- class quantlab.backtest.config.ApproximateBacktestConfig(*, price_dataset, start_date, end_date, rebalance_periods, cost=0.001, benchmark_dataset=None, chunk_bars=63, max_iterations=20000, tolerance=1e-05)[source]#
Bases:
FrozenConfigConfig of an approximate backtest: every rebalance decided at once, the window simulated as arrays.
Built once over a price dataset and run on many (predictions, rule) pairs (
quantlab.backtest.approximate.ApproximateBacktest). The rule is not here: it comes torunwith its own unchanged config, so a rule chosen by a sweep goes to a backtest run as it is. Execution is reduced to one cost on traded weight; the rest of what is kept and given up is indocs/user-guide/backtesting.md.Examples
>>> cfg = ApproximateBacktestConfig( ... price_dataset=price_dataset, ... start_date="2023-01-01", ... end_date="2023-12-31", ... rebalance_periods=5, ... ) >>> cfg.cost, cfg.chunk_bars, cfg.max_iterations, cfg.tolerance (0.001, 63, 20000, 1e-05)
- benchmark_dataset = None#
A market dataset holding exactly one symbol, bought and held on the window’s bars at the same cost, as a backtest run’s
benchmark_datasetis; the account then reports its curve, its return statistics and the excess over it.Nonefor none.
- chunk_bars = 63#
Bars of the window decided together: a chunk’s decision inputs (its covariance estimates, for a mean-variance rule) are held in memory at once. The chunks are decided in time order, each from the weights decided before it, so the size changes memory, not the result.
- cost = 0.001#
Cost per unit of traded weight at each fill, standing for fees and slippage together (a backtest run’s
fees + slippage).
- end_date#
Last date of the window, inclusive.
- max_iterations = 20000#
An iterative rule’s iterations per decision bar before the bar is reported as not converged (
quantlab.portfolio.approximate.Stopping).
- price_dataset#
The dataset whose prices the simulation trades on.
- rebalance_periods#
Rebalance every this many bars from the window’s first bar, as a backtest run does.
- start_date#
First date of the window, inclusive.
- tolerance = 1e-05#
An iterative rule’s bar has converged when its gradient-mapping residual is at most this times the largest entry of its starting gradient: its objective is then within about twice that of the optimum (
quantlab.portfolio.approximate.Stopping).