run_backtest_inline(*ignore, start_at, end_at, client, decide_trades, cycle_duration, initial_deposit, reserve_currency, trade_routing, create_trading_universe=None, universe=None, routing_model=None, max_slippage=0.01, candle_time_frame=None, log_level=30, data_preload=True, name='backtest')[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.

  • name (str) – Name for this backtest. If not set default to “backtest”.

  • start_at (datetime) – When backtesting starts

  • end_at (datetime) – When backtesting ends

  • client (Optional[Client]) – You need to set up a Trading Strategy client for fetching the data

  • decide_trades (DecideTradesProtocol) – Trade decider function of your strategy

  • create_trading_universe (Optional[CreateTradingUniverseProtocol]) – 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 (CycleDuration) – Strategy cycle duration

  • candle_time_frame (Optional[TimeBucket]) – Candles we use for this strategy

  • initial_deposit (float) – how much reserve currency we allocate as a capital at the beginning of the backtest

  • reserve_currency (ReserveCurrency) – 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.


tuple (State of a completely executed strategy, trading strategy universe, debug dump dict)

Return type

Tuple[State, TradingStrategyUniverse, dict]