Back to Community
XIV Shotgun - Trading Inverse VIX with WVF

This is my latest incarnation of the original algo that inspired Pete Bakker's "The SPY Who Loves WVF" post.

Apply on daily interval. Buy orders are executed at EOD. Sell orders are executed next day at open.

Securities for Trading:
- XIV (risk-on asset)
- IEF (risk-off asset)

Securities for Data:
- VXX (used for calculating indicators)

Indicators:
- WVF = 100-day William's VIX Fix of VXX's daily close price
- Smoothed WVF 1 = 10-day EMA of WVF
- Smoothed WVF 2 = 30-day EMA of WVF
- RSI = 3-day RSI of VXX's daily close price

Buy Rules (buy XIV, sell IEF):
- If WVF crosses over Smoothed WVF 1 and WVF < Smoothed WVF 2, or
- If WVF crosses over both Smoothed WVF 1 and Smoothed WVF 2, or
- If Smoothed WVF 1 crosses over Smoothed WVF 2

Sell Rules (Sell XIV, buy IEF):
- If WVF crosses under Smoothed WVF 2, or
- If RSI crosses over 50

Take Profit/Stop Loss (XIV only)
- TP = +25%
- SL = -3%

Please feel free to comment and improve this algo. For collaboration request, please email: [email protected] and [email protected]

Clone Algorithm
474
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: 594bf85817d98707e4012562
There was a runtime error.
35 responses

Tearsheet:

Loading notebook preview...
Notebook previews are currently unavailable.

Is it possible to test this algorithm prior to 2010? esp. around 2008. I keep getting NaN error....assuming no data?

I like it. Depending on what you are looking for, this is likely to be attractive to some.

Very cool. Would this algo actually be able to execute the orders right at market close? I suggest having it execute a few minutes before market close and also adding some code for retrying cancel orders just in case.

I noticed that XIV Shotgun purchased XIV at $85.66 at market close 2012-07-12. It has not sold yet. Pretty good cherry pick so far!

Very interesting algo!

  1. It would be very interesting to see, how the algo performed from 2004-2010 because the bullish market from 2011-2017 is ideal for the algo.
  2. Adding position sizing might give some additional safety - any off-market black swan event could wipe out the position, so using for example 33 % position size for the XIV and 100 % for the IEF might make the algo tradeable. Just an idea...

I've just noticed an error while running this. I have the issue of it ordering more XIV than allowed so I set it to only trade 90% then I was able to buy XIV when the next order came through, but still at only 90% it tried to order 1 more share of bonds than I am allowed to purchase. I ran a backtest and it showed that it should have ordered the right amount so I am confused about this issue. Would there be a way if rejected to then order 1 less share until purchase?

Here is a version that can use Robinhood margin. I think it may work for Interactive Brokers with margin. It is using, apparently, IB compatible commissions and slippage.

I think the TarPer function does a reasonable job keeping the orders small enough to not be rejected.

Clone Algorithm
37
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: 597faae6adf3894f1289d092
There was a runtime error.

Hi Kory,

I'm relatively new - still got a steep learning curve. General question: why do you use "Symbol(XIV)" in your code as opposed to using "sid(40516)" (as example - same for other symbols)?

Also @Charles Witt - learned a ton from you in other posts. Appreciate all the responses #QuantopianRockstar

The algorithm navigated this sell of brilliantly. Has anyone found a way to test against and '08 scenario?

Hi Tyler,

I use a different platform called MultiCharts to test and execute my strategies. Quantopian is only one of my research tools. However, I did test this strategy on MultiCharts using synthetic XIV and VXX data found here. You should read this to understand the caveats of using synthetic data. With that said, the strategy survived 2008 but it would have had a 50-60% drawdown.

@Geoff,

No reason. Just preference.

I have an even more aggressive version of this algo that wouldn't have survived 2008 without a bruise neither but it would have grown back a hell of a lot faster and stronger. Here it is:

Clone Algorithm
113
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: 598fd11f98747e50f360d9c8
There was a runtime error.

Is there a way to reduce drawdown by swing trading XIV, and holding a conservative/moderate portfolio in between? Or swing trade XIV as a percentage of your portfolio rather than going all-in?

I might try and get some quick and dirty code together later to see if that is effective.

@Delman Check this out, you might like it. 50% is allocated to a version of XIV Shotgun and the other 50% is allocated to a high yield bond momentum strategy.

Clone Algorithm
109
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: 598ffbcfd2551b50de3bd4e7
There was a runtime error.

@ Kory Hoang it would be very helpful to many users on here if you could backtest Charles Witt strategy back to the 08-09 crisis.

If you can help figure out how to load my own custom synthetic XIV & VXX data into Quantopian then I'll do it

Hey Kory, great algo.. I was just backtesting this yesterday and noticed quite a bit of downtime (ie where leverage is 0). Would it be possible to stick all available cash during these periods into the bond funds, and then sell when the time is right to buy XIV/VXX?

Edit: Also, I was getting slightly better returns with half-day set to True.

Happy to report the original algo has margin average of only $14.28 per day until near the end, almost nothing. (https://www.quantopian.com/posts/margin). Is there some reason one would not want to trade this with real money? (volatility or drawdown or or ?)

@Kern sure. With low trading frequency algos like these, I usually make them park in IEF or TLT when not activated.

@Seahawk I've been trading XIV Shotgun since March along with 6 other algos for our startup's charity fund (www.quantprophet.com/charity)

Congrats. With 7 algos, different start dates and possibly transferring profits out and/or adding to them occasionally it might take a team of accountants to arrive at a percentage in the real market but if there is any way to gage a backtest comparison that'd be cool.

I've had a few hiccups along the way. The biggest problems for me so far are human error and system failure, not actual problems with the strategies themselves. They have been performing very well as expected and slippages have been in line with my assumptions.

My broker's (Interactive Broker) portfolio analytics feature actually calculates my return net of deposits/withdrawals for me so I don't have to worry about that (but I don't often deposit/withdraw from our startup's charity fund anyway).

@Kory, I've played around with your version of the algorithm a little bit, and the only thing I cannot figure out is how to get the leverage at or equal to 1. Even turning down the XIV to Bond ratio, it jumps unexpectedly. Any thoughts?

Will Quantopian allow me to trade different strategies in the same account? Say I could set the cash to 50% and trade 2 strategies this way?

@Tyler, no. You'd have to combine them into one algorithm or open a second brokerage account.

@tyler. If you use IB you can create linked accounts and they consolidate in the master account. The linked account needs its own login. I have 6 Algos like that

I love this algorithm, so I've decided to improve it, simplify it, make it more efficient, and more profitable.
I may have a bug because it was just a quick adjustment, but some bugs could actually make it better :-)

Clone Algorithm
88
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: 5994d7646ded6550eb386255
There was a runtime error.

@Kon Rad, yes your monkeypick (haha) outperforms but you are missing a key component which is volatility, your sharpe is much lower with a DD @ 50%, so I think you are just proving that Kory algo is actually quite efficient... or did I miss your point?

I am happy to announce that this algo, along with all of my other volatility algos, have survived Black Monday 2018!

Clone Algorithm
474
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: 5a7fcb5b0e2cfb44f8131c99
There was a runtime error.

Here's a screenshot of all my volatility algos taken after the market closed on February 5, 2018. They are set up on MultiCharts. Note the +50% VXX trade on the top right chart.

Looks like the others all lost ~33%? Were you trading these with real money?

Reflecting on what happened, do you think the algos were prepared for this first of its kind event or do you think it was luck? What would have happened had the VIX spike been even more out-of-the-blue (e.g. caused some overnight black swan event)?

They did not lose 33%, I'm not sure where you're seeing that. They all went to cash long before the crash took place. Check out the latest backtests in my other posts for reference. And yes I've been trading all of them with real money for 2 years.

The algos are trend-following by design and were well suited for the scenario that unfolded, i.e., a gradual crash that took place over several days and not a flash crash.

Also, my hedging strategy of buying SVXY puts mentioned here also resulted in over 100x return for the hedge, which would have effectively canceled out your XIV loss on Feb 5.

How did you real-trading? As Quantopian cancels its support.

Nice work!

How about using leveraged ETFs like UPRO/TQQQ/SOXL as trading securities?
We can remain VXX and WVF as indicators.
This could reduce the systematic risk or "black swan" as XIV/SVXY can suddenly drop to bottom (could be during overnight or weekends).
(If the auto-trading system has a problem and we hold XIV/SVXY for a long time, it could possibly be a disaster, too.)

Other thoughts:
Maybe we can replace VXX with UVXY to increase the indicator's sensitivity, or use Money Flow Index (MFI) to replace RSI.
Or use MACD's derivative as another indicator.
These naive thoughts may also work for the "Ballistic XIV/VXX" strategy, or be used for inefficiency detection of other assets.

Anyway, simplicity is always better than complexity. I just propose these ideas for discussion.

Hi,

Beginner question here : how do you live trade ? Do you manually buy or sell according to the signals generated by the algo or is it automatic ? I cannot see any command in the algo which would execute the trade on a trading platform.

Thanks in advance for the reply.