tag:blogger.com,1999:blog-35364652.post6598019561153436816..comments2024-03-22T10:29:59.088-04:00Comments on Quantitative Trading: Excel ADF testErnie Chanhttp://www.blogger.com/profile/02747099358519893177noreply@blogger.comBlogger59125tag:blogger.com,1999:blog-35364652.post-16146655686605287122019-08-19T07:59:02.871-04:002019-08-19T07:59:02.871-04:00Hi Roger,
If you are using ADF test for cointegrat...Hi Roger,<br />If you are using ADF test for cointegration of two assets, the residual is that of the linear regression between the two prices.<br /><br />To simplify matters, you can just use the CADF test instead. There will be no need to run a regression, and no need to test residuals.<br /><br />Ernie<br />Ernie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-56520531506223694452019-08-19T03:32:51.785-04:002019-08-19T03:32:51.785-04:00Hi Ernie,
when you talking about the residual, is...Hi Ernie,<br /><br />when you talking about the residual, is it the equation of :(asset 1) - (coint.coef.*(asset 2)<br />or the residual of regression of the 2 stock ?<br /><br />And the residual is tested for Adf test for a Delta diff of the residual and a 1 lag residual result.<br /><br />Is i am right ?<br /><br />RogerRogerhttps://www.blogger.com/profile/11261650507292639971noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-15474113772820043312019-08-19T03:25:22.190-04:002019-08-19T03:25:22.190-04:00Hi Ernie,
when you talking about the residual, is...Hi Ernie,<br /><br />when you talking about the residual, is it the equation of :(asset 1) - (coint.coef.*(asset 2)<br />or the residual of regression of the 2 stock ?<br /><br />And the residual is tested for Adf test for a Delta diff of the residual and a 1 lag residual result.<br /><br />Is i am right ?<br /><br />RogerAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-26195240886344742002018-07-03T04:29:28.152-04:002018-07-03T04:29:28.152-04:00Hi, everyone.
Unfortunately, 'quantcode.com&#...Hi, everyone.<br /><br />Unfortunately, 'quantcode.com' site closed down a few years ago.<br />So, can you somebody please send me the downloaded excel file?<br /><br />My email address is 'zenithgogo@naver.com'.<br /><br />I'll thank you in advance.<br /><br />Hj KimAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-89064455797883222372018-06-08T15:18:19.646-04:002018-06-08T15:18:19.646-04:00Hi ernie i am unable to download adf excel plugin....Hi ernie i am unable to download adf excel plugin.<br />Kindly email "santoshkhooda@gmail.com"<br /><br />Any one else having pls email "santoshkhooda@gmail.com"Anonymoushttps://www.blogger.com/profile/13513293132966466750noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-3366732236848211392017-10-08T08:09:09.485-04:002017-10-08T08:09:09.485-04:00Hi,
Thanks for your kind words on my books.
Zscor...Hi,<br />Thanks for your kind words on my books.<br /><br />Zscore is based on the spread (i.e. residuals) of prices. One does not take the spread of the Zscores of residuals.<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-9645103451253331542017-10-07T11:02:12.201-04:002017-10-07T11:02:12.201-04:00Hi Ernie,
when you look for the z score of mean r...Hi Ernie,<br /><br />when you look for the z score of mean reversion pair, do i take the spread 0f the pair for the z score calculation or the residual of that pair?<br /><br />P.S. i love your books and this blog too : )Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-8680830310222377802017-04-09T07:49:20.303-04:002017-04-09T07:49:20.303-04:00Hi Ajay,
I don't actually use that Excel progr...Hi Ajay,<br />I don't actually use that Excel program for my own ADF test, as I am a Matlab user. If you want to understand how ADF test work in general, and to obtain the sample input data files, please see my second book Algorithmic Trading Example 2.1.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-52421102021331567822017-04-08T11:37:09.482-04:002017-04-08T11:37:09.482-04:00Hi Erin,
Am new to all this. Request if you can p...Hi Erin,<br /><br />Am new to all this. Request if you can please send an excel file which can help me understand the working in details along with formulas. <br /><br />have been trying really hard to understand the conceptAjayhttps://www.blogger.com/profile/10869124776506217773noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-87324551429520900482014-02-12T07:56:43.848-05:002014-02-12T07:56:43.848-05:00Hi Chad,
I did not write the Excel program, nor di...Hi Chad,<br />I did not write the Excel program, nor did I write the note that we should just use log(MSFT)-log(GOOG) as the signal. My strategy would be to use linear regression to find the best hedge ratio, and use the residual of this LR as signal.<br /><br />The residual can be standardized or not: either can be used as signal.<br /><br />I never use that Excel code myself, as I am a Matlab-user, so I am afraid I cannot explain that code to you.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-138990538570320942014-02-12T06:08:18.139-05:002014-02-12T06:08:18.139-05:00Hi Ernie,
I downloaded the excel file you shared ...Hi Ernie,<br /><br />I downloaded the excel file you shared a few posts above http://www.quantcode.com/modules/mydownloads/singlefile.php?lid=573<br /><br />According to the description in the post there it says, "To know if they are mean reverting, simply create a series = Log(MSFT price)-Log(GOOG price). Paste the data into Sheet1 in cell A4" <br /><br />However in the comments section here you mentioned one should take the residuals and use that as the time series. Is the description for the excel file wrong?<br /><br />(btw if I regress stock A's return on stock B's return, the residual you talk about would be the error variable and not the standard dev of that error term right? And the whole point of the test would be to test if the residuals are stationary and have a mean of 0 and if so the pair are cointegrated?)<br /><br />And one more dumb question: in the excel file you linked to, in cell A4 for the time series, do I place the most recent data at the top or the oldest data?<br /><br />Thanks and kind regards,<br />ChadChadnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-50789575560403312182013-04-02T18:06:26.061-04:002013-04-02T18:06:26.061-04:00Aditya,
There is no point in using intraday data f...Aditya,<br />There is no point in using intraday data for cointegration tests, unless you are interested in trading intraday. If you do, you have to concatenate all the intraday prices together, and remove the overnight gap, before you can apply cointegration test.<br /><br />I also seriously doubt that you can apply Excel on sub millisecond prices due to memory and CPU constraints.<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-75663145166829678822013-04-02T15:08:45.739-04:002013-04-02T15:08:45.739-04:00Earnie,
I'm using this spreadsheet but I am a...Earnie,<br /><br />I'm using this spreadsheet but I am a little confused on the ln(A)-ln(B) values. Can I use intraday prices (ie. every second prices) or do I have to use EndofDay prices so there is one datapoint per day?<br /><br />Will using more frequent data screw up my cointegration test?<br /><br />I have access to submillisecond price data and I want to make sure I can use it instead of EoD prices...Adityahttps://www.blogger.com/profile/02889545160554262054noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-36806881099495092752012-07-18T14:06:54.799-04:002012-07-18T14:06:54.799-04:00thank you very much
regards.
Michelthank you very much<br />regards.<br />MichelAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-85064312132099870982012-07-18T13:48:55.782-04:002012-07-18T13:48:55.782-04:00Hi Michel,
In your equation, 1 share of Y is hedge...Hi Michel,<br />In your equation, 1 share of Y is hedged with slope shares of X.<br />So sharesY will be hedged with slope*sharesY of X.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-33164866684486583972012-07-18T11:08:55.799-04:002012-07-18T11:08:55.799-04:00Hello Ernie,
so I have a OLS line of a cointegrate...Hello Ernie,<br />so I have a OLS line of a cointegrated pair.<br />PriceY = PriceX * slope + intercept<br />lets suppose I want to trade about $1mm of StockY, so I find the number of shares to trade StockY (sharesY). How do I go about finding the number of shares to trade StockX (sharesX) ?<br />thank you.<br />MichelAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-83545472435668163742012-04-26T21:21:15.324-04:002012-04-26T21:21:15.324-04:00Hi anon,
It appears that http://www.quantcode.com/...Hi anon,<br />It appears that http://www.quantcode.com/modules/mydownloads/singlefile.php?lid=573<br />has one.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-19097543723751533542012-04-26T17:27:07.436-04:002012-04-26T17:27:07.436-04:00Hi Ernie, the link to the Excel package is dead......Hi Ernie, the link to the Excel package is dead...anywhere else we we can get it?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-51932066865624927802011-12-18T18:17:12.948-05:002011-12-18T18:17:12.948-05:00Anon,
Both should be tried, and usually the result...Anon,<br />Both should be tried, and usually the results are the same. But to eliminate order-dependence, use Johansen test where this problem does not arise.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-70473100300850881562011-12-18T05:49:59.672-05:002011-12-18T05:49:59.672-05:00Ernie,
should the coint be done on the residual ...Ernie,<br /><br /> should the coint be done on the residual of stk 1 and 2 or the residual of stk 1 and 2 against time?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-63429197505822919042011-03-28T13:35:29.508-04:002011-03-28T13:35:29.508-04:00Michel,
You should first use ols regression to fin...Michel,<br />You should first use ols regression to find the hedgeRatio between the closing prices of the 2 stocks, then use this hedgeRatio to find the spread of the 2 closing prices, and finally use adf test to find if this spread is stationary.<br /><br />Of course, if you have the cadf test available, you can run it directly on the 2 closing prices directly to test for cointegration instead.<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-80256286875579397252011-03-28T11:04:34.921-04:002011-03-28T11:04:34.921-04:00Ernie,
when I want to use the ADF-test to verify i...Ernie,<br />when I want to use the ADF-test to verify if two stocks (stock1 and stock2) series are cointegrated how should I preoceed? Should I test the ADF on the difference between the stock2 price and the OLS regression line of stock1 and stock2?<br />Should I use closing price or log of that?<br />thank you, regards<br />Michel Casparymichelcasparyhttps://www.blogger.com/profile/11038961386939478284noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-4132990427585645152011-03-27T19:24:46.462-04:002011-03-27T19:24:46.462-04:00Michel,
I have not used the Excel adf program myse...Michel,<br />I have not used the Excel adf program myself, but I am guessing that you need to input a price series with ascending order in dates.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-91863798591957428962011-03-25T16:59:53.224-04:002011-03-25T16:59:53.224-04:00Ernie,
I´m a beginner at the subject and I´ve down...Ernie,<br />I´m a beginner at the subject and I´ve downloaded that ADF spreadsheet to test a few stocks for cointegration.<br />I have the closing price series for these stocks and I would like to know what kind of series I need to enter at that spreadsheet for the ADF-test.<br />thank you and congratulations for your blogmichelcasparyhttps://www.blogger.com/profile/11038961386939478284noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-85945414790356427632011-03-11T13:37:28.479-05:002011-03-11T13:37:28.479-05:00Hi Kan,
If you want to find a basket of currencies...Hi Kan,<br />If you want to find a basket of currencies that cointegrate, you should use the Johansen test instead.<br /><br />A free software package for running adf and Johansen tests in Matlab is available from spatial-econometrics.com<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.com