Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
beat SPY by buying & selling SPY

I concocted this algorithm and it seems too good to be true. For the ETF SPY, I compare the volume-weighted closing price to the opening volume-weighted price the next trading day. If the drop is greater than 30%, I buy SPY and sell it the next day. I use a cost of $1 per trade, and start with $10,000 capital.

Questions/comments/additional backtests welcome.

Grant

9 responses

Well my first impression is it does very well in the late 2008 market drop. Otherwise the returns simply follow the market, albeit somewhat inefficiently.

If the start date is 2007-06-01, the algo buys on 2007-06-4, 2007-06-06, 2007-06-08...
If the start date is 2007-06-04, the algo buys on 2007-06-5, 2007-06-07, 2007-06-11...
I think the good performance in 2008 is only due to luck.

Thanks Dennis & Guy,

Yes, the advantage of the algorithm over SPY is gained when the market dives in 2008. I've played around with different start dates and thresholds to buy. It seems that the 2008 period was unique, but it's not clear that it was due to "luck." Is it possible that as a general characteristic, when the market is dropping sharply, an inefficiency creeps in when the market is closed? I find it remarkable that with a simple algorithm, essentially buying and selling the market on a daily basis (trading cost included), the entire market downturn could have been avoided!

Grant

All in all, the algo is long SPY less than half the time: hence its over performance when the market falls and its under performance when the market rises.
The existence of a threshold might result in a data snooping bias.

Thanks Guy,

Yes, admittedly, I had to fiddle with several parameters to obtain the result posted above. It was more of an exploration exercise, based on code for another purpose (I'd written the code after the posting on Estimize data import and NFLX earnings surprises). It's started me wondering how the market incorporates new information that comes to light when the market is closed. It is just a hunch, but I wonder if during the 2008 downturn, there was an over-reaction to bad news around the world (or just pent up anxiety) that resulted in the market sometimes opening low and then "mean reverting" within a day. Or maybe after-hours trading activities played a role?

Also, I wonder if individual investors might be better positioned to take advantage of close-to-open anomalies? I figure that institutional investors may be at risk of moving the market (slippage) if they don't spread their transactions throughout the day.

Grant

Grant

Buying opening-bell sell imbalances alongside the specialists is a classic strategy, usually people (used to) close the position by 10:30am.

Thanks Simon,

Any idea if "buying opening-bell sell imbalances alongside the specialists" is still a viable strategy? Does it require special historical circumstance (e.g. the 2008/2009 downturn)? Or is it common?

Grant

No idea sorry, it was something I used to do 10-15 years ago when I was daytrading. It relies on a rule on the NYSE (in particular) that marketable limit orders and market orders placed prior to the open must execute at the opening crossing price. If there is a sell imbalance, the specialist will open the market at a low enough price that any inventory he must accumulate he feels is at a price where he can recoup the risk. If you place a limit buy order above where the opening price is, he/she is obligated to execute it at the opening price, so you ride along with the specialist as he opens low to clear the market then sell the inventory hopefully a little higher.

Bear in mind I haven't checked up on any of these rules, circumstances or profitability in the last 10 years. A backtest would show if this sort of thing is still possible, I would try to restrict universe to lower-volume NYSE stocks if I were you.

Thanks Simon...Grant