Code covered by the BSD License  

Highlights from
Cointegration and Pairs Trading with Econometrics Toolbox

4.33333

4.3 | 6 ratings Rate this file 160 Downloads (last 30 days) File Size: 11.07 MB File ID: #31060
image thumbnail

Cointegration and Pairs Trading with Econometrics Toolbox

by Stuart Kozola

 

15 Apr 2011

Demo files from the webinar of same title.

| Watch this File

File Information
Description

Files used in the April 14, 2011 webinar titled Cointegration and Pairs Trading with Econometrics Toolbox.

It is recomended that you watch the recording of the webinar: http://www.mathworks.com/wbnr55450

Required Products Econometrics Toolbox
MATLAB release MATLAB 7.12 (2011a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (24)
29 Apr 2011 Lars

Great contribution! This actually gave me the nugde to write a thesis about the subject. However, I struggle with accessing the odbc material on win7 x64, r2011a. I have spent too much time on troubleshooting now, I found some discussions online but never an resolution. I was hoping someone in here have had the same issue, and have resolved it. Thanks!

08 Jun 2011 Fuzhi Cheng

Expecting to see the use of Johansen procedure in the determination of cointegrating relationship in a multiple-assets stat arb trading environment. The pairs trading part of the webinar still focused on two series and EG -- no big change from previous webinar.

16 Jun 2011 Andy

I am having problems running the code for some reason. I get errors trying to run the egcitest(series). "Error using ==> Lagmatrix at 25 lagmatrix: wrong # of input arguments. If anyone could help, it would be greatly appreciated.

24 Jun 2011 PAvlos Giannakopoulos  
15 Jul 2011 Cathal fLANAGAN

Guys, similar to Andy, i am getting the "Error using ==> Lagmatrix at 25 lagmatrix: wrong # of input arguments issue.....

Any ideas?

14 Aug 2011 Suny Mou

Is it possible to see a format of the data file as I don't have the odbc download capability?

31 Aug 2011 lee

??? Undefined function or method 'fetch' for input arguments of type 'struct'.

Error in ==> getMinuteDataFromDB at 25
e = fetch(e);

help!help!help!
 I don't know how to solve,anyone can help me,it would be greatly appreciated!!!

31 Aug 2011 Kittikorn Tongnimitsawat

When you down load files, you shall see MS Access file in a folder. This code will connect to this database.

Therefore you will have to create ODBC to connect to MSAccess.

Hope this helps.

13 Sep 2011 lee

thank you,yes,now I know how to do;but I want to know there is someone use it to trade in futures markets,by .m to dll;I come from China,maybe someone can give me useful information,

17 Oct 2011 Michael Nam

I am missing Data_Canada needed in Demo1_CIWebinar.m from the zip file.

26 Oct 2011 Stuart Kozola

Data_Canada is in Econometrics Toolbox. You need a R2011a in order to run the demo.

26 Dec 2011 Jason

for those who got this kind of error messages: "Error using ==> Lagmatrix at 25 lagmatrix: wrong # of input arguments," you must be using the MFEToolbox which calls in the lagmatrix function from the USCD toolbox. From R2011a or -b, Matlab has introduced a built-in function with the same name. That should be why.

11 Jan 2012 Patrick Lee

it's cooool~

16 Feb 2012 Mate 2u

Using demo 2, if I have second-second data from 2.30pm to 9pm what adjustments would need to be made to create and backtest a strategy?

01 Mar 2012 Fuad

When calculating the trading ratio should the first leg qty be calculated as -1/reg1.coeff(2) instead of just -reg1.coeff(2)? Since the second leg is fixed at 1 we are effectively dividing through by the coeff of the second leg or have I miss interpreted the script...

01 Mar 2012 Fuad

When calculating the trading ratio should the first leg qty be calculated as -1/reg1.coeff(2) instead of just -reg1.coeff(2)? Since the second leg is fixed at 1 we are effectively dividing through by the coeff of the second leg or have I miss interpreted the script... (This is in the pairs.m function)

21 Mar 2012 Shichang

Fuad: Agree with you, should be -1/reg1.coeff(2)

21 Mar 2012 David Snaphaan

Dear Community,

I have the same problem as Lee in Aug 2011: ??? Undefined function or method 'fetch' for input arguments of type 'struct'.

Error in ==> getMinuteDataFromDB at 25
e = fetch(e);

Unfortunately the hint is no help for me. Do I have to change s.th. in the M-file?

Many Thanks,

Dave

06 Apr 2012 Semin Ibisevic  
06 Apr 2012 Andrew Baxter

Please be aware that this demo is not representative of what is achievable in reality. The demo has look ahead bias as it looks at future data to determine the trading signal to use on that data.

See pairs.m "Compute residuals over the next N days"

07 Apr 2012 gill0055 yeremenko

Thats very very true Andy. It contains forward data contamination bias.

13 Apr 2012 Fuzhi Cheng

I do not think there is a forward bias, but it indeed is a kind of curve-fitting based on historical data. I did simulated trading based on this strategy on a daily and intra-day basis, and it has been a losing one.

19 Apr 2012 Carl Sutcliffe

Stuart, I am having problems with downloading the intra-day data from the access db. I receive the error "??? Undefined function or method 'getMinuteDataFromDB' for input arguments of type 'char'."
Is there anyway to fix this?

10 May 2012 Peter Park

Hi,
Could you explain what does it mean if the date is 734548.554861111 in Access file? In other words, what is year,month,date,hour,minutes,second?
Thank you so much.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
cointegration Stuart Kozola 19 Apr 2011 13:28:18
trading Stuart Kozola 19 Apr 2011 13:28:18
pairs trading Stuart Kozola 19 Apr 2011 13:28:18
forecasting Stuart Kozola 19 Apr 2011 13:28:18
vec Stuart Kozola 19 Apr 2011 13:28:18
time series Stuart Kozola 19 Apr 2011 13:28:18
pairs trading Clinton 25 Apr 2011 20:20:20
trading Suny Mou 15 Aug 2011 02:52:28
cointegration Zoe 06 Oct 2011 11:08:43
cointegration Wilson 18 Nov 2011 01:33:37
cointegration Amine ISSAMI 23 Nov 2011 08:41:34
forecasting Amine ISSAMI 23 Nov 2011 08:41:51
pairs trading Amine ISSAMI 23 Nov 2011 08:41:54
time series Amine ISSAMI 23 Nov 2011 08:41:56
trading Amine ISSAMI 23 Nov 2011 08:42:00
vec Amine ISSAMI 23 Nov 2011 08:42:02
forecasting Konrad 04 Mar 2012 19:01:45
forecasting Almira 28 Mar 2012 06:26:06
pairs trading Almira 28 Mar 2012 06:26:10
cointegration Jeffrey Li 06 May 2012 19:41:04
cointegration Karen 30 May 2012 08:58:11

Contact us at files@mathworks.com