I felt the need to verify the calculations in the previous post, just to be sure no coding error was made, or at least not a serious one. To do this, I've rewritten the strategy using vector operations rather than 'for' loops and I'm happy to say, the result still stands. Sharpe is a little lower at 1.13, but the curves are quite similar.
To make this post a worthy follow up, I've also included the code:
dumbGaps.m , download_hist_yahoo_data.m
The following remarks are still very appropriate:
Your feedback is very much appreciated.
To make this post a worthy follow up, I've also included the code:
dumbGaps.m , download_hist_yahoo_data.m
The following remarks are still very appropriate:
- It is very hard to get a fill at the opening price.
- Results are frictionless.
- All this is just a basic concept
Your feedback is very much appreciated.
Hi,
ReplyDeleteThe quick tests have been performed for the list
http://finance.yahoo.com/lookup?s=SPDR
The first impression from the proposed strategy is negative.
Thanks for your code
@Jeanbou: This rough idea needs some work before it can become profitable. In any case, only a test based on intraday data could give you an idea of the strategy performance. The reason is that the market moves extremely fast in the first seconds after the open and your order fill will most probably happen at a different price, usually in a 'wrong' direction. However, the basic idea of retracing the previous days close could lead to a profitable strategy.
ReplyDeleteHi,
ReplyDeleteIf you change spy.close on spy.adj_close in your m-code you will get the Sharpe 33.3429 .
I.
@Jeanbou: If you take a closer look at how the adjusted price is calculated you'll understand why this happens. Try plotting the close and adj_close next to each other, you'll notice that the dividends cause a permanent offset in the adjusted price.
ReplyDeleteMerci
ReplyDeleteGood day, I try to understand your code.
ReplyDeleteIn the line 25
idx = (gap>0) & (spy.low<prevClose);
How one can know in advance during the day of trading that spy.low can/cannot go lower than prevClose while the stock exchange is still open?
Correct me if I'm wrong, please?
Thanks
@Anonymous: the strategy rules are: enter in the opposite direction to the gap. For an up gap, exit at the level of previous close. If the previous close level is not reached, exit at days close. In this case the strategy wins. The expression looks for winning dates.
ReplyDeleteI don't really understand why you said it's difficult to get a fill in the openings. In general, you can always do a pre-market trade just a few seconds before. Your execution price shouldn't be more than a few pennies from the official opening price.
ReplyDeleteAlso, did you exclude the ex-dividend dates? A gap down because of ex-dividend shouldn't be seen as a trade signal.