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:
- Press "Clone Algorithm." You'll be redirected to a window where you can edit your copy of the algorithm.
- Hit "Build." This runs a quick backtest on the algo.
- Change the n and m parameters!
- 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.