tag:blogger.com,1999:blog-35364652.post9094760950592190665..comments2022-11-30T05:11:53.159-05:00Comments on Quantitative Trading: An additional ETF pairErnie Chanhttp://www.blogger.com/profile/02747099358519893177noreply@blogger.comBlogger33125tag:blogger.com,1999:blog-35364652.post-14720855092750358922017-07-16T07:40:32.868-04:002017-07-16T07:40:32.868-04:00Hi,
This blog is built on blogspot.com. No Wordpre...Hi,<br />This blog is built on blogspot.com. No Wordpress or HTML knowledge required.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-84579045214967931292017-07-15T21:40:00.400-04:002017-07-15T21:40:00.400-04:00Howdy are using Wordpress for your blog platform?
...Howdy are using Wordpress for your blog platform?<br />I'm new to the blog world but I'm trying to get started and <br />set up my own. Do you require any html coding knowledge to make your <br />own blog? Any help would be greatly appreciated!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-70994743318727084352010-09-02T09:04:30.183-04:002010-09-02T09:04:30.183-04:00Hi Roger,
Sorry to hear about the connection probl...Hi Roger,<br />Sorry to hear about the connection problems. I have tried my site from 2 different machines and internet providers, and I haven't had problem reaching it. I haven't heard of complaints from other users yet. Sometimes it may be a regional internet problem.<br /><br />You can email me directly at ernest AT epchan.com.<br /><br />Thanks,<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-35482816719113946962010-09-02T00:20:04.332-04:002010-09-02T00:20:04.332-04:00Hi Ernie,
The direct link is failing for me as we...Hi Ernie,<br /><br />The direct link is failing for me as well. Also, the link to your consulting site is failing for me as well (epchan.com). I wanted to ask some questions about consulting and the upcoming pairs workshop. Chrome says it cannot connect, Firefox says the server at epchan.com is taking too long to respond, and Internet Explorer says my end is fine, and that epchan.com is taking too long to respond. I've tried this on three different machines.<br /><br />Thanksvbmbnerhttps://www.blogger.com/profile/02262374108913408190noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-48274880351782163232010-09-01T20:57:55.822-04:002010-09-01T20:57:55.822-04:00Hi Roger,
Try to go to http://www.epchan.com/subsc...Hi Roger,<br />Try to go to http://www.epchan.com/subscription/spread.htm directly.<br />It may just be a temporary glitch at the web hosting site.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-4739466412306650862010-09-01T19:47:01.172-04:002010-09-01T19:47:01.172-04:00Hi Ernie,
Neither the premium content button on t...Hi Ernie,<br /><br />Neither the premium content button on the main blog page, nor the link in this post to epchan.com/subscriptions.html seem to work any longer. I am signed up, so am wondering how to get there.<br /><br />Thanksvbmbnerhttps://www.blogger.com/profile/02262374108913408190noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-88599514285571192452010-08-03T17:18:41.243-04:002010-08-03T17:18:41.243-04:00Thanks Ernie!Thanks Ernie!Jessenoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-51052375942970617852010-08-03T17:18:04.421-04:002010-08-03T17:18:04.421-04:00Thanks Ernie!Thanks Ernie!Jessenoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-14847001007635171522010-08-03T09:05:25.792-04:002010-08-03T09:05:25.792-04:00Jesse,
Cointegration does not require zero interce...Jesse,<br />Cointegration does not require zero intercept. I have explained the reason for using zero intercept in my reply to you and Marylander above.<br /><br />I don't use the beta obtained through the cointegration fit as my hedge ratio because I often want use a much shorter lookback period for calculating hedge ratio, which won't be suitable for cointegration test.<br /><br />Best,<br />Ernie<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-56311209769937629922010-08-02T15:51:43.630-04:002010-08-02T15:51:43.630-04:00Dr. Chan,
I was thinking you used the zero Y-inter...Dr. Chan,<br />I was thinking you used the zero Y-intercept in your regression because you are operating under the assumption that the 2 securities are cointegrated. Therefore, if one security is worth zero the other security will be worth zero as well.<br />Also, Dr Chan you mentioned earlier that you test for cointegration and then run your regression separately to find the hedge ratio. Why is this? Do go a lot farther than just using your zero intercept regression in finding the proper hedge ratio?jessenoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-80700614350216219182010-08-01T17:52:11.436-04:002010-08-01T17:52:11.436-04:00Ernie,
Many thanks for the prompt repsonse. I bou...Ernie,<br /><br />Many thanks for the prompt repsonse. I bought your book and love it. It's a very very good intro to the quant trading world . Best,Marylandernoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-49232585047599690082010-08-01T08:40:04.973-04:002010-08-01T08:40:04.973-04:00Jesse, Marylander:
It is important to note that in...Jesse, Marylander:<br />It is important to note that in my regression fit, I assumed the intercept is zero. The reason is that I believe fewer fitted parameters yield more a robust model, and I also don't believe that a non-zero intercept has any fundamental reason or significance.<br />The difference in the results you generated appear to stem from a non-zero intercept.<br />Best,<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-3927994479671911812010-07-31T14:38:56.044-04:002010-07-31T14:38:56.044-04:00Ernie, i agree with Jesse. Betas are different. Ma...Ernie, i agree with Jesse. Betas are different. Maybe we are making the exact same mistake but my hedge ratio when i use excel's ols is 1.19. When I chart the prices in excel it looks similar but don't know why they are different. I greatly appreciate your help.Marylandernoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-47804941728334987462010-07-20T12:22:54.559-04:002010-07-20T12:22:54.559-04:00Dr. Chan, i am trying to fully understand the coin...Dr. Chan, i am trying to fully understand the cointegration approach to find the "hedge ratio" for 2 assets. I am under the impression that this should be at least similar to running a regression of one asset against the other, so i was thinking the slope would be similar under both methods (method 1=cointegration using QR factorization ( like in your book) and method 2= using least squares (“regular” regression). Here is my MATLAB code to test this on a very simple example.<br /><br />x=[10;11;13;11]<br />y=[18;20;28;22]<br /><br />%cointegration method with QR factorization like Dr. Chan’s book<br /><br />r11=norm(x,2)<br />q2=x./r11 % %%could also use:[q r] = qr(x,0) %matlab function<br />mybeta=r11\(q2'*y)<br />plot(x,mybeta*x,'r')<br />hold on<br /><br />% now do least squares method<br /><br />n=length(x)<br />vect=ones(n,1)<br />A=[vect,x]<br />Atraspose_times_b=A'*y<br />ab=[inv(A'*A)*(A'*y)]<br />alpha=ab(1,1)<br />beta=ab(2,1)<br />plot(x,alpha+beta*x)<br /><br /><br />The main point is the betas are quite different. Does your way somehow factor in the price difference of the two assets maybe? Where the simple regression approach leaves the investor to figure that out for himself? Can you tell us why the two methods can give such different betas? Could you also tell us what is a proper time frame of past data to use when finding the correct hedge ratio.<br /><br />Thank you very muchjessenoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-60170372536101091182010-07-12T09:44:18.133-04:002010-07-12T09:44:18.133-04:00Anon,
Thanks for your kind words.
Yes, for Zscore...Anon,<br />Thanks for your kind words.<br /><br />Yes, for Zscore=-2, long ABC and short XYZ for 100 shares each would be correct. Alternatively, you can long 100 shares of ABC, and short hedgeRatio shares of XYZ.<br /><br />For Zscore=2, you would do the opposite.<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-27313789259817217492010-07-12T09:39:34.785-04:002010-07-12T09:39:34.785-04:00Abhishek,
There are 2 separate issues: 1) backtest...Abhishek,<br />There are 2 separate issues: 1) backtesting the futures pairs, and 2) live trading.<br /><br />Regarding 1), you would backadjust the contracts to form continuous contracts, and use the price (not return) gaps on rollover days to perform the backadjustment.<br /><br />Re: 2), you would just rollover both sides as usual before expiration, and use the backadjusted cotinuous contracts as in 1) to perform you calculations of MA, MSTD, hedgeRatio, etc.<br /><br />Hope this helps,<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-12672345642255963182010-07-11T12:39:46.763-04:002010-07-11T12:39:46.763-04:00Could you please sum up the problem of rolling ove...Could you please sum up the problem of rolling over of the futures contract in a couple of lines? :) <br />I am stuck while trying pair trading in futures contract, for I don't have enough ideas regarding how one would adjust the price of an expiring contract with the 2nd front month contract.<br />I had attended your workshop that you conducted for GHF group and while you were trying to find suitable futures contract for pair trading in oil futures, we had similar problems. May be you could throw some light on this adjusting the price for expiring contract issue. That would be great.<br />Thanks,<br />AbhishekAbhisheknoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-87895196872074099442010-07-10T12:46:32.620-04:002010-07-10T12:46:32.620-04:00Ernie,
Great book, I got it as a gift. I invest ...Ernie,<br /><br />Great book, I got it as a gift. I invest as a hobby so I'm not as proficient as many of your readers. Although you are getting me there ;-) I calculated my first sharpe ratio and drawdown percentages and drawdown times using the example in excel you have in your book. Thanks for the book and blog. I am reading and trying to learn.<br /><br />I have questions on pair trading after reading the book and blog. I am still not sure of a few things:<br /><br />AS an example to discuss (assume a cointegrated pair):<br /> ABC-XYZ<br />Z-score -2<br />shares ABC 100<br />shares XYZ 100<br />half-life 30 days.<br /><br />To trade this, would you go long ABC and short XYZ for 100 shares each?<br /><br />If the z-score was +2 would you still go long ABC and short XYZ for 100 shares each or do you have to do the OPPOSITE?<br /><br />Thank you!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-51836327721520937502010-07-06T09:12:14.121-04:002010-07-06T09:12:14.121-04:00Abhishek,
If you are pair trading futures contract...Abhishek,<br />If you are pair trading futures contracts, you should rollover just as your normally would (e.g. at a a week before expiration.)<br /><br />The main problem is how you adjust the prices when you backtest the strategy. This would require a lot more discussions.<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-25237711672568352552010-07-04T13:06:20.227-04:002010-07-04T13:06:20.227-04:00Ernie,
On a different note, could you pleas...Ernie,<br /> On a different note, could you please explain how you tackle the problem of rolling over while using futures contract in pairs trading? eg how would one use eurodollar futures contracts in pairs trading for a significantly longer period of time as the front contracts keep expiring every 3 months.Abhisheknoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-2501729349640941102010-06-07T15:08:55.891-04:002010-06-07T15:08:55.891-04:00Hi Trevor,
I used the second method you suggested....Hi Trevor,<br />I used the second method you suggested.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-14133898141867513102010-06-07T14:53:56.419-04:002010-06-07T14:53:56.419-04:00Hi Ernest,
I was just curious how you calculated ...Hi Ernest,<br /><br />I was just curious how you calculated the zscore of your cointegrated pairs. Did you perform linear regression on the pair and used the resulting residuals i.e. zscore = residual - mean(residual)/stdev(residual). Or did you perform linear regression on the prices of the pair, find the beta, used the beta to find the spread i.e Spread = StockA - HedgeRatio*StockB. Then calculate the zscore of the spread. <br /><br />ThanksTrevornoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-13335589994783719702010-05-22T17:22:57.953-04:002010-05-22T17:22:57.953-04:00Hi Anon,
I believe your zscore logic is correct.
...Hi Anon,<br />I believe your zscore logic is correct.<br /><br />The mean on page 57 of my book is over the entire training set. You can substitute that with a SMA. <br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-32210361062714270282010-05-21T06:52:09.798-04:002010-05-21T06:52:09.798-04:00Ernie I wanted to check some ZScore math logic I&#...Ernie I wanted to check some ZScore math logic I'm doing if I may.<br /><br />If the trade we want is 100 ABC against 90 XYZ, I'm first calculating (100* Closing price of ABC) - (90* Closing price of XYZ) to get a spread, mySpread.<br /><br />I then calculate the SMA of mySpread for period zPeriod, and the StdDev of mySpread for zPeriod.<br /><br />My ZSCore is then (mySpread - the SMA calculated above), divided by StdDev calculated above... right? <br /><br />I'm coding it in C# with some custom methods so I'm not sure how useful posting the raw code here would be.<br /><br />The code works, but I have nothing to compare it to.<br /><br />I note in your Matlab code on page 57 you are using a function called mean. I'm not a Matlab guy. Is that the arithmatic mean of your entire dataset? Is your spreadSTD also on the whole dataset? or is using rolling n periods (say, 28 period SMA and 28 period StdDev) a workable solution?<br /><br />Many thanks for your thoughts and looking forward to Quantitaive Trading II :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-20396976811961197842010-05-04T08:32:45.112-04:002010-05-04T08:32:45.112-04:00Jez,
You have a good point there. We will have to ...Jez,<br />You have a good point there. We will have to see how liquid they are in reality.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.com