The main useful feature of this checkpoint is walk-forward optimization with predefined data windows. Essentially, within the systems/
architecture module, specify walk-forward windows in the Params
class. ("train" is mandatory, "up," "down," and "chop" are optional).
class Params:
"""
Strategy meta-configurations. These are not indicator settings, or
any such optimizable parameters; rather, symbols, timeframes,
date-ranges, etc.
"""
symbol = "AAPL"
timeframe = "1m"
walkforward = {
"train": (dt.date(2014, 7, 1), dt.date(2015, 8, 31)),
"up": (dt.date(2021, 7, 1), dt.date(2022, 1, 1)),
"down": (dt.date(2018, 9, 1), dt.date(2019, 2, 1)),
"chop": (dt.date(2020, 9, 1), dt.date(2021, 2, 20))
}
optimizers: dict = {
"rsi_period": range(3, 30, 1),
"buy_rsi_entry": range(10, 30, 1),
"buy_rsi_target": range(70, 90, 1),
"sell_rsi_entry": range(70, 90, 1),
"sell_rsi_target": range(10, 30, 1),
"constraint": lambda params: params.buy_rsi_entry < params.buy_rsi_target and params.sell_rsi_entry > params.sell_rsi_target
}
Other Additions
- Data cache: initialize, view, and manage a local cache data repository to speed up data aggregation in the processing phase. When tuning and reprocessing a strategy, the walk-forward data windows are often the same, so it doesn't make sense to (a) use up a data rate limit or (b) wait for the same data to download again (especially when loading many years of intraday data for testing and optimization). An example (more sample CLI commands below):
wooster cache init aapl --interval 1m --lookbackyears 10
to store 10 years of minute bar data on AAPL, automatically used whenever any program feature tries to access 1m AAPL data within the last 10 years. - No-loss incremental aggregation of market data to comply with freemium data provider restrictions and rate limits. This was after switching data providers, from yfinance (free) to Finnhub (paid), as yfinance had intraday period restrictions.
- Automatic Firebase deploys to website on git push with GitHub Actions
- Nice looking, informative progress bars and status updates (from Rich) throughout the backtest, optimization, and walk-forward processes. Example below.