Skip to content

Releases: preritdas/wooster-trading-systems

Walk-forward optimization and multi-window backtesting.

22 Aug 00:31
7f579c8
Compare
Choose a tag to compare

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.

asciicast

CLI and Website

15 Aug 21:15
09457e6
Compare
Choose a tag to compare

Working CLI for backtesting, processing, optimizing, generating and building interactive plots, and launching pre-existing plots. No support yet for pretty printing performance metrics to console or formatting them in the results/stats/ subdirectory which Firebase and the index.html JavaScript association are already expecting.

Firebase has been deployed to https://wooster.preritdas.com with a basic JavaScript function to jump to the interactive plot or stats (nothing there yet) of any system (currently only Wooster One).