Code covered by the BSD License  

Highlights from
Cointegration and Pairs Trading with Econometrics Toolbox

4.3

4.3 | 10 ratings Rate this file 102 Downloads (last 30 days) File Size: 11.1 MB File ID: #31060
image thumbnail

Cointegration and Pairs Trading with Econometrics Toolbox

by

 

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 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (35)
27 May 2014 Koranit

Error in getMinuteDataFromDB (line 25)
e = fetch(e);

how to fix?

13 May 2014 puqiao

I just look the title for interest, I thank you first here.

24 Apr 2014 EHSAN ramezanifar  
24 Apr 2014 EHSAN ramezanifar

It's good but not practical.

24 Apr 2014 Koranit

how to download ??

24 Apr 2014 Koranit

good !!

22 Jan 2014 Peter O

Demo1 works fine, but Demo2 is a non-starter. When I tried to run/evaluate the section "Load Intraday from a database" I get the following:

Undefined function 'setdbprefs' for input arguments of type 'struct'.

Error in getMinuteDataFromDB (line 17)
setdbprefs(s)

Running the whole demo at once gives me similar data issues. Any idea how to fix?

18 Aug 2013 Stephen Wang

the quantity on y(:,1) should be -1/reg1.coeff(2)./s(i:i+N-1,2);

18 Aug 2013 Stephen Wang

yea i think there is a look forward bias as well for generating the trading signal based on forward looking residuals predicted by egcitest.

30 May 2013 Mirko

Stuart, thanks for your contribution. It Looks to me that this is not able for real live trading because the "reg2" value "res" (of the egcitest) is changing its history with every new datapoint. If for example the res value at Bar 8 is -.9 for bar 7 the res value might be +0.8 for bar 7 at bar 20. Do you know a solution for this issue?

10 May 2013 SteffenR88

is the file offline?
I have a problem with opening the file!

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.

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?

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.

07 Apr 2012 gill0055 yeremenko

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

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"

06 Apr 2012 Semin Ibisevic  
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

21 Mar 2012 Shichang

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

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)

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...

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?

11 Jan 2012 Patrick Lee

it's cooool~

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.

26 Oct 2011 Stuart Kozola

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

17 Oct 2011 Michael Nam

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

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,

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.

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!!!

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?

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?

24 Jun 2011 PAvlos Giannakopoulos  
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.

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.

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!

Contact us