I'm fairly new to swing trading and especially Quantopian. Since I'm a simple guy, I wrote and tested a simple algorithm that does the following:
-Every Tuesday morning before market open, scan for the 4 stocks that rose the most over the past five trading days. The stocks are selected from a custom universe that includes those:
- with avg. daily vol > 20000 over the past one year
- outstanding shares > 1000000
- market cap > 6000000
- average close price over the past five trading days > 1.10 and < 10.00
- not LP, OTC, WI, and is a common stock
-Tuesday at market open, I short $10000 worth of each of the four stocks.
-Thursday at market close, I cover all positions.
-I have a single stop in place such that if the Tuesday or Wednesday closing price > 2x cost basis, the position is closed the following morning.
The backtest results show a gain of +1606% from 1/1/2003 to 12/31/2016. Since I consistently short $10k/stock in this algorithm regardless of portfolio value, a smaller and smaller percentage of the total portfolio is invested as time moves forward. Instead of re-investing and compounding the gains (which would probably not work with this strategy as the stocks are not the most liquid), I would withdraw $40k from the portfolio each year. Unless I'm missing something, which I admit I most likely am, this strategy shows that I could start with $40k and have a steady stream of $40k in income per year over the 14 year test period.
It seems too good to be true. What am I missing? For the purposes of this backtest, I turned off slippage and set the commission to $4.95/trade (my E*Trade cost). I think I would get fill prices better than are calculated via Quantopian's slippage algorithm since I'm only making four round-trip trades per week, at market open and close when trading is generally most active. That said, even when I turn slippage on, the backtest results still show a gain of about 1280%. I also thought that since Quantopian does not trade exactly at market open or close that I should compare the filled prices within the backtest to actual open and close prices. The results show that I would actually do better than the backtest reveals by trading exactly at market open/close, not within a few minutes of open/close as Quantopian does. These results are shown in the backtest log along with the code.
I tweaked numerous variables and the weekly trading range, and those shown in this backtest yielded the best result of those I tested. I know these are not the most liquid stocks, but I think that by making few transactions at market open/close it should not be a huge problem. I also understand this algorithm is not scalable for that reason, but that is not my intent. That said, interestingly enough, if I turn slippage on and re-invest my gains instead of consistently trading $10k/stock, the algorithm shows a gain in the tens of thousands of percent by the end of the backtest period!
The backtest statistics look good to me, although they are skewed in the sense that only around $40k is invested at given time. That said the gain is fairly steady over time, with fairly minimum volatility and every 12-month period over the 14-year backtest shows a profit (through both bear and bullish market conditions).
I know that stocks may sometimes not be available to short, and that HTB fees will reduce the gains slightly. I do not estimate these as significantly reducing profit. Finally, note that I am only using Quantopian for its backtest feature and to determine which stocks to trade each week. I would still make all trades manually.
Anyway, what do you all think? Am I on to something here or is too good to be true? Do you have any suggestions to improve the algorithm?
|Returns||1 Month||3 Month||6 Month||12 Month|
|Alpha||1 Month||3 Month||6 Month||12 Month|
|Beta||1 Month||3 Month||6 Month||12 Month|
|Sharpe||1 Month||3 Month||6 Month||12 Month|
|Sortino||1 Month||3 Month||6 Month||12 Month|
|Volatility||1 Month||3 Month||6 Month||12 Month|
|Max Drawdown||1 Month||3 Month||6 Month||12 Month|