run_backtest_inline#
API documentation for tradeexecutor.backtest.backtest_runner.run_backtest_inline Python function.
- run_backtest_inline(*ignore, start_at=None, end_at=None, minimum_data_lookback_range=None, client, decide_trades, create_trading_universe=None, create_indicators=None, indicator_combinations=None, indicator_storage=None, cycle_duration=None, initial_deposit=None, reserve_currency=None, trade_routing=None, universe=None, routing_model=None, max_slippage=0.01, candle_time_frame=None, log_level=30, data_preload=True, data_delay_tolerance=None, name='backtest', allow_missing_fees=False, engine_version=None, strategy_logging=False, parameters=None, mode=ExecutionMode.backtesting, max_workers=8, grid_search=False, execution_context=<ExecutionContext backtesting, unspecified engine version>, execution_test_hook=None, three_leg_resolution=True)[source]#
- Run backtests for given decide_trades and create_trading_universe functions. - Does not load strategy from a separate .py file. Useful for running strategies directly from notebooks. - Parameters:
- name (str) – Name for this backtest. If not set default to “backtest”. 
- start_at (Optional[datetime]) – - When backtesting starts. - If not given take the date of the first candle. 
- When backtesting ends. - If not given take the date of the last candle. 
- minimum_data_lookback_range (Optional[timedelta]) – If start_at and end_at are not given, use this range to determine the backtesting period. Cannot be used with start_at and end_at. Automatically ends at the current time. 
- client (Optional[Client]) – You need to set up a Trading Strategy client for fetching the data 
- decide_trades (tradeexecutor.strategy.strategy_module.DecideTradesProtocol | tradeexecutor.strategy.strategy_module.DecideTradesProtocol2 | tradeexecutor.strategy.strategy_module.DecideTradesProtocol3 | tradeexecutor.strategy.strategy_module.DecideTradesProtocol4) – Trade decider function of your strategy 
- create_trading_universe (tradeexecutor.strategy.pandas_trader.trading_universe_input.CreateTradingUniverseProtocol | tradeexecutor.strategy.pandas_trader.trading_universe_input.CreateTradingUniverseProtocolV2) – Universe creation function of your strategy. You must give either create_trading_universe or universe. 
- universe (Optional[TradingStrategyUniverse]) – The pregenerated universe for this backtest. You must give either create_trading_universe or universe. 
- cycle_duration (tradeexecutor.strategy.cycle.CycleDuration | None) – Strategy cycle duration 
- candle_time_frame (Optional[TimeBucket]) – Candles we use for this strategy 
- initial_deposit (float | None) – how much reserve currency we allocate as a capital at the beginning of the backtest 
- reserve_currency (tradeexecutor.strategy.reserve_currency.ReserveCurrency | None) – Reserve currency used for the strategy 
- trade_routing (Optional[TradeRouting]) – Routing model for trades 
- routing_model (Optional[BacktestRoutingModel]) – Use a predefined routing model. 
- max_slippage – Max slippage tolerance for trades before execution failure 
- log_level – Python logging level to display log messages during the backtest run. 
- data_preload – Before the backtesting begins, load and cache datasets with nice progress bar to the user. 
- data_delay_tolerance (Optional[Timedelta]) – - What is the maximum hours/days lookup we allow in the backtesting when we ask for the latest price of an asset. - The asset price fetch might fail due to sparse candle data - trades have not been made or the blockchain was halted during the price look-up period. Because there are no trades we cannot determine what was the correct asset price using {data_delay_tolerance} data tolerance delay. - The default value None tries to guess the value based on the univerity candle timeframe, but often this guess is incorrect as only analysing every pair data gives a correct answer. - The workarounds include ignoring assets in your backtest that might not have price data (look up they have enough valid candles at the decide_trades timestamp) or simply increasing this parameter. - This parameter is passed to - tradeexecutor.backtest.backtest_pricing.BacktestSimplePricingModel.
- allow_missing_fees – - Allow synthetic data to lack fee information. - Only set in legacy backtests. 
- engine_version (Optional[str]) – - The used TS engine version/ 
- strategy_logging – - Enable PositionManager log output. - Set True to display output. See - tradeexecutor.strategy.pandas_trading.position_manager.PositionManager.log()for usage.
- parameters (Optional[Union[Type, StrategyParameters]]) – - Strategy parameters as a singleton class. - Allows using the same parameter structure for single backtest runs and gridtesting. 
- max_workers – - Maximum number of worker processes to use to calculate indicators. - Set to 1 to disable multiprocessing / debug. 
- create_indicators (tradeexecutor.strategy.pandas_trader.indicator.CreateIndicatorsProtocolV1 | tradeexecutor.strategy.pandas_trader.indicator.CreateIndicatorsProtocolV2) – 
- indicator_combinations (set[tradeexecutor.strategy.pandas_trader.indicator.IndicatorKey] | None) – 
- indicator_storage (tradeexecutor.strategy.pandas_trader.indicator.DiskIndicatorStorage | None) – 
- mode (ExecutionMode) – 
- execution_test_hook (tradeexecutor.cli.loop.ExecutionTestHook | None) – 
 
- Returns:
- tuple (State of a completely executed strategy, trading strategy universe, debug dump dict) 
- Return type: