NaN.

TutorialMachine LearningLast updated

Kalman Filters and Pairs Trading 1[ Edit ]

To determine the hedge ratios for a pair of cointegrated price series is quite simple: using their historical data and performing OLS for a regression fit or Johansen test to find the models.

My concern here is the same found in the last two experiments (1,2), high MMD and volatility, because of the basis of our strategy and I would like to find a way to improve it by solving the stationarity issue. In all the strategies we used so far, we only took a moving look-back period and found the regression coefficient over a specific time period. But if the look-back period is short, the omission of the earliest bar and inclusion of the latest bar as time goes on can cause errors on the hedge ratio. This problem also exists in the case when we use a moving average or moving standard deviations to calculate the current mean and standard deviation. As for the solution, we should improve our model by adding more weight to the latest dataset and less weight to the earlier data without an arbitrary cutoff point. Here I choose Kalman Filters as the scheme to update the hedge ratio over time.

The Kalman Filter is an algorithm that uses noisy(including outliers) observations of a system over time to estimate the parameters of the system and predict future observations. At each time step, it makes a prediction, takes in a measurement, and updates itself based on how the prediction and measurement compare. By doing the adjustment by itself, we actually generate a predictive learning model which can learn and update itself through the data we feed it. The assumption behind this model is that the hidden variable at time t is a linear function of itself at time t -1 with noise and the noise obeys random walk distributions.

In this case, I choose the ‘WWAV’ (WhiteWave Foods Co) one of the organic food companies as the object. I use colorful scatter plot to show the correlation between WWAV and SPY(S&P500) over 2 years(from 2013–01–01 to 2015–01–01) with each point colored by date. From the graph, we can tell that the changes of these two cannot be described accurately by simple linear regression with constant slope and intercept.

Actually, we can find out best estimates of α and β over time. Also, we can see how much the parameters fluctuate over extended periods of time. If we are using beta hedging strategy, it is increasingly important to estimate beta accurately.

Now, we can plot how the system evolves through time using Kalman Filters; we plot every fifth state(linear model) below, the black line is the one when we use ordinary OLS regression on the full dataset.

All the graphs I posted before use the close price as the measurement. But we use returns instead of prices to do the regression generally. The next step I will show the same linear regression structure on the returns data by Kalman Filter method.

Because the Kalman filter updates its estimates at every time step and tends to weigh recent observations more than older ones, another useful application is the estimation of rolling parameters of the data.For instance, if we have already computed the moving Sharpe ratio, we can smooth it using a Kalman filter.

In the next article, I will add Kalman Filters in my pairs trading model and try to use it to smooth the hedge ratio of the strategy.

Please feel free to comment on inefficiencies about anything I explained here as usual. I am always open to the mistakes and willing to learn from them as a beginner in this area.

*Reference:***https://mktstk.wordpress.com/2015/08/18/the-kalman-filter-and-pairs-trading/** **Quantopian: Kalman Filter Notebookhttp://www.thealgoengineer.com/2014/online_linear_regression_kalman_filter/**

Read more…(617 words)

About the contributor:

Haohan Wang

100%

Loading…

Join the discussion. Add a reply…

Post

Ready to join our community?

Sign up below to automatically get notified of new courses, get **reminders** to finish ones you subscribe to, and **bookmark** lessons to read later.

Continue with Facebook

— OR —

Your Full Name

Email address

I have an account. Log in instead

By signing up, you agree to our Terms and our Privacy Policy.

Popular Courses

New Courses

About Us

Get in touch

Copyright 2016-18, Compose Labs Inc. All rights reserved.