We are going to build a Dakota 3 market timing model that predicts the 5 period change in the natural log of the daily SP closing price using support vector machines for k-step ahead modeling. The K-Step Ahead SVMPredictors work like this:
- A support vector machine is trained to predict the input series 1 time period into the future. For our system, the most recent 5 values of the 5 period change in the natural log of the daily SP closing price will be the input series.
- If we only want to predict ahead 1 time period then we simply feed the most recent input values into our SVM.
- If we want to predict more than 1 time period into the future then we need to start with step 2. and then iteratively remove the oldest value in our input series while appending the last predicted value to form the next input series that is then fed into the model to produce the next predicted value. This is why the algorithm is named k-step ahead.
When using K-Step Ahead SVMPredictors the trading signal will either be the predicted value k steps ahead or the difference between the predicted value and either the most recent value in our input series or the predicted value some small number of steps ahead. For this system the trading signal will be the difference between the predicted value k steps ahead and the predicted value 1 step ahead. The reason for this is that the system applies a trading delay of 1 trading day. i.e. trades are placed MOC on the trading day following the trading day that the systems were updated.
The first step is to load the data into Dakota 3.
The SP futures data is non-adjusted and is being loaded from January 2nd 1990 to January 15 2015. The next step is to configure the Equity settings. We are using the default equity engine, have set the trading delay to 1 and slippage and commission to zero. Note that the trading delay corresponds to the ‘Project the signal by’ setting.
Now we are up to something a little more interesting. We need to define the input series that will be used for the modeling. This is done on the Dakota 3 Indicators tab. Note that k-step ahead predictors do not require a target series. The input series is used to generate the target series behind the scenes.
What I am calling a ‘series’ corresponds to a variable on the Indicators tab. The variable that is listed after the closing value of the traded security will be used as the input series by the K-Step Ahead SVMPredictor. The Ln (natural log) of the SP closing value has been multiplied by 100. There is no need to multiply by 100 in this case. It’s just a habit of mine.
The bulk of the system configuration is done on the Dakota 3 Swarm tab. In the image below you can see that we are using 1 swarm of 15 trade bots. Each bot will have it’s own support vector machine. The Halton Initializer is used to initialize the bot parameter values within the adapted parameter space. The Flocking Boid Adapted swarm adapter has been selected along with the PropOfPerfect bot performance add-in. The Lookback Period for the PropOfPerfect bot performance add-in has been set to 200 bars.
In the image below we can see the parameter values for the K-Step Ahead Kernel SVMPredictor. Predict Bars is set to 3 so we are predicting the value of the input series 3 trading days into the future. The Modeling Period is 200 which means there will be 200 training samples used to train the support vector machines. The Input Depth is 5 so the most recent 5 indicator input series values will be used to form the inputs for 1 training sample. C and Sigma are parameters of the SVM which are being adapted by the swarm walking-forward.
Predict Change is set to True because we want to predict the change in our input series and use that as the trading signal. The Retrain Period is 20 which will result in the SVMs being rebuilt every 20 trading days. This provides the system with the potential to adapt to changing market dynamics walking-forward.
Here is the equity curve generated by running the system.
Model performance statistics appear below.
You might be wondering how I came up with the 5 period change of the log of the close for the input series. My usual approach is to keep 5 to 10 years of data for out-of-sample testing when developing a new systems. I basically try different input parameter values until I find one that looks promising over the modeling data. I’ll provide an overview of that procedure in another post as this post is long enough.