@@ -721,8 +721,7 @@ def run_backtest(
721
721
Run a backtest for an algorithm.
722
722
723
723
Args:
724
- backtest_date_range: The date range to run the backtest for
725
- (instance of BacktestDateRange)
724
+ backtest_date_range (BacktestDateRange): The date range to run the backtest for
726
725
name: The name of the backtest. This is used to identify the
727
726
backtest report in the output directory.
728
727
initial_amount: The initial amount to start the backtest with.
@@ -732,9 +731,13 @@ def run_backtest(
732
731
that needs to be backtested.
733
732
strategies (List[TradingStrategy) (Optional): List of strategy
734
733
objects that need to be backtested
735
- algorithm:
736
- output_directory: str - The directory to
737
- write the backtest report to
734
+ algorithm (Algorithm) (Optional): The algorithm object that
735
+ needs to be backtested. If this is provided, then the
736
+ strategies and tasks of the algorithm will be used for the
737
+ backtest. If this is not provided, then the strategies
738
+ and tasks provided in the strategies parameter will be used.
739
+ output_directory: str - The directory to write the
740
+ backtest report to
738
741
save_strategy: bool - Whether to save the strategy
739
742
as part of the backtest report. You can only save in-memory
740
743
strategies when running multiple backtests. This is because
@@ -756,7 +759,6 @@ def run_backtest(
756
759
Returns:
757
760
Instance of BacktestReport
758
761
"""
759
-
760
762
# Add backtest configuration to the config
761
763
self .set_config_with_dict ({
762
764
ENVIRONMENT : Environment .BACKTEST .value ,
@@ -765,7 +767,9 @@ def run_backtest(
765
767
DATABASE_NAME : "backtest-database.sqlite3" ,
766
768
DATABASE_DIRECTORY_NAME : "backtest_databases" ,
767
769
BACKTESTING_INITIAL_AMOUNT : initial_amount ,
768
- SNAPSHOT_INTERVAL : snapshot_interval .value ,
770
+ SNAPSHOT_INTERVAL : SnapshotInterval .from_value (
771
+ snapshot_interval
772
+ ).value
769
773
})
770
774
771
775
self .initialize_config ()
0 commit comments