~~~ Training Algo Trading Strategies ~~~


Just like athletes, algorithmic trading systems should be trained - preferably in regular intervals for adapting them to changing market conditions. If a trading system is not trained, it will often lose its edge and become unprofitable after a relatively short time.  There are three different elements of strategies that require training:

  • Strategy parameters are adapted to the market by parameter optimization
  • Machine learning models learn trading rules or patterns by model training
  • Portfolio strategies adapt their capital allocation by factor generation

All three require quite different training methods. But they all can be combined with walk-forward analysis. Depending on the algorithm, some strategies must be trained with all three methods together.

Historical market data, price curves, and/or backtest trade returns are normally used for the training data set.  For optimizing a strategy parameter, a range of different parameters values is backtested with historical price data for finding the best suited value. For example, imagine an automated trading system that buys and sells a Forex position when the price curve crosses its Simple Moving Average (SMA), and puts a stop loss at a certain distance from the price. This strategy would normally be trained to determine the best suited SMA period between 30 and 300 bars, and the optimal stop distance between 10 and 100 pips.

Why training?

Contrary to popular belief, the goal of parameter optimizing should not be the highest backtest profit. A proper algo trading parameter optimization has 3 main purposes:

  • visualizing which parameters affect the performance in which way,
  • sturdying the strategy by making it more robust against market fluctuations,
  • adapting the strategy to different assets of a portfolio, or to changing markets.

A live trading algo system should also be able to automatically re-train itself in regular intervals with recent price data or recent trading results. In this way the system stays permanently adapted to the market.

If the strategy uses a machine learning algorithm, such as a neural net or decision tree, training works a bit differently. It generates a set of data values - named 'signals' or 'features' - and a training target, such as a price changes or trade return. This allows the algorithm to learn predicting future prices or the outcomes of future trades. This process is repeated in intervals for keeping the learning algorithm up to date. This is rules training or model training, as opposed to parameter training. Since rules or models training bears a high danger of overfitting, out-of-sample or walk-forward backtesting is mandatory.

The wrong way to optimize a trading system - and the right way

For parameter optimization, algo trading software often uses Genetic Algorithms or Brute Force optimization in order to find the highest performance peak in the parameter space. That's the main reason why so many perfectly optimized strategies fail miserably in live trading. These methods do not produce robust strategies. They generate panda bears that are perfectly adapted to a specific historical data set, but won't survive anywhere else.  

Zorro countour plot from a 2-parameter brute force optimization
Performance landscape from a 2-parameter optimization.
This strategy has no stable performance plateau.

Zorro prefers a different method. Its default Ascent optimizer does not seek performance peaks, but stable performance plateaus, and places the parameters into their 'sweet spots'. This does not necessarily produce the best backtest performance, but it produces robust strategies with better live trading results. For special purposes, conventional genetic or brute force optimization is also available, and external optimization modules, for instance in R packages, are also supported.

There's also another difference to conventional strategy training. Most platforms have a menu for entering the parameters and training settings. Zorro has no such menu. Training is coded in the strategy script just like anything else (see the machine learning script as an example). This makes optimization an integral part of the strategy and allows automated re-training the strategy while trading live.

Parameter training normally requires thousands of backtests with different parameter sets. The speed of the backtest module is therefore essential for effective optimization. Zorro can optimize a multi-parameter intraday portfolio system in a few seconds. To achieve this, it uses massive parallel processing by activating multiple processor cores.

  

"Take Money From The Rich And Give It To The Poor"