2727 BacktestMarketDataSourceService , BacktestPortfolioService , \
2828 BacktestService
2929from .app_hook import AppHook
30- from .reporting import BacktestReport
3130
3231logger = logging .getLogger ("investing_algorithm_framework" )
3332COLOR_RESET = '\033 [0m'
@@ -762,7 +761,7 @@ def run_backtest(
762761 date and time.
763762
764763 Returns:
765- Instance of BacktestReport
764+ Backtest: Instance of Backtest
766765 """
767766
768767 # Add backtest configuration to the config
@@ -853,16 +852,18 @@ def run_backtest(
853852 def run_backtests (
854853 self ,
855854 algorithms = None ,
856- strategies = None ,
855+ strategies : List [ TradingStrategy ] = None ,
857856 initial_amount = None ,
858857 backtest_date_ranges : List [BacktestDateRange ] = None ,
858+ snapshot_interval : SnapshotInterval = SnapshotInterval .TRADE_CLOSE ,
859+ risk_free_rate : Optional [float ] = None ,
860+ save = True ,
859861 output_directory = None ,
860862 checkpoint = False ,
861-
862- ) -> List [BacktestReport ]:
863+ ) -> List [Backtest ]:
863864 """
864- Run a backtest for a set algorithm. This method should be called when
865- running a backtest .
865+ Run a set of backtests for the provided algorithms or strategies
866+ with the given date ranges .
866867
867868 Args:
868869 algorithms (List[Algorithm]) (Optional): The algorithms to run
@@ -885,14 +886,15 @@ def run_backtests(
885886 when running backtests for a large number of algorithms
886887 and date ranges where some of the backtests may fail
887888 and you want to re-run only the failed backtests.
888- save_strategy: bool - Whether to save the strategy as part
889- of the backtest report. You can only save in-memory strategies
890- when running multiple backtests. This is because we can't
891- differentiate between which folders belong to a specific
892- strategy.
889+ save (bool): Whether to save the backtest report
890+ to the output directory. If True, then the backtest report
891+ will be saved to the output directory.
892+ snapshot_interval (SnapshotInterval): The snapshot interval to
893+ use for the backtest. This is used to determine how often
894+ the portfolio snapshot should be taken during the backtest.
893895
894896 Returns
895- List of BacktestReport instances
897+ List[Backtest]: List of Backtest instances
896898 """
897899 logger .info ("Initializing backtests" )
898900 reports = []
@@ -959,6 +961,9 @@ def run_backtests(
959961 initial_amount = initial_amount ,
960962 output_directory = output_directory ,
961963 algorithm = algorithm ,
964+ save = save ,
965+ snapshot_interval = snapshot_interval ,
966+ risk_free_rate = risk_free_rate
962967 )
963968 reports .append (report )
964969
0 commit comments