Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Market Panics: To Sell or Not to Sell?

The market has taken a nosedive recently, which prompted an interesting analysis by 538 on whether to sell or to hold during a market panic, i.e. when the S&P suffers a big decline. The folks at 538 propose that holding your assets is better than selling during the panic and buying back later.

To drive the point home, 538 included a simulation of a trader who sold upon downturns of 5% and bought back upon 3% rebounds. I wrote an algorithm to let you run similar simulations: you can clone the algo and tweak the parameters to try variations on this strategy. Perhaps you will find something useful. To get started:

  1. Press "Clone Algorithm." You'll be redirected to a window where you can edit your copy of the algorithm.
  2. Hit "Build." This runs a quick backtest on the algo.
  3. Change the n and m parameters!
  4. Hit "Build."

My experience was that it's difficult to meaningfully outperform SPY with such a simple strategy (and in the case of outperformance, to ensure that the result was not due to overfitting). The problem is basically twofold:
1. Movements in price are not very indicative of future movement.
2. Detecting a loss requires taking a loss to begin with. Detecting a gain requires letting the equity appreciate before purchasing.
For many simple, risk-averse strategies that trade SPY, the second point implies that the strategy will underperform SPY. It is possible to improve results by shorting and optimizing n/m pairs (both of which I will do in future notebooks), but at that level of effort, it is probably better to develop a reasonably market-neutral trading strategy to manage the portfolio.

3 responses

Addendum: you can see that in the backtest above, the strategy slightly outperforms SPY. This might be surprising. The reason for this result is that the strategy heavily outperforms SPY between 2002 and 2004. Between 2005 and 2015, it underperforms SPY slightly, as you might expect. Thus, I think of this result as the consequence of (unintended) 2002-specific overfitting.

Plotting linear-scaled cumulative equity is actually pretty deceptive like that.

Agreed. Maybe it'd be helpful to plot the difference between the returns of the two over time? A gradually diminishing difference would show that your strategy's earlier outperformance might have been a fluke.