Back to Community
Ballistic XIV/VXX (my best long XIV/VXX strategy to date)

Another simple RSI strategy, yay!

This strategy is applied on the 2-hour interval for XIV (note that the last interval of the day is only 30 minutes, not 2 hours because there are only 6.5 hours during a normal trading day).

1) Calculate RSI2 and RSI5 for XIV
2) When RSI2 crosses below 85 and RSI5 < 70, buy VXX
3) When RSI2 crosses above 70, sell VXX and buy XIV
4) When RSI2 crosses below 85, sell XIV
5) VXX has -1% stop loss and +50% take profit
6) XIV has a "doomsday" stop loss that is placed far away at -25% just in case a black swan/nuke goes off somewhere (warning: will not work if the nuke goes off overnight because XIV will certainly gap down A LOT when the market opens in the morning).
7) Additionally, there is a "panic button" that automatically dumps XIV if it loses 10% or more within an intraday time interval.
8) Lastly, if XIV rises at least $1 above entry price and then drops back down to entry price or below, a break-even stop loss is triggered.

Hedging suggestions: buy monthly SVXY puts that are 30-50% out-of-the-money with about 1% of portfolio value to hedge against black swans. Weekly puts also work; just use about 0.25% of portfolio value. Worst case scenario, XIV/SVXY crashes to $0 from an overnight black swan and hopefully your puts will balloon in the morning to offset your XIV/SVXY blow-up, which means total portfolio max drawdown should be contained within -30% instead of -100% (although that's not a guarantee).

Shout out to Mohammed Khalfan for porting my PowerLanguage codes for this strategy from MultiCharts to Quantopian!

Feel free to improve this algo with your own twists! For any collaboration request, please email: [email protected] and [email protected]

UPDATE (9/13/2017): all previous versions of this algo posted in the comments below prior to September 2017 used incorrect codes that I posted originally which cause many VXX trades to not trigger. The current version has been fixed (+20,000%).

Clone Algorithm
566
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: 59a8741448626d55004afaf7
There was a runtime error.
91 responses

How would this strategy have preformed in 08?

It is not possible to backtest this strategy pre-2008. There is no intraday synthetic data available for XIV.

Everyone who is hoping to see a volatility strategy that would have survived 2008 is gonna be in for a big disappointment when the next crash comes. No matter how well your backtest performs, you must always assume that trading volatility = 100% loss during 2008-level events due to the extreme nature of vol trading. If your strategy ends up navigating the next crash well then that's great but to assume that it will do so is frankly unrealistic IMO

Well done. I like the way this operates more than your other 2 XIV-related algos.

Sorry to hit you with the same question as in the other thread (XIV shotgun), but is it possible to park the funds in a safe-ish fund (AGG, etc) while leverage is zero? Thanks.

For this one it's not worth it IMO because its trading frequency is higher than the other ones so you'd likely lose more money to commissions and slippage. You can try if you want.

Can confirm, overall return goes down when parking cash in AGG. If you were to assume commission-free trades on Robinhood, it goes up slightly.

The brief leverage spike at the beginning appears to be due to liquidity issues with XIV, but I'm not sure why there are brief periods of sub-1.0 leverage. I just crudely tacked on AGG and didn't really look things over afterwards.

Clone Algorithm
18
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: 59910a2120d6c650f5b3a6bf
There was a runtime error.

My main worry is that if 2008 v. 2.0 happens this entire portfolio would get absolutely wallpapered with zero chance of recovery.

@Kern and Sean, it looks like parking in TLT instead of AGG did better.

Clone Algorithm
122
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: 5991229e8a017650daa85e2f
There was a runtime error.

@Kern and Sean, I tried parking in VXX when not in XIV. Not bad.

Clone Algorithm
16
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: 599122c0c4c98850f117adf2
There was a runtime error.

@Delman A good rule of thumb when it comes to volatility strategies is you SHOULD assume that your portfolio will be wiped out completely during GFC 2.0. You're playing a strategy that does close to 100% in CAGR and you want it to survive a crash, too? Life is not that easy, my friend, and nothing that good can last forever.

What you CAN do is hedge with options or allocate only a small portion of your portfolio to volatility strategies so that they won't wipe you out completely should worse comes to worst. Check out this great post by my buddy Cesar Alvarez: http://alvarezquanttrading.com/2016/09/28/taming-high-return-and-high-risk/

Below is the same algo but it only uses 20% of the account per trade. The rest is always parked in IEF (mid-term gov't bonds). Note the Sharpe ratio vs SPY.

Clone Algorithm
122
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: 599127223e8f8550dcd2914f
There was a runtime error.

Looks nice! Are you trading it live currently? Looks very well elaborated, thanks for sharing!

I am, via MultiCharts. It's been doing well

@Delman -- 2008 didn't happen overnight. These are great in sunny weather, but definitely switch to something safer when you start sensing some warning signs.

@Kory -- I'd be careful with a dynamic 20% strategy like that -- or at least be aware that it can be misleading, because once volatility starts snowballing it'll keep selling bonds at each rebalance in order to keep your inverse volatility exposure at 20%, until you are entirely wiped out -- sure it'll happen slower, but it can still happen. The algorithm needs some extra logic if you want it to protect your funds in a crash.

@Kory, that is also a great trading strategy. It can scale up too as shown.

Great work again.

Clone Algorithm
26
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: 5991fb63ba895150f559b6c0
There was a runtime error.

Pretty cool. Have you tried combining it with UVXY? Not parking, I mean using RSI also in UVXY.
Also, have you tried selling before EOD? You know, because of the nukes.

@Viridian, very true sir, thanks for pointing that out. This is why I hedge my vol portfolio with options (for SVXY because XIV has no options). The best hedging strategy IMO is to buy 3-month puts that are about 50% OTM. Do this with about 5% worth of whatever your XIV exposure is. For example, if I hold $10,000 in XIV or allocate $10,000 to XIV per trade, I would buy $500 worth of SVXY puts and hold them every 3 months. This would likely help prevent a black swan or 2008-type blowout (although nothing is for sure!).

@Guy, are you sure it's scaleable? It trades a lot and I used fixed slippage, not volume share slippage. XIV only has about $1B of average daily volume. Your backtest was pushing over $10M per trade since 2015, not sure if that's realistic according to the volume share slipapge model. Then again, it may not matter according to this document from JP Morgan since XIV's underlyings (VIX futures) are highly liquid, the volume share slippage model may not be accurate for this type of security.

@Nic, I do have a long VXX version that's more optimized. Will share in a later post. And no, I generally hold overnight because not enough profits to be made intraday; most profits come from overnight gaps. I use options to hedge for black swans.

the performance is terrible in 2017

@Eric, yeah the Trump Dump in May and early July volatility caught the algo off guard. Still, up close to 50% YTD and still another 4.5 months to go before the year ends. We'll see!

Kory - I wanted to thank you for your generosity in sharing these algorithms!

You are welcome! As a trader, I need as much good karma as I can get :)

Thanks for sharing this! I modified it to be usable on Robin Hood and some logic to prevent be marked as a pattern day trader when starting with less than 25k until it reaches more than 25k, and somehow the result of the back test went up by a lot more! I will start trading it on Robin Hood tomorrow with 7k and see how it goes.
Thanks A LOT again!

Nice! If you want, please share it with us so we can take a look, too.

@Kory, I have not read your code yet. I am only at a preliminary investigation stage.

Your first chart showed some alpha on low initial capital. So, my first question was: it the thing scalable? It is, but only to a certain extent.

Now, that I see it could have delivered, my next questions are: is it feasible, is it maintainable, what are the limits? Which would be followed by: can I improve on the code? This, evidently on the condition that I could, and that sustainability was also there.

My initial take would be that your current strategy could have its place in a portfolio of strategy just for the alpha it brings to the party. Such a portfolio would render your strategy less risky by technically drowning its volatility and drawdowns.

So, yes, it passed my first test. Now, having the same caveats as you do, I have to see where it all leads. But, definitely, I do think that you have something there. It is time for me to do my homework. Is this thing feasible, sustainable and for how long?

Hi, Kory,

Just couldn't stand all the hard coded stuff.... here is a 32% XIV / 65% IEFversion with 2.5% stoploss and I recoded the 2 hr thing so it looked less .... you know

cheers, Peter

Clone Algorithm
76
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: 5992edc8a863d35511e2ebaa
There was a runtime error.

@Kory, can you explain what and how exact does # panic button do?

@Wendon, it sells XIV if the price of XIV has fallen 10% in the last interval (2 hours, or half an at the end of the day). Because XIV can fall by such huge amounts, if it starts falling really fast it's a good idea to get out and wait it out.

@Peter, thanks! My friend Mohammed coded it for me originally.

It's my understanding, just looking over the code, that this algorithm is heavily dependent on a decent chunk of starting capital + day trading to succeed?

@Delman, more swing trading than day trading although it can day trade if it decides to do so. And no you don't need a lot of initial capital. As a matter of fact, these volatility strategies should occupy no more than 5% of your portfolio. Although your account needs to qualify for margin trading in order to bypass PDT rule

@Kory

    if price - context.BuyPrice >= 1:  
        if context.BuyPrice > context.SellLossPrice:  
            context.SellLossPrice = context.BuyPrice

What is the logic behind "if price - context.BuyPrice >= 1"? I think you meant set new stop price if current price increases $1 you raise stop price to buy price. However, what this $1 means a lot different when XIV price is at $10 range vs. $100 range. Would it be more reasonable to change this to a percentage?

@Wenbo, I think that was supposed to be left out. My friend Mohammed coded this and there is a trailing stop loss component that he hasn't coded yet. Those lines were probably meant for that.

@Kory, thank you very much for your kind explanation. I would like to do through investigation before throwing real money into it.

Now I add below log to follow the buy/sell decision maker after your RSI calculation:

log.info("Current XIV price %.2f @ RSI_2 level %d, previous %d, %d and RSI_7 level %d, previous %d, %d" %(data.current(context.XIV, 'price'), rsi[-1], rsi[-2], rsi[-3], rsi7[-1], rsi7[-2], rsi7[-3]))

I find that sometimes the rsi[-2] of current my_rebalance schedule does not match the rsi[-1] of last schedule. And in a few cases it impacts the buy/sell criteria. See below example:

2017-01-04 12:59 my_rebalance:142 INFO Current XIV price 52.84 @ RSI_2 level 87, previous 99, 99 and RSI_7 level 93, previous 95, 94
2017-01-05 08:29 my_rebalance:142 INFO Current XIV price 52.17 @ RSI_2 level 36, previous 84, 99 and RSI_7 level 84, previous 96, 98

At 12:59 the RSI is 87, and at 8:29 the following day the RSI drops to 36. By algorithm I should sell XIV, however because the RSI[-2] read is 84 rather than 87, now I end up not selling XIV.

That puzzles me what causes the data mismatch?

I dont think this is relevant anymore since Quantopian will no loger support brokerage integrations.

Since multiple people send me messages asking for the algorithm to avoid being marked as a pattern day trader on Robin Hood I post it here, sorry I have been busy lately.
The algorithm also uses Robin Hood gold, that you can set up in a variable how much you use, you can set 0 if you dont use gold at all.
Also you may want to modify it so if it is a panic sell triggered, it shouldsell anyway, this version does not do that but still does well.
I am live trading a similar version to this one but I made some other adjustments and I trade other equities too, so could result confusing.
If anything read the comments on the code or if you find an error please let me know right away!
I hope this helps someone!
Thanks!

Clone Algorithm
117
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: 599cda91b97574555fccd7a0
There was a runtime error.

I am fairly new to algo trade and quantopian (although i have fair knowledge on option). Can somebody explain the philosophy on this XIV long strategy (e.g. when RSI2 crosses above 70, buy XIV. When RSI2 crosses below 85, sell XIV) ? Also, can we have a "similar" strategy by long VXX instead ? I mean..we are all a bit more comfortable with holding long VXX overnight position than XIV (because market crash is always unexpected), although VXX has "contango loss".

I wasn't familiar with the concept either, but this page might help you to better understand: RSI7

Algo fixed. See my original post at the top.

"Conservative" version of the fixed algo. 20% algo, 80% treasury bonds.

Clone Algorithm
566
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: 59aadedca313c050fc4e2bd9
There was a runtime error.

Very nice Kory.

Have you tried using the Kelly criterion for position sizing?

Nic,

I have not. Will try to implement that in the future.

Where can this be live traded with the lowest monthly cost? Multicharts is very expensive and Quantopian is good for analysis but not tradable. Would porting it to QuantConnect be a good option?

@Honver email me and I can help you. [email protected]

@Kory

This is the change when XIV is sold, if RSI215 sell VXX. Note that it is compatible with Robinhood meaning no commission and 95% order.

Clone Algorithm
90
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: 59ae9ef72e2da35103dc148c
There was a runtime error.

@Wenbo when I used Kory's original slippage and commission assumptions as well as start date, I got results closer to his. Good improvement though. I like how the new triggers are very symmetrical.

Clone Algorithm
68
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: 59bebaded0287556001b4ba2
There was a runtime error.

@Kory

After running the backtesting I see in the logs some error messages as follow:
... 2016-11-25 18:59 my_rebalance:133 ERROR 2 HOUR CONVERSION FAILURE
...

Is this the reason as you wrote at the beginning as below?

... This strategy is applied on the 2-hour interval for XIV (note that the last interval of the day is only 30 minutes, not 2 hours because there are only 6.5 hours during a normal trading day).
...

@Quant Prophet

Note that in my robinhood version I only buy with 95% of the cash. You can use 100% for IB and your result should improve a bit.

    order_target_percent(context.XIV,  context.xivTradePercent * 0.35)  
    order_target_percent(context.XIV,  context.xivTradePercent * 0.3)  
    order_target_percent(context.XIV,  context.xivTradePercent * 0.3)  

Added custom slippage model to properly model spread at higher XIV prices.

Clone Algorithm
70
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: 59c1cf895c66e1506e426017
There was a runtime error.

@Honver

Please replace all
order_target_percent(context.XIV, context.xivTradePercent * 0.35)
order_target_percent(context.XIV, context.xivTradePercent * 0.3)
order_target_percent(context.XIV, context.xivTradePercent * 0.3)
with
order_target_percent(context.XIV, context.xivTradePercent)

@Hover - Spread? I have never seen a spread greater than .01. I've stated in multiple threads that the Quantopian slippage should not apply to this ETF. There are millions of shares traded, unless you're pumping in millions of dollars, which I assume us smaller investors are not doing.

@Wenbo - when you make that change the performance drops to ~500% from over 30000%? Was there a lot of leverage in your original algorithm?

The slippage is half of the spread and is a minimum of .01. In cases when the spread is greater than $.02, which happens at higher prices due to XIV's average 0.03% spread, the custom slippage model modifies the slippage accordingly to be more than $.01.

@Wenbo Zhang

Have you figure out the data mismatch you mentioned in Ausust? I have seen similar problems even just by checking a 30 mins bar close information. Thanks,

6) and 7) both sound like stop-losses. What's the difference between these? (I looked at the code but I don't have any training in Python so I can't figure this out on my own...)

@Thomas, it's about 'half_day = True', if you setup 'half_day = False' then not any such error raised and overall return is better as well.

@David, if you set 'half_day = False' , what will you do if there is a crash on a half-day ?

@Thomas, the handle_data will always work and if the strategy has XIV positions, it will process the stop lose.

Hedging suggestions: buy monthly SVXY puts that are 30-50% out-of-the-money with about 1% of portfolio value to hedge against black swans. Weekly puts also work; just use about 0.25% of portfolio value.

Have you back tested this? You can do so with VIX options which began in 2006 ish. Agreed it's a slightly different animal but I found it of some use. And of course you will buy calls not puts.

Actually, I couldn't give a stuff how it backtests. XIV is almost bound to go bust (at some stage) and at current volatility a 3 month put on SVXY makes good sense.

XIV has been around for 7 years. Has something changed recently to make you think it'll go bust?

Backtesting to 2004 using futures. In a big enough fast enough spike managers will need to protect themselves and have said so in prospectus. I hope it does not happen but I have hedged my position in a couple of ways.

A curious question. Why use this type of 2 hour setting? How about 9:30-9:59,10:00-11:59,12:00-13:59 and 14:00-16:00? Would that be significantly different? Thanks.

Hello community,
thanks for sharing this very interesting algo. Please, I'm quite new to quantopian and I hope somebody could answer these probably simple questions.
I see the following code within the function "rebalance":

if '20:00:00+00:00' in str(xiv_prices.index[-1]) or '21:00:00+00:00' in str(xiv_prices.index[-1]):
xiv2hr.append([xiv_prices.index[-28], xiv_prices[-28]])
xiv2hr.append([xiv_prices.index[-27], xiv_prices[-27]])
xiv2hr.append([xiv_prices.index[-23], xiv_prices[-23]])
xiv2hr.append([xiv_prices.index[-19], xiv_prices[-19]])
xiv2hr.append([xiv_prices.index[-15], xiv_prices[-15]])
xiv2hr.append([xiv_prices.index[-14], xiv_prices[-14]])
xiv2hr.append([xiv_prices.index[-10], xiv_prices[-10]])
xiv2hr.append([xiv_prices.index[-6], xiv_prices[-6]])
xiv2hr.append([xiv_prices.index[-2], xiv_prices[-2]])
xiv2hr.append([xiv_prices.index[-1], xiv_prices[-1]])
context.last_bar = True

questions:
- what are we trying to do with this part of the code? are we looking for those items of the series object that have time 8pm or 9pm?
- and why 20: and 21:... ?
- also, why are we appending items 28, 27,23.. from the bottom of the series? like why 28? why then we skip 26 and 25?

Thanks for taking the time to get back to me.
Kind regards,
Angel

@ qi chen
Everybody has his stratergy. Simply back testing your idea. If you find yours is better, than use it.

Pay attention: The time zone used by QuantOpian is UTC. There is 5 hours different than that of US/Eastern.

@Angel Quant

I try to answer your questions as bellow.
- what are we trying to do with this part of the code? are we looking for those items of the series object that have time 8pm or 9pm?
I think the author try to construct the 2-hours block which consists of: 16:30, 18:30, 20:30 and 21:00. (pay attention to the time zonedifference)

  • and why 20: and 21:... ?
    Bcz of Sommer Time.

  • also, why are we appending items 28, 27,23.. from the bottom of the series? like why 28? why then we skip 26 and 25?
    SImply resample tp the 30-minutes block and try to constrcut the 2-hour-block as mentioned above. You can understand why.

Congrats Kory, this survived the XIV meltdown.

Viridian, could you share a backtest to see the impact of the past week?

I'm happy to announce that all of my XIV algos survived Black Monday 2018!

Hopefully whoever used this also survived the XIV collapse as well. It even bet on VXX that day for a massive +50% gain :)

Clone Algorithm
211
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: 5a7fc7cc6f9feb46a6f09e4f
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.

Well done!

But how are you going to do in the future? With SVXY?

I've back tested your algo with SVXY. The total return is quite "bad". I am not sure if this is because the SVXY has several splits in its history and the Quantopian just provides the non-adjusted price and this will distort the indicator?

Thomas, SVXY is an ETF and not an ETN...although roughly they should behave the same they didn't 100%.

Since the leverage of SVXY changed since 27 Feb 2018, it's -0.5 to VXX, not -1.0 now.

Any suggestion of which measures will be changed in the strategy now?

In my opinion, the stop lost percent need to change to -0.125, not sure about the RSI[-2] and RSI[-1].

David, I think you should study RSI a bit more.....if you know what RSI is you will figure out the answer.

Thanks Smith, after studying the calculattion of RSI, I trend to consider no changes needed for RSI measurement.

Any good ideas on how to backtest some simulation of the reduced SVXY power? Just cutting in half the old algo's position does not work since it really messes with the ability to compound returns. I have a hunch that the ratio of what you buy in SVXY vs. VIXY needs to be equivalent, but its hard to prove without a solid equivalent backtest...

According to the ETFDE.com, the leverage of SVXY is just 0.5x. The former XIV has 2.0x. You can't find now any underlying which could compare to XIV. Or you should multiple your account-leverage for SVXY?

You can still opt for:
ZIV

or short selling TVIX (but short selling is not always a good option..)

VMIN

For me the VMIN is a NO-GO since its total assets is too small. :-/

@Carlo,

I wonder how did you use the ZIV. I've tried it but the return is "terrible" :-/

@Thomas

I did not use it, but it is very similar to XIV - leverage of 1.0 though. What is interesting though is the high alpha - they do exist. Maybe you have to pair it with VXX (to match the mid term).

For a good analysis / strategy you might want to look at this paper:
Easy Volatility Investing

Let me know the results.

I opted for reducing the VXX exposure down to 0.5 in the algo vs. using margin with SVXY (not sure if many brokers would let you margin up anyway). This seems to be a good balance of risk/reward for me. It wont be nearly the golden goose as the original, but should still would give good returns over the next few years if volatility does revert as many of the papers claim.

If shorting VXX, I think you will get around 0.5~0.7 exposure since brokers like IB has a margin requirement for shorting volatility-related products.

Also, I think this algorithm is pretty time-sensitive (try to move the 2-hour intervals a little bit) and pattern-sensitive (due to overfitting?) for real-trading.

You can still try to play it in the European market, as there the ETN's are still in play - the pair EVIX and EXIV should do the trick. Both are not leverage and should go in tandem. However, I would still recommend to apply the formula from Tony Cooper or at least try to play with it.

@Adam Chen
"try to move the 2-hour intervals a little bit"

What do you mean "a little bit"? I think this algo must be a day-trade, otherwise in case of black swan of 5th Feb you could lose a lot of money.

@Carlo
The article of Tony Cooper is very famous and I guess most of the people have read it. But Tony's algo is also use daily data.

The volumn of EVIX and EXIV are too small. It's quite "danger" to trade them. :-/

There is a way to replicate XIV using futures there is an article about it, you'll probably need a 100K account size minimum to track it correctly. Just wondering from backtesting this it seems majority of the profits come from the VXX positions, seems like long XIV doesn't provide much of the performance?

Also going forward what will be used for XIV data, given it doesn't exist anymore.... kinda throws a big monkey wrench into the strategy.

I am new to quantopian but have enough experience on UVXY/VXX/SVXY/XIV trading. As everyone knows XIV was terminated. How this system works on SVXY? Thanks

...have enough experience on UVXY/VXX/SVXY/XIV trading
...How this system works on SVXY?

replace the XIV with the SVXY?

SVXY has less leverage now, nothing will compete with XIV, you have to use futures to replicate XIV, even short VXX in backktests showed poor performance.

@Elsid So you want us to sell VIX futures instead of buying SVXY? Do you backtest this strategy?

Short VXX gives results that would look like XIV. But SVXY is also a good replacement, if you need the leverage you might think if trading vol ETF's is wise regardless. Ofcourse you can replicate it with futs but that is not all that different from short VXX

@siva

There is a calculation where you can track the XIV through futures, but you need a minimum of 20 contracts to track correctly. You basically replicate the XIV with futures contracts, but that is you throwing a $200K-400K account minimum to run this strategy even with the lowest of margin rates on VIX futures.

Another option is to use the same method to calculate synthetic XIV data, and than just short VXX as an alternative to long XIV, as @Kees mentioned, but the issue is you would need intraday synthetic XIV data.

Does anyone know if any data provider is providing intraday synthetic XIV data?