Back to Community
Worlds best algorithm?

Hi guys, I stumbled upon this idea and I wanted to find out if this is possible.

At 1530ET "Buy Stocks" and cover at 1545ET.
At 1545ET "Short Stocks" and cover at the close.

The percentage gain per year is about 60%. In a triple market/inverse market ETN, that could go to 180% per year. (I.e. SRTY)

Here's an image of what this would look like for the past few years.

http://www.zerohedge.com/sites/default/files/images/user3303/imageroot/2016/02/29/20160229_SandP.jpg

Is this something I could pay to have made? Thanks.

8 responses

Please can you post the article

Yes with a triple leveraged etf you would be taking 3x more risk.

I wanted to see if this works so here is the algo.

Note: This is without commission or slippage (comment the zero commissions from the code to see - the algo doesn't survive commission or slippage)

The interesting part is that with this data is that it's easier to pinpoint when you should close your position during last 30 minutes, longs should be closed at ~1545 and shorts at 15:30 or near 16:00 but not between.

Clone Algorithm
177
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
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
# Backtest ID: 56d76296f938e20df2e41ea4
There was a runtime error.

Neat! I've got an (old) set of intraday graphs, and it suggests a couple of things:

  • Open is a good time to buy on all days, except Mondays, when you might want to short at open
  • 12.30 is a good time to buy as well (on all days)

The graphs don't suggest shorting 15 minutes before close, but it looks like you are doing this to offset your long position. Did you try simply going long at half an hour before the close, then closing out this position at close, with no short?

Though your algorithm doesn't survive slippage, it suggests good times to trade for equity algorithms that do.

PS The spread on a leveraged ETF like 3x SPY will be much worse than plain old SPY.

The graphs don't suggest shorting 15 minutes before close, but it looks like you are doing this to offset your long position

The algo is just doing what the OP suggests, 1xleverage @ 1530, -1xleverage @ 1545 and closing minute before close.

It's important to note that the algo might not be able to close the whole position before close so this might lead to some securities being hold over night (and therefore increasing risk).

Just for fun, here is 3xetf version (without commission/slippage)

Clone Algorithm
177
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
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
# Backtest ID: 56d7fc3182284e0f57638dd6
There was a runtime error.

And here the same with default commission/slippage. Pretty different picture.

Clone Algorithm
177
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
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
# Backtest ID: 56d7fcbec934f20f9c39dda8
There was a runtime error.

To me at least it seems like this strategy is falling for the same fallacy that numerous other Quant strategies fall prey to. Let us look at another example, the 'Foolish 4' which was a strategy pushed by the Motley Fool in the 90's. It was sold as a low risk way to outperform the markets by a significant margin. There were five steps to it:

  1. Take the five stocks in the DJIA with the lowest price and highest yields
  2. Discard the one with the lowest price
  3. Put 40% of your cash in the stock with the second lowest price
  4. Put 20% in the three remaining stocks
  5. One year later, rinse and repeat.

The fallacy this fell to was over-fitting, there was no investment logic behind it and I believe it made the same mistake as this algorithm: If you look at a large quantity of data, a large number of patterns will emerge. The fact that this pattern existed in the past, neither means that the pattern will exist in the future, nor that the pattern is the reason for the movements.

Let's look at this as a hypothetical, you've got all the data from the past and you find that every Monday at 15:47 the market rises, you then write an algorithm to exploit this. It has a 0% drawdown because historically the market has always risen on Monday at 15:47, this seems like the 'Holy Grail' in backtests so you take it into live trading and go bust. You then check and see that the market has gone down for the first time ever on Monday at 15:47, you then realise that there is no investment logic behind the strategy you've made and as a result you're guilty of overfitting.