Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Nice 'N Steady - Low Vol, High Dividend with a Vol Kicker

This seems to me like a pretty good algorithm, but it isn't the type of thing Quantopian would be interested in. I had decent results live trading it the first half of last year before Q pulled the rug out from under me. I have at this point been unable to find a suitable alternative for live trading on IB, but still have dreams of making it work. Basically, it puts 80% in low vol/high dividend stocks and 20% in VXX or ZIV (maybe more depending on what it sees). I took pieces from quite a few different algos I've seen here over the last couple of years as well as come up with a few things of my own, so if you see some familiar code, thank you for sharing your idea.

If you are interested in collaborating on a way to live trade this outside of Q, please let me know. Or if you want to try adding in a short component to make it market neutral for Q, I'd be interested to see what you can come up with that works, as I never found something I thought was good enough.

Disclaimer: I'm sure this is overfit in some areas, but it has worked over the last 9 months or so out of sample (about the time I stopped developing it). Also, given what happened to XIV recently, I have replaced instances of it with ZIV (thought I haven't renamed it in the code - I just changed the SID for context.xiv to that of ZIV).

Anyone interested in recoding this in another platform and willing to share what they write?

22 responses

Hi Joseph,

Have you tried removing the volatility portion of the strategy reason i ask is so you can backtest past 2011. My feeling is high yield dividend stocks will crash during 08's 01's the long volatility will probably add on top of it.

@Elsid - I did actually try that. The algo generally gets a boost from going long VXX when the market is heading south, whereas you are correct that the dividend stocks go down. They tend to offset each other, and performance stays acceptable.

@Joseph that is excellent, I know a developer who can easily convert this to trade directly on IB for a fee of course, I'm still backtesting it with different variables I'll wouldn't mind splitting costs together and get it up and running, especially since much of the Python code wouldn't even need to change.

@Elsid - Can you get a quote on how much it would cost to re-write? One thing I'm not clear on is how one would be able to re-write the customfactors for least volatile and highest dividend outside of Q. Thanks!

Yeah I'll look into it, what does Q provide besides data? As long as we can get the proper data which shouldn't be hard, i believe it can be written I'll ask him though. Also was looking I know majority always use IB, but there are better commission structures say like TD Ameri, or any other major brokerage especially for ETFs, stocks. I know IB is better for futures ect.

@Joseph

Hey Joseph, is everything in the algo used? If not maybe you could clean it up, but a preliminary estimate is probably around $1500-$2000 to transfer over to IB or wherever, but that could be because of all the code in there, if it's not needed maybe clean it up and the dev could get a better picture.

Meh... I'll have to give it some thought and spend some time looking into what isn't used. Not sure how gung-ho I am at moving forward with this currently.

@joseph

I think the backtest might be highly misleading I'm looking at the trade logs, and there is a bunch of unfilled orders, I've turned slippage basically off, and it still has these unfilled orders, which would make the backtest kinda useless to simulate real world conditions, or the numbers might be completely off.

If someone can figure out why there are unfilled orders even with the slippage model turned off, assuming it might be the stop loss orders.

I believe what you are looking at are stop loss orders that are placed daily and then mostly unfilled. I know when I live traded it, I never had any issues with partial fills. If you are backtesting in 2010 or 2011 with ZIV, there may not have been adequate volume back then. I wouldn't waste time backtesting with XIV since it no longer exists and we can't use it going forward.

OK that's good to know, Yeah XIV was just an exercise in seeing the difference in performance, you could also use SVXY to get much higher performance.

SVXY is now at .5 leverage from where it was... just an FYI - you won't get the same returns now.

@Tyler

I guess you could short VXX but that has unlimited risk.

Sorry took so long - VXX/TVIX were not levered down they are still the same. Only SVXY and UVXY. SVXY was reduced to .5 leverage and UVXY to 1.5 leverage.

Yes, shorting VXX is now the same as going long XIV with unlimited risk. Otherwise you could do a synthetic short with options, which is doable as VXX is super liquid and has a small bid/ask spread.

I guess you can also double up on the SVXY order and put it back up to 1 leverage.

Good luck getting any leverage from a broker on any volatility ETF/ETN. They now normally require 100% maintenance.

Best best is shorting VXX/TVIX and even UVXY although UVXY is only 1.5 now.

@Tyler

Was SVXY and XIV supposed to be almost identical before the changes? I'm running backtests before the blow up, and XIV still outperforms SVXY, my a large margin.

SVXY and XIV were inverse VIX, but each were calculated differently - they were never a 1 for 1.

Sounds like if you are looking for an exact replacement for XIV it is to short VXX, but even still it probably won't be exactly 1 for 1 on performance/drawdown.

Can anyone modify the order function it's confusing trying to make it short VXX and see what the performance is.

This would take some time, because some of the basic logic sprinkled throughout the algo is that VXX is for a bad market and the inverse is for a good market. However, I think you might be able to easily get an idea of how it would look if you went long VXX in a bad market and short VIXY in a good market - then the underlying logic can stay intact.

You have to change this:

context.sidsShortVol = {
sid(40513): +1.0

to this:

context.sidsShortVol = {  
    sid(40669): -1.0

and change any other instance of sid(40513) to sid(40669) in the algo. Then of course you would have to change the start date to after the 1/3/11 inception date of VIXY. You would probably also want to increase the value for context.stop_lim_vol some because VIXY will be more volatile than ZIV.

I think that is about it, but I haven't finished running a new backtest yet, so it is possible there is a little more to it...

The previous post resulted in a disappointing backtest, so more time will have to be spent figuring out what it is doing wrong...

@Joseph

Yeah I tried that yesterday before posting, seemed it wasn't working correctly, there is a lot of logic with rebalancing orders also.

can someone explain if drawdowns are being calculated correctly? When you look at the chart of high to low peak to valley it's way more than what the Drawdown numbers shows, for example it shows max drawdown of 25%, meanwhile peak to valley shows like 40%.

Is it the way this algorithm is calculating it? Or is the peak, unrealized gains?