ParameterScan

class src.boatwright.Optimizations.ParameterScan.ParameterScan(strategy_class, symbol, broker, loss_function, scan, data, executor=<src.boatwright.BacktestExecutors.SequentialExecutor.SequentialExecutor object>)

A parameter scan runs a set of backtests for each combination of the specified set of parameters

Parameters:
  • strategy – strategy

  • symbol (str) – e.g. “BTC” or “APPL”

  • broker (BacktestBroker) – broker

  • data (DataFrame) – OHLCV data to conduct backtests

  • executer – handles running the backtests

  • scan (list) – list of strategy parameters

  • strategy_class (Strategy)

  • executor (BacktestExecutor)

Note

example scan list:

[
    {"fast_period": 10, "slow_period": 20},
    {"fast_period": 10, "slow_period": 30},
    {"fast_period": 15, "slow_period": 20},
    ...
]

Methods

calc_prerequisite_data_length()

finds prerequisite data scan for the ParameterScan by calling calc_prerequisite_data_length() for on each strategy

Returns:

(int) prerequisite data length

make_backtests()

Generates a list of backtests (self.backtests) each with a different combination of parameters

Returns:

None

run(verbose=False)

runs backtests using the executer

Parameters:

verbose – boolean toggle for printing progress bar to terminal

Returns:

(Strategy) The strategy which minimizes self.loss_function

set_backtests_data(data=None)

For each backtest trim excess data from the start, such that each backtest is for the same date range

Parameters:

data (dict) – OHLCV data for parameter scan