Back to Community
Help creating leveraged ETF index

Hi there, I'm new to Quantopian and this is my first post.
I'm looking at the leveraged ETF SPXS, which exists only after 2009. I'd like to create the same ETF but before 2009, in order to backtest a longer time horizon. And then be able to trade this index just like SPXS. Thanks a lot for the help!

5 responses

Han, I think it can be tough to replicate leveraged ETFs, they use swaps and other derivatives to achieve their leverage, which is not the same as owning more shares on borrowed cash. You can get an approximation in backtests by trading -3*SPY in place of SPXS, but it will not be very accurate. The only ways I can think of to replicate a leveraged fund would be synthetic positions with options, and buying shares with borrowed cash.

This backtest demos a difference between the leveraged/unleveraged funds. It shorts SPXS and 3x as much SPY, re-hedging this every day with some unrealistic leverage generates a steady return.

Clone Algorithm
Backtest from to with initial capital
Total Returns
Max Drawdown
Benchmark Returns
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: 547e405efe9b6a5844f25f7e
There was a runtime error.

David - what is the origin of 6-week cycle in the algo results? That could be something important, either an anomaly or a bug.

I am not 100% sure, but my guess is that it is a combination of how the fund rolls their contracts, how they deal with SPY dividend payments, and how Quantopian handles dividend events. I don't see the bounce in data from Yahoo, but they evenly distribute dividends across the period when adjusting their prices, and Quantopian distributes dividends on payout dates iff you had shares at the ex-date.

Makes you wonder if there's a way to extract that bounce, my guess is that it's a pretty efficient price mechanism if it exists. Most funds are leveraged via derivatives and don't dividends, so maybe there is something to it.


Just figured it out, SPY has ex-dates roughly six weeks prior to payment dates. On the ex-date, while short, you get a bump, and then a dip when the actual dividend cash leaves your account. I suppose as long as zipline doesn't forget about that delayed dividend (ie if you were short overnight just over the ex-date, then went flat) it's as expected.

Just use this formula to make your life easier.

L = LETF price
S = Underlying price
Lambda = leverage
sigma = Underlying vol
t = time step

That's the result you get when you solve the SDE dL = L*lambda*dS/S where dS = uSdt + sigmaSdB (gbm)