Back to Community
The SPY who loved WVF (or Just another Volatility SPY strategy)

Yes I cannot help myself: we must be able to conquer this beast called Vola

Economic thesis, loosely defined:
1) there is information in the synthetic VIX versus the real VIX or VXX,
2) the Volatility of the VXX says something about the underlying and therefore the real market (Kory)
3) by assigning a low amount of capital to a high volatility strategy you prevent being taken to the cleaners but profit from upside (Alvarez)

Thanks to Kory and Cezar Alvarez, I present a strategy that one could trade, but looking at the tear sheet and the equity curve I suspect that this strategy is its current form and the current market does not perform.

For equity curve jockeys: none of the parameters are optimised, the use of cash is not optimised
For Contest Jockeys: easy to isolate the Alpha with hedging, I can't be bothered with the contests

Further dev:
Alvarez has some more "anti-cleaners" strategies that I didn't implement, one could test them out
Pull in VIX and see whether the VIX and WVF can play nicely

Disclaimer:
I'm not trading this strategy, needs more time and trading guards and I would wait to see whether the strategy is going back to older levels of volatility as the DD in the last 2 years is double from the years before.

Clone Algorithm
345
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: 57fa07ae61aee0105968a16e
There was a runtime error.
44 responses

Hi Peter,
Just have to say your previous volatillity algo was so precious for me! I have implemented it in IB and it was great!
Why you think this isn't compatible for LIVE? The rationale I see here is very similar to JAVOLS..

you could trade it, I haven't put enough time in it to say it's robust. I thought I release it to the community and see how others can improve it. The things that I see in the tear sheet looks like the behavior as changed from 2014 to 2016. There is a big difference in returns and beta and that worries me a bit. With a few more guard rails and cash usage it could be traded, but be careful...

Peter, i borrowed your codes and put this together. I got this. It is looking good. So wanted to give it a run in IB. I so new to Python and Q so hope you dont mind .

Clone Algorithm
120
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: 5806415821d2301059e514f0
There was a runtime error.

Here the TearSheat for it.

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

The equity curve of the modified algo looks really nice. What are the main logic differences between the modified and original algos?

looks good indeed, I'll play with it and see how I can break it ;)

Peter, from my observation as the same as the note you put on top of MVP algo. As the algo MVP, Return is a function of look back period (1-20 ) and eps_factor. i was able to do an optimize these parameters( every 2 month period) in AmiBroker and it delivers good result. Im not sure how can i do it in Python(since im so new as this). Also here is the version that aggressive tilt and using your Vol ago to control the portion of xiv and increase or decrease portion of spy and edv..

Clone Algorithm
141
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: 5808d095ea03a3136cb572f4
There was a runtime error.

Wow, this is awesome. Thank you Peter for starting this thread.

Cesar and I actually live near each other and I recently presented my volatility trading strategies at a Northwest Traders & Technical Analysts meeting (Cesar attended as well). I've shared my volatility strategies with Cesar and we're both working on improving them. Here's our Meetup group if anyone in the Seattle area is interested in joining: http://www.meetup.com/Northwest-Traders-and-Technical-Analysts-NWTTA/

Please message or email me in private if you would like to collaborate with me on coding volatility strategies. I'm a TradeStation user and all my stuff are coded in TradeStation's EasyLanguage. I would love to have them ported over to Python for Quantopian.

Currently I have 5 different strategies that strictly trade VXX and XIV:
- Three of them are long XIV only (50-80% CAGR and 15-35% Max DD)
- One is short VXX only, similar to the ones presented here but has more variables (60% CAGR and 15% Max DD; http://imgur.com/a/w4blx)
- One is long VXX only (15% CAGR and 10% Max DD)

I have everything coded in EasyLanguage so it would be pretty easy for a programmer to port everything over. Unfortunately I'm not a programmer.

Email: [email protected]

Only issue is that the last ago does have some leverage. Any way to ensure there is no negative cash - for Robinhood trading?

A small remark , if you want to trade the last ago live, this line should be changed :

:135: FutureWarning: pd.rolling_max is deprecated for Series
and will be removed in a future version, replace with
Series.rolling(window=28,center=False).max()

not plug and play - you need to define the series.

Is there any way to get help with these changes? Like examples?

For anyone considering live trading NHAT NGUYEN's algo, keep in mind that it's highly dependent on day of the week, this is a form of overfitting and there's no guarantee that it's performance in the future will be as good.

@ Luke, you are right "there's no guarantee that it's performance in the future will be as good". Im using the idea from Grant's algo (which is MVP ) and do a conversion to lite C (Zorro platform ) where i can do optimization and walk forward analysis, Amibroker gave almost the same volatility but about 2% less returns. These are best parameters which deliver the highest return. i did 10 WFA cycles so i think it is stable parameters for next couple of years, algo will perform closely but past is not the future where it is a unknown . For live trading, we may need some nice Python expert in the forum to double iron some bugs in order management, keep track trades, and money management part. Or lower the allocation and watch it like a hawk for couple of months.

Just a word of caution: the algos in this thread so far all use a fixed value for the WVF trigger. That might potentially be dangerous in the future. I don't use a fixed trigger in my VXX/XIV algo but I use a variable trigger that's an EMA of the WVF.

Kory, that's a great idea. If you don't mind, could you share a code-snippet showing how you get the EMA of the WVF? If I tried I think could get a value but it wouldn't be a true historical EMA, only an EMA of the WVF as far as it shows up in my algo using .append(WVF). This wouldn't work well for live trading until after some time had passed

Here is the correction of the depretiation warning line #135
:135: FutureWarning: pd.rolling_max is deprecated for Series and will be removed in a future version, replace with
Series.rolling(window=28,center=False).max()

Clone Algorithm
154
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: 580e165cf904011041cc613f
There was a runtime error.

I would like to say it seems no body has done a back testing which covers the time period 2008 where there was big crash bcz. Lehmann. If you do a back testing covers this period, you will find the return is quite different.

Some of the ETFs used in this algo have no data before 2011. This could be the reason why no back testing did which covers the year of 2008.

very insightful Mr Chang

Given "Some of the ETFs used in this algo have no data before 2011", therefore, "no body was able to do a back testing which covers the time period 2008".
This is already True statement. What are you saying ? ......

Maybe - put another way - the concern is that the specifics of this strategy dictate that the backtesting and subsequent walk-forward analysis have only been done in the relatively known and predictable post-2011 market conditions. That certainly is a concern I would have prior to launching a long-term based strategy - how would it have performed during a major market turndown when correlations change dramatically between the ETFs it uses?

My thought? If you need absolute certainty, the stock market isn't a good place to play.

My first objective was reduce the volatility of over all portfollio when i combined these 2 strategies and it accomplished.
Second objective, was optimized and get the backtest results so i can have a relative reference point of results so i can work with when moving forwad ( that was the stage that i publish the backtest).
Third objective, given objective 1 and 2 met and return slightly above benchmark, can i add another strategy to reduce further beta, increase alpha and reduce volatility ( This is the current state that im in )
Fourth objective, if 1,2,3 met, moving to asset allocation models selection and various optimization techniques (parameters, time reference point etc) for over all portfolio and all the strategies combined.

That is usually, my route of designing a new portfolio.

My questions to you is ? Why do you want to put your money at risk when you are clearly not putting enough time to understand how things work.
"This game is long, hard and scary. Risk + Uncertainty = Probability (pulling your hairs off + lack of sleep )= 95%

@Eric:

A absolute certainty can't you never get. Maybe the god could give you . :-)

But what's the sense you do back testing?

@Nguyen,

You wrote a lot here. Why not simply back test your algo in bear phase? For example include the year 2008 and 2009?

In 2008 there was a big crash bcz. Lehmann. After that, exactly to say since 2011 the market goes up continuously. It's a bull market. Why not back test your algo in a bear market?

@Thomas

Everyone trades differently. Different strategies. Different time frames. I'm a very (very) short term trader, so if it works this year, it's good enough for me to use. I don't hold any positions overnight.

I'm aware that because of this my opinion in the matter is moot to most if not all of you guys in the forum because you trade much longer time frames. But since I was hanging around I just threw my hat into the ring.

Also, asking why no one backtests this prior to 2011 almost seems like a rhetorical question, as some of the components didn't exist before then. This too, is moot.

This is Peter's thread so i dont want to post something which doesnt add any value here. And this is will be my last post here.

For Mr, Chang.
First, These are not mine algos, i saw some great things in Grant and Peter' algo so i try to build a something out of it to see how much volatility it can reduce.
Second. I think your logic does have serious problems. Lets me point it out for you.
2 of your posts are have the same question ? and both your questions are already answered by your self.
You said " Some of the ETFs used in this algo have no data before 2011".This is True statement because " XIV and TMF " intercepted date is 2009 and 2011, and this is your Conclusion: "no body was able to do a back testing which covers the time period 2008".
So your declaring statemnt is TRUE .< =>your conclusion is also TRUE. ( You see Mr Chang, your opening statement and your conclusion can go both ways (backward and forward).
Is it right Mr Cheng ? Can you see it. ?
Good luck

Could someone explain to me the basis of the algo, i am new to quant and would like to understand what the parameters are and the rationale behind this algo.

Sorry for being a NOOB

Here is my understanding of this strategy:
Function “Allocate” - The strategy allocates between 5 stocks SSO (2x S&P), TMF (3x 20-year treasury), IJR (small caps), IJH (mid cap) and XIV (inverse volatility) based on highest momentum for the last 6,630 minutes. Not sure why this number used?
Function “allocVol: Closes XIV position if WVF index (based on VXX) crosses below 14. But does nothing if the WVF under 14.
Function “allocSPY”: Opens SSO position if WVF spy uptrending and closes SSO position and opens EDV (long term treasuries) position if SPY in downtrend.

Also, if someone considers trading this strategy , i would consider replacing EDV with some Short S&P ETF (e.g. SDS) and TMF with TLT (due to lower spread and higher liquidity). Because the algo over-allocates to the treasuries, and the reliance on treasuries as safe haven asset that might be wrong during the tightening economic cycle

Here is the version that uses Short S&P ETF (e.g. SDS) instead of EDV and TLT instead of TMF. It should be a safer bet in case of the bonds bear market

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: 581bef6d6ffc9b0f2472057f
There was a runtime error.

Maxim, that is a good idea. I can wait to play with this idea. im working on my v3 of this algo and trying to put pieces together in C. It is quite interesting and it looks promising by showing low draw-down with high Sharp. Here the idea for you to play, get 1 more strategy that playing stock market like Value investing or momentum that re-balance monthly, then allocate about 40%, Keep the MV algo, which is driving the rest of allocation and also driving the whole portfolio when stock market in trouble.
if market in trouble, put all the allocation of the stock strategy to 1 of safe haven assets and lets the MV algo allocate it weekly until the stock market is trade able again.
My idea is having a diversify portfolio of strategies (between 2 and 4) with continuous allocation between assets. Safer and better returns.
Have fun and good luck.

Very good improvement indeed, let me play with it further as well!

PB

Hi Maxim,

It's realy well done!

But a question: After I run the back testing I found in "Transaction Details" that it happens very often that an ETF is bought but several hours later (at the same day) it is sold again. Is this what you want?

Cheers

Thank you guys, I am really glad that I could make a little contribution to this thread.
@Nguyen. Thank you for your suggestion on how to combine the strategies and use the MVP algo to drive the allocations between them. I will be investigating it…
@Thomas, you are right that the algo can open and close the positions in the same ETFs during the day.
It happens, because there are 2 different processes (functions) used to place the orders for SPY (SSO and SDS) and XIV :
1. @ 10.30 AM - “allocate” function (based on scipy.optimize.minimize function) allocates capital to SSO and XIV positions
2. @15.45 - “allocVol” function closes VIX position if it WVF crosses 14 (based on VXX)
3. @15.45 - “allocSpy” function opens/closes SSO or SDS based on WVF (based on SPY)
In my view, this is a weakness because it leads to overtrading and confusing signals. The possible improvements are: combining the 2 signals (WVF and regression/optimization) or using only one of two signals for signal generation.

Would this algo still be valid if i were to set long_only as my trading settings?

@ Seungmin. Should work for long only, it doesn't short anything but using Short ETF instead.

My contribution:
Change the TMF to the TLT only and get even better!!!

Returns
494.2%
Alpha
0.28
Beta
0.31
Sharpe
2.00
Drawdown
-10.8%

@Michele: Your contribution to Peter's original code or to Maxim's? I found both of them haven't used TMF but TLT. Or maybe you want to write "change the TLT to TMF"? :-)

Cheers

I may apologize for my poor english..
I mean, instead to change both etf EDV and TMF, change TMF with TLT only in the last Maxim's algo and you get sharpe=2.

The issue still remains that there is a fixed value for the WVF trigger - using the best # historically from 2011 forward. Seems like overfitting as this number can change walking forward.

I could change, but remember volatility is not a stock price or so, if the volatility structure changes permanently, othe very base assumptions in the amrket must have changed as well. There could be periods where we have elevated or depressed volatility, but a high vix/wvf value to revert from is pretty safe in my mind. I haven't found a adaptive measure that improves the algo.

First thanks to Peter & Nguyen and everyone else for sharing your ideas. I loved the performance & have spent some time experimenting. Here's my experimentation observations:

  • In a similar to 2008 scenario, the algo will probably lose money, you just have to stay alert. I tried to simulate this by trading a portfolio that didn't include XIV, and had TLT instead of TMF (poor man's simulation) and that portfolio was losing big in 2008. Nevertheless, I think omitting XIV for that period would not materially impact the simulation validity. Next, I built a bullish market filter that only invested when SPY was above of either 100 or 200 day SMA. It protected against the 2008 market but it was impacting the total performance. Even when I was running the full (with XIV & TMF ETFs) version past 2011, the overall performance was being impacted and the 2016 YTD perf was terrible. So, I decided against it & removed the SPY bullish filter.
  • The allocSPY function in some algo versions uses EDV and some versions uses SDS. In my experimentations it appeared that using EDV in momentum markets performs better and using SH in sideways markets performs better. Currently, I am using a linear regression filter to decide when the market is in momentum or is choppy. Momentum means that the R square of a linear regression of 126 days of SPY is above 70%. 70% is a result of instinct and very limited experimentation.
  • I chose SH instead of SDS for the allocSPY because it appears that the algo is in SDS for long periods & SDS has terrible decay. It appears that it is less offen in SSO, so I didn't spend any time with that.
  • I am allocating only 20% to the allocSPY scheme leaving 10% in cash. In backtesting, the code seems to be going into leverage above 1.0 resulting from partial executions. It would perform better with the original 30% allocation, but as a first step I want to make sure I don't go into margin and this seemed the easiest way programmatically to do it. I also moved the spyAlloc 15 minutes earlier to have more time for execution.
  • I added a filter for the daily allocSPY rebalance to only execute trades when they exceed a threshold. In the included test, it is set to $500. This removes a lot of small 1s and 2 shares rebalance transactions for a small capital test.

I would be very interested if anyone has any analysis on how events like Brexit, US elections, FED meetings impact the performance of the algo.

Cheers

Clone Algorithm
99
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: 58310297ddb07b6407d1a3f6
There was a runtime error.

Anybody trading this live? I added it to Robinhood, and seems something is wrong, yesterday it sent an order for TLT only and not TMF and XIV.

I'm trading a variant of this live in IB. As there are so many versions here, which version did you put live?

Using Maxims Version, actually I think it is behaving fine, it matched the order, I just thought it was going to sync the current positions, but it just waits for the orders to add up. Also, for 2008 if there isn't a bond market collapse/stock collapse at the same exact time, wouldn't this perform well as it would jump into Bonds?

@Takis
Did you try lowering the MA period say 20, 50?