I've tried combining momentum indicators along with the vix/vix3m and vix/vix9d ratios as a mesure of contango/backwardation (I've tried the futures term structure ratios but Quantconnect's futures system makes me want to pull my hair out). I use indicators on SPY since I belive it's the "underlying" and more represtative of the underlying market that ultimately affects VIX values, and technical analysis on a actual ETF makes more sense to me.
I used the SPY crossing sma as an exit signal for short volatility, and SPY macd as an exit signal for long volatility. I find that macd tends to "want" to switch every once in a while even when growth is sustained (but not gaining momentum) and provides too many false positives as an exit signal for short vol since the majority of the time the market trends upwards gradually, so I used sma as a kind of trailing exit. However for long vol I find that once the party is over you want to get out quickly before the spike crashes, so I attempt to use SPY macd as measure of momentum and an exit to get out and minimze losses.
Additionally, usually when exiting a long vol position, much of the time the market is recovering even if temporarily, however due to the lingering backwardation this recovery is not always reflected in a short vol ETP such as SVXY, so I take advantage of this period by staying in TQQQ.
If anyone sees something I missed or could improve, or has thoughts to add it would be much appreciated. (I've also gotten rid of the last 2-3 months cause the coronavirus crash makes any vol strat look amazing, including it returns are 58000%, without it 8000%)
Grant Forman
Derek Melchin
Hi Sunny,
Interesting strategy. Although, I noticed that the `vixRatio` threshold is not very robust. Adjusting the threshold by as little as 1% causes the strategy's returns to drop by >35%. The strategy may be over-fit.
Additionally, the entry conditions are quite extensive. For example,
shortEntry = (vixRatio < 0.94) and not vixCrossUp and not (self.Securities["SPY"].Open <= self.spySma.Current.Value and self.yspy > self.yspySma)
In general, the simpler the strategy, the less likely it is to be over-fit to the historical data.
In regards to drawdown, the strategy experiences quite a large one at 61.5%. I would recommend to try adding a Risk Management module to the algorithm to reduce it. For instance, the Maximum Drawdown Risk Management Module may be a good option. In fact, the entire algorithm could be converted in to one that follows the Algorithm Framework outlined in our documentation. This will separate the algorithm's logic into several isolated classes.
On a final note, I noticed there are several lines of imports at the top of the algorithm. We can remove all the ones above datetime, except `my_custom_data`. Doing so will force the algorithm to automatically import the C# files it needs, resulting in faster execution.
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Steven Sucheck
I was just playing around I am sure this is not possible, changed .open to .close. .
Steven Sucheck
Can either of you explain the date handling of the Vix data? I plotted the vix values by date in Sunnys project. I could add +1 to the day of week in the custom data code and then the vix values correspond to the to the days of the week in the excell file on the website. But I don't think the vix data is published in the excel file until the the end of a trading day. So I was thinking the best you could use is yesterdays close from that data source. Does the main algorith care about the date of the vix data?, do you have to tell it to used yesterdays close, or is it just using the last data availble to plan its execution?
Josh M
I also believe that the algo is reading future datapoints; to confirm I have begun 'live trading' on a paper account. I'll report back in a few weeks.
Best,
Josh
Steven Sucheck
This seem to correct the plotted dates. Should rolling windows be used to pull yesterdays close or open data. Still trying to figure it out.
data = line.split(',')
index.Time = datetime.strptime(data[0], '%m/%d/%Y') + timedelta(hours=12)
Shay Hazan
Hi,
I tested your algorithm on 1/1/2017 - 1/1/2019 period and it seems like there is a problem with splits, i.e. there are huge gaps in the PnL graph when there was a split in SVXY.
During 2017-19 there were two splits: 17-Jul-2017 and 18-Sep-2018, and you can see the gaps (down and up) exactly during these times.
How such splits can be handled? is your backtest also experience it?
Thanks,
Jared Broad
Thanks Shay. Splits and dividends are automatically handled in LEAN but it looks like this split-dividend data got corrupted. Please use the data issues reporting system to ensure it gets fixed.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Shile Wen
Hi Shay,
This error isn’t caused by the contents of an algorithm. If this error occurs, try rerunning the algorithm. We are currently working on fixing it, and we believe it may be caused by a faulty node in our server, as we are preparing to launch new infrastructure.
Best,
Shile Wen
Charly
Hi Sunny,
I was excited to find this Algo because I wanted something with volatility. Sadly as most of the time if something seems too good it usually is. This algo ist indeed as suspected by Josh trading on data that is in the future. But I wanted to see if your idea for alpha was actually valid so I incorporated the quantopian sources for your data via Quandl and Cboe. Sadly the resulting Algorithm isn't anywhere close to your results and without risk management it is extremely unstable. But at least I learned how to use Quandl and Cboe.
Cheers Charly
Josh M
Nice revision Charly!
Derek Melchin
Hi everyone,
As pointed out above, the original algorithm in this thread uses future data points. This is because when importing a custom data source, the time we assign to the Time property is precisely when the data point is made available to the algorithm. For instance, if the timestamp in the imported file is 2014/10/1, the data point will be pumped into the algorithm at the beginning of 2014/10/1. To avoid lookahead-bias, we need to add a day to the date recorded in the CSV files used here.
See the attached backtest and logs for reference.
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Mark Reeve
Isn't there an easier way to get VIX and VIX3M data into QC?
Derek Melchin
Hi Mark,
Yes, we now have these in our built-in CBOE data source. See the attached backtest for reference.
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Sunny Nagam
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!