Back to Community
First Try "Algo". **Why isn't this allowed on contest??**

So I found this website about a week ago and I'm hooked. The "algo" I made is called reballypower, because all it does is rebalance itself. It only takes equal and offsetting short positions in 3x levered etf/ns. Just a note this is my first week in python.

Improvements I want to do:
Throughout the week, like every few minutes or so, check if rebalancing will make money.
Put in stops and fall safes.

I also find it interesting the contest rules wont let anything like this into competition. This has a beta of like .04.

Clone Algorithm
35
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: 57b1e5c78a85030ffc4a2a15
There was a runtime error.
20 responses

Fully hedged, leveraged version.

Clone Algorithm
6
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: 57b1f5d71b6cac1001dd789a
There was a runtime error.

Thanks for the suggestion Tim. I tweaked it a little and changed the back test dates.

Clone Algorithm
35
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: 57b214e645381b100330f028
There was a runtime error.

Interesting how liquidating the portfolio before the week-end smoothes the performance (equity curve). Well done.

i feel like short selling a 3x leveraged etf is cheating. you could just short sell all leveraged etfs in mass and never lose because they by definition bleed value over time.

is what you're doing even allowed? im not sure quantopian tracks which etfs you are allowed to short sell.

@James Hutchison

Thanks for your comment. For some reason this isn't allowed on the contest. And yes by definition they bleed, that's the point. But the beauty of it is how it is perfectly hedged and how the rebalance each week makes it almost free money.

@Tim

Thanks for noticing, I think it has to do with it always gaping over the weekend, because the underlining futures are always trading.

contest rules say you can't trade leveraged etfs

my point is the broker won't allow short sale of many etfs and etns. for example, you can't short sell uwti and dwti.

you can short sell uvxy and tvix. have fun making an algo that does that. i think one guy did a short sell of uvxy and svxy which is allowed and made 60% per year.

@ James Hutchison

IB says UWTI ,DWTI, NUGT, and DUST are available to short. Am I missing something?

nope, i might be mistaken. i thought i looked that up before but i was probably thinking of something else

could also be that different brokers have different rules depending on the account.

i did some more research on this topic and one thing i wasn't aware of is that there are fees for shorting these things that vary from 4-10% per year which quantopian does not model. also, your algo has to be weary of one of these etfs making a killing. Adding logic to "get out" if one starts doing that might end up cutting into the returns of the algo. it's also likely that you would need money in the account that is not shorting anything to provide as collateral, which is also not modeled by quantopian.

For another variation check out this post https://www.quantopian.com/posts/exploiting-etf-decay. There is also an external link which references more on 'etf decay' and a potential strategy. Seems to have similar returns.

It nice but shorting inverse ETFs ain't cheap. It's foolish to not model the borrowing cost and commissions too.

@ Dan Whitnable

Thanks for the post, I think the only problem with Mo's algo is that it isnt a hedged great. Think about it half his portfolio is in a bear bond fund TMV, and he only back tested from 2010 when rates where going down. That is obviously going to be a sure thing in the algo. Same SPXU he only back tested a bull market.

@ Minh Ngo

I'll work on putting in short cost. Max its like 10% a year so ill use something like that. Eyeballing it right now it is still very profitable.

@Connor - you're right, the issue with these ETF decay algos is that they cant be backtested very long because they didn't exist during the 2008 crisis. Most of them started 2009 and onwards.

I studied this code a bit more - the reason this algo gets such high returns is because it goes long on RSP and TLT.

By shorting a bear and a bull ETF, it is already hedging itself. So then going long on RSP and TLT means the algo is actually not hedged - it has market exposure. Of course going long on RSP and TLT over the last few years has produced high returns, which is what is being shown in this algo.

A properly hedged example of this algo is below. It's actually quite impressive, it doesn't use leverage, the drawdown is very low, and the beta is virtually zero.

Clone Algorithm
35
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: 57b36f4e330b68100370bcc5
There was a runtime error.

Upon further inspection, it seems this algo does not perform very well out of sample - see the same algo results for a different period below.

For this I have a theory... this algo trades commodities, and the last couple of years the commodity markets have been very volatile, causing ETF decay which is higher than normal. This level of decay is unlikely to continue in the long term, so returns from an algo like this are going to be much lower (if positive at all).

Clone Algorithm
35
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: 57b37593ffee930ff5d8a09d
There was a runtime error.

@Mo

All good points lets break them down. Original algo is the unlevered and perfectly hedged at most times. Which to me should be allowed in competition even if it is only short positions. I agree that the levered version is not greatly hedged but it is still cool.

The last of your back test would obviously not make returns, because for ETF/N decay to really work you need volatility. Contango helps too. The set at the end also is going to have problems with trading volume since the ETF/Ns were brand new at the time.

I don't think your algo shows ETF decay. It shows that shorting the wrong strat for the past 6 years makes money. Sure there might be some decay in it but that has nothing to really do with your returns. I think you can also agree that is no even close to being hedged.

Thanks for the input and taking the time to post some backtests. Well have to continue. I really need to put in shorting cost to really see a more realistic return. I think Alpha is somewhere.

@Connor - there are 2 definitions of hedging.

  1. The concept of hedging commonly accepted in the entire investing world
  2. The Quantopian definition of hedging used for their contest

1) The concept of hedging in general is reducing market risk. This is done by offsetting a long position with a related short position. So for example if you go short in a gold ETF, and you also go short in an inverse gold ETF, you are fully hedged. This is 2 short positions, but should not be mistaken for "not being hedged".

2) The Quantopian definition of hedging (used in their contest) requires that you have a long position AND a short position. This is because they want to be able to programatically identify algos which are hedged. This is really-dumb-hedging-so-it-can-be-done-programmatically type of hedging. This is not realistic at all, and is easily gamed.

The algo you proposed is not hedged via definition 1, it is only hedged via definition 2. The algo I proposed is not hedged via definition 2, it is only hedged via definition 1.

Many ways to skin the cat :)

i don't think buying both directions of leveraged etfs is hedging, it's a straddle. you lose if it doesn't move in either direction. it usually loses but sometimes wins big

short selling both sides is just an inverse strategy. it usually wins but sometimes loses big.

a true hedge would be something that moves with an inverse correlation to the strategy but doesn't directly offset it. in many cases your hedge would move exponentially while your base strategy moves linearly.

i don't think buying both directions of leveraged etfs is hedging, it's a straddle. you lose if it doesn't move in either direction.

This is only true in options. Since an option is a contract that has an expiry date, then if both contracts expire out of the money (i.e the market doesnt move), then you can "lose".

But we are talking equities. There is no expiry. You dont lose if the market doesnt move in either direction... because you can just wait a bit longer. Unless we assume that the price will be range bound indefinitely... which just seems like a bad assumption.