BacktestTradingSessionBuilder¶
-
class
qf_lib.backtesting.trading_session.backtest_trading_session_builder.
BacktestTradingSessionBuilder
(data_provider: qf_lib.data_providers.general_price_provider.GeneralPriceProvider, settings: qf_lib.settings.Settings, pdf_exporter: qf_lib.documents_utils.document_exporting.pdf_exporter.PDFExporter, excel_exporter: qf_lib.documents_utils.excel.excel_exporter.ExcelExporter)[source]¶ Bases:
object
Class used to build a Trading Session with all necessary elements, connections and dependencies. By default it uses the following settings:
backtest name is set to “Backtest Results”
initial cash is set to 10000000
SimulatedContractTickerMapper is used to map contracts to tickers
no commissions are introduced (FixedCommissionModel(0.0))
no slippage is introduced (PriceBasedSlippage(0.0))
SimplePositionSizer is used
Methods
build
(start_date, end_date)Builds a backtest trading session.
set_benchmark_tms
(benchmark_tms)Sets the benchmark timeseries.
- Parameters
data_provider (DataProvider) – data provider used to download all fields and prices used during trading
settings (Settings) – object containing all necessary settings, used for example for connection purposes
pdf_exporter (PDFExporter) – used to export all trading statistics to PDF
excel_exporter (ExcelExporter) – used to export trading data to Excel
-
build
(start_date: datetime.datetime, end_date: datetime.datetime) → qf_lib.backtesting.trading_session.backtest_trading_session.BacktestTradingSession[source]¶ Builds a backtest trading session.
- Parameters
start_date (datetime) – starting date of the backtest
end_date (datetime) – last date of the backtest
- Returns
trading session containing all the necessary parameters
- Return type
-
set_benchmark_tms
(benchmark_tms: qf_lib.containers.series.qf_series.QFSeries)[source]¶ Sets the benchmark timeseries. If set, the TearsheetWithBenchamrk will be generated.
- Parameters
benchmark_tms (QFSeries) – timeseries of the benchmark