tag:blogger.com,1999:blog-35364652.post6705992173073923207..comments2024-03-15T10:28:18.248-04:00Comments on Quantitative Trading: The life and death of a strategyErnie Chanhttp://www.blogger.com/profile/02747099358519893177noreply@blogger.comBlogger74125tag:blogger.com,1999:blog-35364652.post-31579900779710193292021-12-19T18:01:01.600-05:002021-12-19T18:01:01.600-05:00Hi,
The main reason for the discrepancy is due to ...Hi,<br />The main reason for the discrepancy is due to the fact that the open prices are not synchronous for NYSE stocks. If you limit your trading to Nasdaq stocks, it may fair better.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-24650607387973265592021-12-19T10:14:50.682-05:002021-12-19T10:14:50.682-05:00Hi Ernie,
reviving this old thread to say I backte...Hi Ernie,<br />reviving this old thread to say I backtested rigorously the buy on gap model from your book.<br />In order to generate more trading signals, I used 0.8 standard deviations and increased the universe from S&P500 to Russell 1000. topN was reduced to 5 max positions. When backtesting, I used 5bps slippage on entry/exit.<br /><br />The backtesting results looked pretty good -- from 2000 to 2020 the CAGR was around 29% with a max Drawdown of 21% and a sharpe of 1.91. I knew these were not realistic, so I decided to do some forward testing to see where exactly the pitfalls were.<br /><br />Live forward testing showed average entry (buy) slippage was around 30-40 bps, and exit (sell) slippage was more stable at avg 10 bps. This is because<br /><br />When backtesting the model again with these slippage figures, it turned out to be catastrophic:<br /><br />30/10bps slippage reduced the CAGR to 6% and increased the drawdown to 61%, sharpe was 0.52<br />40/10 bps slippage resulted in a negative CAGR of -6%, -87% DD and negative Sharpe of -0.44<br /><br />With the short on gap model, the differences were even more dramatic: just a mere 20/10 bps of slippage crashes the entire model over time.<br /><br />So, my conclusion was the buy/short on gap models are not suitable for trading.Николай Цветковhttps://www.blogger.com/profile/14090523135676864120noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-34547264431361487402016-08-04T10:08:42.550-04:002016-08-04T10:08:42.550-04:00Milind,
If Goolge Finance doesn't give you the...Milind,<br />If Goolge Finance doesn't give you the actual open price of the market, then you have to find another source data. You may even need to find intraday data. If you use IB, you can download free intraday data through their API, as long as you are subscribed to their live data for the Indian market.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-20501601424570988802016-08-04T09:26:09.049-04:002016-08-04T09:26:09.049-04:00Now I get it. But I trade on NSE India. NSE does n...Now I get it. But I trade on NSE India. NSE does not have LOO's. I use daily stock price data from google finance to backtest, and the price at 9:08 am during the NSE pre-market session is reflected as the open price for the day (when the market starts at 9:15 am) in google data. Hence it not possible for me to figure out what was the actual trade price of the first trade when the market opened at 9:15 am. <br /><br />When I implemented it Live, with limit orders I am not able to executes all buy signals, if I opt for markets orders, the slippage is unpredictable and makes the strategy unprofitable. <br /><br />Any suggestions to overcome this problem?Milindhttps://www.blogger.com/profile/07565896823124242287noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-69124854254188879602016-08-04T08:31:22.706-04:002016-08-04T08:31:22.706-04:00Hi Milind,
I think you misunderstood how one backt...Hi Milind,<br />I think you misunderstood how one backtests strategies that use LOO.<br />E.g. if your BUY LOO order on a stock has limit price $10, and the stock opened at $11, then your order won't be filled. If the stock opened at $9, then your order will be filled at $9. There is no randomness or uncertainty involved, and you can backtest the strategy with complete accuracy (with the caveat that your actual signal is generated at 9:28 at the latest, and that your historical data may have consolidated open price instead of the auction, primary exchange open price.)<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-86811319758404889222016-08-04T07:43:42.058-04:002016-08-04T07:43:42.058-04:00Hi Ernie, I tried backtesting this strategy. As yo...Hi Ernie, I tried backtesting this strategy. As you mentioned above that using limit orders will not guarantee that all 100 stocks can be bought on a daily basis; in such a case for backtesting, should I randomly select from the daily trade signals generated, and see whether the strategy gives good returns? Randomly selection can give false results. Can you please guide on this? Sorry If I am troubling you with my doubts, but a novice in trading. ThanksMilindhttps://www.blogger.com/profile/07565896823124242287noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-44651229753590794202016-08-01T14:23:51.811-04:002016-08-01T14:23:51.811-04:00Thanks Ernie for your valuable comments. I will fu...Thanks Ernie for your valuable comments. I will further backtest this strategy and try it live. Milindhttps://www.blogger.com/profile/07565896823124242287noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-12620934175132046462016-08-01T13:45:33.569-04:002016-08-01T13:45:33.569-04:00Hi Milind,
There are many versions of the buy on g...Hi Milind,<br />There are many versions of the buy on gap strategy. But as long as one uses limit orders, no versions would guarantee that you all your orders are filled. Why would that be a problem? You can backtest this quite accurately: just see if your limit price is higher or equal to the open auction price.<br /><br />We can only trade in the cash market for stock strategies.<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-22787946779741404202016-08-01T13:10:48.585-04:002016-08-01T13:10:48.585-04:00Thanks Ernie for your quick reply. Since LOO order...Thanks Ernie for your quick reply. Since LOO orders were used for entry, there might be instances on many days when for example only 40 or 70 or 60 stocks out of 100 stocks got filled due to the usage of LOO orders. How did you model your strategy for this behavior? (Not being able to trade all 100 buy signals). And did you execute this strategy in F&O or in the Cash Market?<br />Cheers Milind!Milindhttps://www.blogger.com/profile/07565896823124242287noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-61608444254658175012016-08-01T08:35:39.441-04:002016-08-01T08:35:39.441-04:00Hi Milind,
You can use LOO orders.
There is inevi...Hi Milind,<br />You can use LOO orders. <br />There is inevitably some slippage, since you have to use the 9:28 prices to generate these orders, and they will be filled at the auction price at the open.<br />If you want to backtest this accurately, you really have to use bid-ask quotes at 1 minute intervals.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-2411925589313708592016-08-01T07:18:50.642-04:002016-08-01T07:18:50.642-04:00Hi Ernie,
I had a question on the "Buy-on-Ga...Hi Ernie, <br />I had a question on the "Buy-on-Gap" strategy. Which is the best way to enter trades in this strategy, via Market orders or Limit orders? I tried entering via Market orders, but my one-way slippage is around 30bps (and it can be quite unpredictable I guess). For a 2-way 60 bps slippage the strategy fails to give positive returns in the backtest. With Limit orders, not all stock positions have a fill. Is there a way to execute such strategies at the market open , at the required volume with minimal slippage? Thanks<br /><br />-MilindMilindhttps://www.blogger.com/profile/07565896823124242287noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-45863511988186835612013-01-04T13:30:04.752-05:002013-01-04T13:30:04.752-05:00Hi S,
Actually, intraday variations may not involv...Hi S,<br />Actually, intraday variations may not involve ranking. But I will leave it to your imagination to find out the exact strategy that is possible and profitable, lest I trample on someone else' intellectual property!<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-36532726528753902722013-01-04T10:12:51.108-05:002013-01-04T10:12:51.108-05:00Hi, Ernie,
Yes, that's the comment I was refe...Hi, Ernie,<br /><br />Yes, that's the comment I was referring to. I am not sure at what point the ranking happen, and using what data point. I can think of three methods:<br /><br />1) use the rank at open using open(0) and low(-1), and buy at noon_open(0) ... this seems random to me<br />2) rank at middle of the day using noon_open(0) and low(-1) and buy noon_open(0) ... but this confused me when you comment "Buy if the price is lower than the previous day's low,",<br />3) rank using before_noon_low(0) and noon_open(0), but noon_open(0) >= before_noon_low(0), since there is no reason to believe the market will gap at noon. However, we only care about its relative rank?<br /><br />But after reading your replies, I don't think I understand how this variation work. Can you elaborate it a little bit?<br /><br /><br />Regards,<br /><br />S.ink<br />yu namhttps://www.blogger.com/profile/00387215305926568640noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-68962845543058440842013-01-04T09:41:30.224-05:002013-01-04T09:41:30.224-05:00S,
I believe you have lost track of the thread of ...S,<br />I believe you have lost track of the thread of conversation.<br /><br />The thread started with the question "Have you tried to trade the same strategy but using the price in the middle of the day as the open?<br />This would basically be an intraday reversal. "<br /><br />implying this is an intraday variation of Lo's strategy.<br /><br />E.Ernie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-31743121710257319482013-01-04T09:35:07.359-05:002013-01-04T09:35:07.359-05:00Hi, Ernie,
In your comment, you said
"Buy ...Hi, Ernie,<br /><br />In your comment, you said <br /><br />"Buy if the price is lower than the previous day's low, and your backtest shows that today's low is indeed lower than previous day's low, then you know the execution price is the previous day's low. You don't need intraday prices to do this kind of backtesting.". <br /><br />But Andrew Lo's strategy is "buy the open"?<br /><br /><br />Thanks,<br /><br />S.inkyu namhttps://www.blogger.com/profile/00387215305926568640noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-35385558020161326162013-01-04T09:09:33.271-05:002013-01-04T09:09:33.271-05:00My tcost is one-way, include slippage and commissi...My tcost is one-way, include slippage and commission.Ernie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-91613235130213687812013-01-04T09:07:55.346-05:002013-01-04T09:07:55.346-05:00Hi S.ink,
If your strategy says "Buy if the p...Hi S.ink,<br />If your strategy says "Buy if the price is lower than the previous day's low", and your backtest shows that today's low is indeed lower than previous day's low, then you know the execution price is the previous day's low. You don't need intraday prices to do this kind of backtesting.<br /><br />However, you won't be able to test a strategy that can only execute at 1pm, of course, without intraday historical data.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-64265186988755965892013-01-04T09:05:54.484-05:002013-01-04T09:05:54.484-05:00Hi, Ernie,
What is tcost mean in your post? Comm...Hi, Ernie,<br /><br />What is tcost mean in your post? Commission only, commission & slippage? Is the bps for 1 way or round trip?<br /><br /><br />Thanks,<br /><br />S.inkyu namhttps://www.blogger.com/profile/00387215305926568640noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-50998014128015422642013-01-04T08:50:40.174-05:002013-01-04T08:50:40.174-05:00Hi, Ernie,
Thanks for all the replies. But I th...Hi, Ernie, <br /><br />Thanks for all the replies. But I think I don't quite understand what you mean. Because if you are using just daily open-hi-low-close, how can you back test using noon open price?<br /><br />Does that mean when you trade intraday, <i>you rank your stock using daily open and daily low(-1)?</i>. But trade at noon on a different price, even though the ranking might be different at noon?<br /><br />Or do you redo the ranking at noon, using the noon "open" price with previous day low? Then trade at noon. I do feel more comfortable with that because the instance I observed, its quiet after 11:00AM.<br /><br />Sorry, I am a total newbie at this kind of topic (therefore such explicit questions).<br /><br /><br />Thanks,<br /><br />S.ink<br />yu namhttps://www.blogger.com/profile/00387215305926568640noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-13812515123401669992013-01-04T08:18:51.771-05:002013-01-04T08:18:51.771-05:00Hi S.ink,
I also don't use historical intraday...Hi S.ink,<br />I also don't use historical intraday data except high and low. However, that doesn't mean you cannot enter intraday.<br /><br />Due to the uncertainty of the data at open, 5bps for large cap, 10 bps for small cap tcost will be prudent.<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-35217448047402856742013-01-04T04:56:22.748-05:002013-01-04T04:56:22.748-05:00Hi, Ernie,
Thanks. I should have rephrased my qu...Hi, Ernie,<br /><br />Thanks. I should have rephrased my question to "are you using the previous day low and open of the noon bar?" I don't have access to intraday data and can't really run the test with any other time except daily open.<br /><br />Also, what value did you used for slippage in your backtest (daily open entry)? When I looked at the 5min charts, the open is so chaotic. In your opinion, what level of slippage should I expected?<br /><br /><br />Thanks,<br /><br />S.inkAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-60968479571684210832013-01-03T21:13:46.999-05:002013-01-03T21:13:46.999-05:00Hi S.ink,
Yes and yes.
ErnieHi S.ink,<br />Yes and yes.<br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-43593749041059675622013-01-03T20:49:55.975-05:002013-01-03T20:49:55.975-05:00Hi, Ernie,
In one of your comment, you said "...Hi, Ernie,<br /><br />In one of your comment, you said "It is equally profitable" for buying in the mid of the day. Were you using low from previous day? And ignoring the price data in the morning session?<br /><br />Thanks,<br /><br />S.inkAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-35364652.post-12901710152686878292012-06-01T13:08:07.252-04:002012-06-01T13:08:07.252-04:00Hi Gekkoquant,
Yes, the strategy apparently worked...Hi Gekkoquant,<br />Yes, the strategy apparently worked well in 2012, but I don't know about 2009-2010.<br /><br />I look for a Sharpe ratio > 1 before trading live. Max drawdown is less important since it depends on leverage. If we have only 1 strategy, then Sharpe ratio needs to be even higher, at least 1.5 in backtest.<br /><br />ErnieErnie Chanhttps://www.blogger.com/profile/02747099358519893177noreply@blogger.comtag:blogger.com,1999:blog-35364652.post-28309488838470078722012-06-01T10:41:45.694-04:002012-06-01T10:41:45.694-04:00Hello again,
I've implemented this strategy (...Hello again,<br /><br />I've implemented this strategy (or at least my interpretation of what you outlined) at http://gekkoquant.com/2012/06/01/trading-strategy-buy-on-gap-epchan/<br /><br />I hope you don't mind this comment.<br /><br />From what i've implemented it looks like this strategy still works well. One slight difference that I think might exist is the standard deviation test, I check that the stock is less than or equal to the mean return + 1 standard deviation.<br /><br />Another slight difference is that i'm using the 2011 S&P constituents (so have survival bias).<br /><br />Thanks for this great post.<br /><br />What sort of values in the sharpe ratio/win ratio/max drawdown performance metrics do you look for before taking a strategy live?GekkoQuanthttp://gekkoquant.comnoreply@blogger.com