quantlab.backtest.config.WeightsBacktestConfig#
- class quantlab.backtest.config.WeightsBacktestConfig(*, price_dataset, start_date, end_date, rebalance_periods, output_dir, model=None, model_mode=None, checkpoint=None, cv_project_dir=None, fees=0.0005, slippage=0.0005, init_cash=1000000.0, sizing_basis='fill', benchmark_dataset=None, risk_model=None, tracker=<factory>, name=None, fill_price_column, valuation_price_column, trading_days_per_year, session_minutes_per_day, direction=None, top_n=None)[source]#
Bases:
BacktestConfigConfig of a backtest of given target weights, market conventions included.
The backtester reading it (
WeightsVectorBt) has no fixed market: the fill and valuation columns and the annualization are fields here instead of a class constant, so one class serves any frame a caller brings. It takes no model; its weights come torun_weights().directionandtop_nrecord the top-N selection that built the weights from scores, when one did; they are shown in the report and never used to select.Examples
>>> import pandas as pd >>> from quantlab.backtest.config import WeightsBacktestConfig >>> from quantlab.dataset.memory import FrameDataset >>> price_dataset = FrameDataset(pd.DataFrame({ ... "timestamp": pd.to_datetime(["2024-01-02", "2024-01-03"]), ... "symbol": ["AAA", "AAA"], "open": [10.0, 11.0], "close": [10.5, 11.5], ... })) >>> cfg = WeightsBacktestConfig( ... price_dataset=price_dataset, ... start_date="2024-01-01", ... end_date="2024-06-28", ... output_dir=None, ... rebalance_periods=1, ... fill_price_column="open", ... valuation_price_column="close", ... trading_days_per_year=252, ... session_minutes_per_day=390, ... ) >>> cfg.model, cfg.top_n (None, None)
- direction = None#
The selection side the weights were built with, or
Nonefor weights given as such. A record only.
- fill_price_column#
Price variable orders fill at.
- session_minutes_per_day#
Minutes of one trading session, to annualize intraday bars.
- top_n = None#
The names per side the weights were built with, or
None. A record only.
- trading_days_per_year#
Trading days in a year, to annualize daily and longer bars.
- valuation_price_column#
Price variable the portfolio is valued at after each bar.