Backtest 1.0 – Encouraging First Findings

Just got some very encouraging results creating a set of backtests to understand the equity curve when shorting pairs of inversely-correlated 3x leveraged ETFs.
– Code on Github: https://github.com/postbio/infinite_decay/blob/master/backtest.py
– Results on Google Drive Folder: Backtest 1.0

1. Data

Downloaded the daily closing prices of the following tickers since their inception.
NGUT/DUST, UGAZ/DGAZ, ERX/ERY, TNA/TZA, TQQQ/SQQQ, UPRO/SPXU
I chose these since they were among the most liquid, but plan to expand on the number of pairs, identity of each ticker in a pair, and or even sets of tickers on each side of the market.

2. Daily Profit/Loss

Starting from inception of the ETF and for the first day of each year for that year, backtested on a $20,000 in margin allocated to a pair, with each ticker receiving half of that, and using the daily returns based on the closing prices. This was done since inception, and starting from the first trading day of each year.

I’m assuming that this $20k is some small amount of portfolio size such as 5% – 10% so that both margin considerations aren’t an issue, and that I can short other pairs in other uncorrelated sectors. The goal is to have short pairs on five or so sectors across the entire portfolio, stressing the importance of low correlation between them. This requires more market research and backtesting, at the portfolio level one level up, which can be discussed in another (series of) post(s).

Screen Shot 2018-12-23 at 03.09.08
Example of a Backtest

3. Rebalancing

When shorting pairs of leveraged inverse ETFs, of course one ticker will always move up and against you. In an ideal world, both sides will eventually mean revert, and go back to the initial price you entered, minus the continuous Beta slippage losses (and other favorable losses to short positions on the underlying ETF, such as management fees), which provide the source of profit. In the real market, the side that goes up and against your position may both spike in the short term and trend in the long-term. Since shorting an ETF can lead to infinite losses, even with the mitigating factor of the winning side winning but not fast enough, one has to actively manage the allocation of the notional value of each side through a process called rebalancing.

From various posts on Seeking Alpha, it seems a crucial issue is to find the correct rebalancing threshold.

There are multiple ways to rebalance. The three classes are:
A. Reduce the size of the losing side
This is useful to cut risk exposure immediately, but suffers in that it also prevents the ability to recover any losses as that losing side heads back down.
B. Increase the size of the winning side
This is useful assuming we are looking at that side “only”, since we still have to account for the losses on the losing side, and those may still spike up faster than the winning side gains, depending on the the relative symmetry of the pairs.
C. Redistribute the size of both the winning and losing side
Reduce the exposure on the losing side take realized profits on the winning side, and reset the trade so that they have equal exposure in terms of notional value. This is the method I used.

Example:
Let’s say I’m shorting $10k worth of $NUGT and $DUST with a rebalancing factor of 25%. The number of shares of $NUGT and $DUST would be N($NUGT) = $10k/price($NUGT) and N($DUST) = $10k/price($DUST). Now let’s say the $NUGT side moves against me and the market value of the $NUGT shares are now $13k. This would mean that I have a loss of $3k on $NUGT, and the account balance would be $7k. In a perfect world, the market value of $DUST would drop to $7k, and I’d have a $3k gain there for a total of Profit/Loss (P/L) on the pair of $0.00. In practice, I may have gained more or less than that $3k due to Beta slippage, supply/demand, management fees, etc. Let’s say I’m lucky and $DUST is showing a $4k profit so that my P/L is ($NUGT, $DUST) = ($7k, $14k), for a total $21k margin and net $1k win. What I’d do now is reset the trade by allocating $10.5k each to $NUGT and $DUST, via buying back some shares of $NUGT to reduce exposure to $10.5k and shorting more shares of $DUST to bring exposure up to $10.5k.

Of the SeekingAlpha articles I’ve read on this topic, it seems that the rebalancing percentage is crucial. In the limit that the rebalancing percentage goes to 0.0% with continuous time rebalancing, the benefits of being perfectly hedged are outweighed by transaction costs (bid-ask spread, commissions, etc) that overwhelm any wins from Beta slippage. On the other hand, in the limit that the rebalancing percentage goes to infinite (for no rebalancing), the the trade starts to become an outright shorting of the wrong side of the market, mitigated by the any the gains on the winning side.

So it’s a matter of both finding the optimal rebalancing percentage, and more crucially keeping the initial position small enough so that spikes and runs don’t cause the losing short side to be closed out from a margin call. In the backtests, I’m assuming that the position size is small enough so that it never becomes an issue. As for the rebalancing percents, currently backtesting for: 25%, 50%, 75%, 100%, 125%, 150%, 175%, and 200%.

4. Results

For different starting time periods that I’m defining to be the first trading day of the year, and range of rebalancing percentages, got some first encouraging results. All of them are here in the Google Drive Folder: Backtest 1.0

dashboard-nugt-dust
Profit given different starting dates and rebalancing parameters

5. Future Work

I have much more to write with respect to limitations, improvements, and analysis, but this post is approaching 1,000 words, so will conclude now with some next action items.

  1. Determine if there any rebalancing thresholds for each pair stand out as the most optimal, for:
    • Different date ranges within current tickers
    • Expanded ETFs
    • Different “paired” tickers
  2. Write code for a portfolio of N pairs, extending beyond just one pair at a time
  3. Model transaction costs
    1. Bid Ask spreads
    2. Short borrowing fees
    3. Commissions
  4. Write code to pull historical futures term structure to calculate contango or backwardation, and incorporate this into bias for relative weights of 3x vs. -3x ticker

Author: postbio

Trading blog

Leave a comment