tag:blogger.com,1999:blog-35364652.post460411242575722090..comments2023-03-22T06:23:30.858-04:00Comments on Quantitative Trading: My book on Quantitative Trading is publishedErnie Chanhttp://www.blogger.com/profile/02747099358519893177noreply@blogger.comBlogger59125tag:blogger.com,1999:blog-35364652.post-47919462388359745682020-08-30T08:30:16.705-04:002020-08-30T08:30:16.705-04:00Hi Wynton,
The 2 in log(2) just means we are inter...Hi Wynton,<br />The 2 in log(2) just means we are interested in the half life, when the value dropped to 1/2 of the initial value.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-21031350028207456922020-08-30T06:17:01.219-04:002020-08-30T06:17:01.219-04:00Hi Ernie,
I read your book Algorithmic Trading bu...Hi Ernie,<br />I read your book Algorithmic Trading but I don't get grasp of the OU.<br />OU-<br />E( y(t)) = y0exp(λt) − μ/λ(1 − exp(λt)) (2.6)<br />Remembering that λ is negative for a mean-reverting process, this tells us<br />that the expected value of the price decays exponentially to the value −μ/λ<br />with the half-life of decay equals to −log(2)/λ.<br />How does log(2) get into the picture?Wyntonhttps://www.blogger.com/profile/11512850516237919737noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-15008061013649563952018-06-17T08:33:07.349-04:002018-06-17T08:33:07.349-04:00Hi Alberto,
Thank you for your kind words on my bo...Hi Alberto,<br />Thank you for your kind words on my book. <br />The link is http://www.epchan.com/subscription/spread.html.<br />The last "l" seems important.<br />Ernie<br />Ernie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-6273487539142772732018-06-16T18:39:12.115-04:002018-06-16T18:39:12.115-04:00Hi Ernie
I am a master student in economics and I...Hi Ernie <br />I am a master student in economics and I am doing my thesis on algorithm trading for high frequency firms. I was amazed by your book and the way it is presented. Even if I have no professional background, you took me through the mathematical struggle and I have a much better overview of the sector. I was about to start to chapter with the interday trading and I have some troubles. In fact, the premium link (http://www.epchan.com/subscription/spread.htm) is not working anymore and I have been trying for 2 days now. It is very annoying because my thesis deadline is coming and I really need those codes to be able to finish. Please Ernie could you help me?<br />Anonymoushttps://www.blogger.com/profile/04069738447597233172noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-10410800129915858422014-04-22T16:45:23.824-04:002014-04-22T16:45:23.824-04:00Hi John,
Thanks for your kind words.
Please make ...Hi John,<br />Thanks for your kind words.<br /><br />Please make sure you added all the sub-folders of the jplv7 package to your Matlab path.<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-78870639895972100612014-04-22T15:23:55.209-04:002014-04-22T15:23:55.209-04:00Hi Ernie,
Great book - inspired me very much. By...Hi Ernie, <br /><br />Great book - inspired me very much. By the way, the function "prt" to show the data result table for the cointegration test in example 7.2 doesn't work for me. <br /><br />Error msg.: Undefined function 'prt' for input arguments of type 'struct'.<br /><br />Do you have any idea what might be wrong?Johnnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-46111209287318435242013-02-26T13:40:21.467-05:002013-02-26T13:40:21.467-05:00Hi Anon,
Thanks for the kind words on your book.
...Hi Anon,<br />Thanks for the kind words on your book. <br /><br />Actually, I have provided Excel input files for most of the examples in the book. Furthermore, the entirety of the source codes were displayed, so you can see the exact parameters as well.<br /><br />Let me know if you have a question about a specific example where such inputs are not available.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-56135520746441315532013-02-26T10:47:24.846-05:002013-02-26T10:47:24.846-05:00Ernie, I really like your book, but there is a sli...Ernie, I really like your book, but there is a slight issue I hope you adress in future editions.<br /><br />Often you present code and some output, say "p-value 0.035". However, I may use other tools than Matlab and therefore would like to <br />be able to calibrate my tool to yours. I would appreciate if you specified the input, too. Not only the output. Say "XLD/GM for dates 2008-01-01 up to 2010-01-01". Now I can calibrate my tool with your output. So please specify input AND output!<br /><br />Great book, I am recommending it to others!<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-86986638506582259502012-07-24T07:44:17.684-04:002012-07-24T07:44:17.684-04:00Hi ShinjiOno,
You can just use raw prices for OU.
...Hi ShinjiOno,<br />You can just use raw prices for OU.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-7238701467788894032012-07-24T04:15:33.918-04:002012-07-24T04:15:33.918-04:00Hi Ernie,
Shall we use log price to model spread ...Hi Ernie,<br /><br />Shall we use log price to model spread for ornstein-uhlenbeck? <br /><br />Z= log p1- log p2<br />Z OU process?<br /><br />ShinjiAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-79895444528202914112012-07-24T04:12:00.066-04:002012-07-24T04:12:00.066-04:00Hi Ernie,
Shall we use log (price) for Ornstein...Hi Ernie, <br /><br />Shall we use log (price) for Ornstein-Uhlenbeck to model spread for mean reversion? <br /><br /><br />ShinjiOnoAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-36004447356564972892011-05-05T07:48:06.131-04:002011-05-05T07:48:06.131-04:00Gray,
You might want to google the paper by Doyne ...Gray,<br />You might want to google the paper by Doyne Farmer (of Los Alamos National Lab/Prediction Company/Santa Fe Institute fame) "Liquidity, long-memory and market impact".<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-81338879687780029612011-05-04T17:09:30.069-04:002011-05-04T17:09:30.069-04:00Thanks Ernie, I'll look at that blog post and ...Thanks Ernie, I'll look at that blog post and the sources it references. <br /><br />My strategies have hold periods of about 5 days, and I've backtested them based on getting closing price on the day following the signal (signal available after close of market on t=1 trades at close on t=2), so I'm pretty confident that as long as my order can get done within one full trading day without major impact I'll be OK. <br /><br />I currently measure every execution relative to the daily close price (i.e, what was the execution price vs. the end of day close price) and consider this to be the "slippage", at least relative to the close price (I'm assuming here that I'm not a big enough buyer/seller to actually move the close, just to nudge around the intraday prices a bit). My "slippage" defined in this way is on the order of one basis point. <br /><br />The journal article listed in Max Dama's blog seemed to focus on impact from size of order relative to average size of inside quote (if I'm reading this right). I'm specifically interested in size of position that can be taken over some period of time (like an hour or day) and what the impact of that would be. In some ways this is analogous, but not totally. <br /><br />I'll keep going through the literature looking for a market impact equation based on TradeSize / ADV ratioAdministratorhttps://www.blogger.com/profile/12799136696974150915noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-9318463253296235362011-05-03T18:12:07.408-04:002011-05-03T18:12:07.408-04:00Hi gray,
Capacity estimation is a complex topic.
...Hi gray,<br />Capacity estimation is a complex topic.<br /><br />I define capacity as the point where marginal increase in equity will not produce a marginal increase in P&L.<br /><br />Others, however, may define capacity as the point where marginal increase in equity will start to decrease return. <br /><br />Obviously capacity under my definition is much larger! The common sense definition of capacity is probably somewhere in between.<br /><br />If you are using the second definition, the first step is to look at the typical bid-ask size of the instruments you trade. If your order size has reached the typical bid-ask size, then you have reached capacity already, unless you find a way to slice up the order and enter in small chunks at different times without diminishing the return.<br /><br />If you are using the in-between common-sense definition, you have to estimate the market impact of your orders. Many, many academic papers have discussed this topic, but you can start with this blog post: http://www.maxdama.com/?p=397<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-66376180322033885212011-05-03T14:58:03.357-04:002011-05-03T14:58:03.357-04:00Hi Ernie,
I just bought and devoured your book - ...Hi Ernie,<br /><br />I just bought and devoured your book - really on point to my situation. Especially relevant was the conclusion section where you described the importance of knowing a strategy's capacity. I've got a nice strategy, Sharpe ratio of ~3.0, and really good consistency. I'm trading it with non-trivial amounts of money (>$500K equity) and want to better understand if its capacity is 2x, 20x or 200x the current size. The answer to this question is key for me in knowing whether I've got a profitable source of incremental income or an opportunity to build a fund partly with institutional money. <br /><br />I can think of a few ratios to look at (e.g., pos size relative to ADV) but haven't seen any good literature on rules of thumb of estimating. <br /><br />Any thoughts or links would be appreciated.Administratorhttps://www.blogger.com/profile/12799136696974150915noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-49021513939737517242009-12-13T17:23:43.109-05:002009-12-13T17:23:43.109-05:00Anonymous,
You may have the same lag function in d...Anonymous,<br />You may have the same lag function in different packages higher up in your Matlab path. Type "which lag" to find out which function you are using and adjust your path precedence accordingly. Call Matlab customer support if you have further difficulties.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-6178685320001545592009-12-08T21:17:51.891-05:002009-12-08T21:17:51.891-05:00Hi,
I tried running example7.2, here is my error m...Hi,<br />I tried running example7.2, here is my error msg (I intalled jplv7 and did set the path):<br /><br />?? Error using ==> lag<br />Too many input arguments.<br /><br />Error in ==> cadf at 57<br /> z = trimr(lag(r,1),1,0) ;<br /><br />Error in ==> example7_2 at 53<br />res=cadf(adjcls(:, 1), adjcls(:, 2), 0, 1); % run cointegration check using augmented Dickey-Fuller test<br /><br />Any comments?<br />Thank youAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-65811630036014591492009-04-17T08:57:00.000-04:002009-04-17T08:57:00.000-04:00I can see the index for the book files now and eve...I can see the index for the book files now and everything is there, thanks!Johnnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-44234563400008461152009-04-16T14:55:00.000-04:002009-04-16T14:55:00.000-04:00John,
That was a temporary glitch on the part of t...John,<br />That was a temporary glitch on the part of the web hosting company. It has been fixed now, and you can see the index of all the programs at epchan.com/book<br /><br />Sorry for the inconvenience!<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-25049797455902616142009-04-16T09:38:00.000-04:002009-04-16T09:38:00.000-04:00I liked your book, but it is really annoying that ...I liked your book, but it is really annoying that the premium section of your website (http://epchan.com/book/) does not allow directory listings (it gives a 403 error). There is also no index file, despite what you say on http://www.epchan.com/subscription/spread.htm. So there is no way to know what files there are other than trying all the filenames mentioned in your book (some of which are case sensitive, others not). This also means that if you post a new file, we will never be able to find it.Johnnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-66873462300839631452009-03-26T09:01:00.000-04:002009-03-26T09:01:00.000-04:00Jacques,AR(1) is an estimate of the hedge ratio be...Jacques,<BR/>AR(1) is an estimate of the hedge ratio between the 2 stocks. It is not the mean value of the spread, which should always be close to zero.<BR/><BR/>You can always google VWAP Matlab to find freeware for this calculation. Like you said, it is a one-line calculation so you might as well do it yourself!<BR/><BR/>backshift.m is included in epchan.com/book for you to download.<BR/><BR/>ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-69312697867774224932009-03-26T02:31:00.000-04:002009-03-26T02:31:00.000-04:00Hello Ernie,Here's one more question tonight. Hop...Hello Ernie,<BR/><BR/>Here's one more question tonight. Hope I'm not overloading you.<BR/><BR/>I ran Example 7.5 on p. 141 (Calculation of the Half-Life) in Matlab but received an error: "backshift not found."<BR/><BR/>Backshift doesn't appear to be in the Econometrics Toolbox by James P. LeSage. Are you aware if it is in one of the Matlab tooboxes (e.g., their Econometrics toolbox)?<BR/><BR/>Thanks a lot for your input! :)Jacques Marsunhttps://www.blogger.com/profile/17028741688120675707noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-41335771291182144422009-03-26T01:37:00.000-04:002009-03-26T01:37:00.000-04:00Hello again,Are you aware of any pre-existing Matl...Hello again,<BR/><BR/>Are you aware of any pre-existing Matlab code that calculates the Volume Weighted Adjusted Price (VWAP) over a given time series?<BR/><BR/>It doesn't seem to be complicated code to write from scratch, but if someone has already written it... :)<BR/><BR/>Cheers!Jacques Marsunhttps://www.blogger.com/profile/17028741688120675707noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-27248126825950813162009-03-26T01:35:00.000-04:002009-03-26T01:35:00.000-04:00Hello Ernie!Example 7.2 on pages 128-130 runs the ...Hello Ernie!<BR/><BR/>Example 7.2 on pages 128-130 runs the Augmented DF test.<BR/><BR/>Could the "AR(1) estimate" be considered the mean value for the spread's time series?<BR/><BR/>Thanks!Jacques Marsunhttps://www.blogger.com/profile/17028741688120675707noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-37912131284959984152009-03-23T19:21:00.000-04:002009-03-23T19:21:00.000-04:00Dear Ernest,I've been reading your blog since 2007...Dear Ernest,<BR/><BR/>I've been reading your blog since 2007, and I recently purchased your book. <BR/><BR/>Thanks for all the insights in your book and blog!<BR/><BR/>I'll try to comment here more often, maybe sharing some experiences.<BR/><BR/>Best Regards,<BR/><BR/>Newton Linchen.Anonymousnoreply@blogger.com