Hi everyone, I am fairly new to Quantconnect. I am trying to backtest this exact strategy for my thesis.
https://www.quantconnect.com/tutorials/strategy-library/exploiting-term-structure-of-vix-futuresFor some reason when I clone the algo the backtest does not run. I suppose it is due to the data coming from a persona quandl.
Can anybody give me a hint on how to fix the path to make it run?
Derek Melchin
Hi Niccolò,
Welcome to QC!
To resolve the issue, we need to update how we're accessing the futures chain. First, we need to gather the canonical symbols of each index.
self.canonical_symbol_by_index = {} for index in [Futures.Indices.VIX, Futures.Indices.SP500EMini]: future = self.AddFuture(index) future.SetFilter(timedelta(0), timedelta(days=180)) self.canonical_symbol_by_index[index] = future.Symbol
Then, we need to replace
if chain.Key.Value == Futures.Indices.VIX: ... if chain.Key.Value == Futures.Indices.SP500EMini: ...
with
if chain.Key == self.canonical_symbol_by_index[Futures.Indices.VIX]: ... if chain.Key == self.canonical_symbol_by_index[Futures.Indices.SP500EMini]: ...
In addition to the changes above, we should increase the cash buffer to avoid margin calls.
self.Settings.FreePortfolioValuePercentage = 0.5
See the attached backtest for reference. Continuing the development of this algorithm, consider replacing the Quandl VIX data with our built-in VIX index data.
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.
James
Niccolò
I have done allot of research on this strategy (outside of QC), I have been running it live since early 2020. I would be happy to discuss the strategy with you if you need someone to bounce ideas off of. Not sure if we allowed to share email addresses here but feel free to contact me at VIX6108 at g mail
BUT Im an expert {self proclaimed :)} on the strategy but not using QC. As I too am having a very hard time migrating the strategy over from another platform.
James
Im been trying to learn QC especially trying to figure out when futures are executed (dates, times and prices), but based on this strategy...a few questions if anyone can help
1. I assume the futures data is Daily data, NOT minute?
2. I assume ALL the futures data comes from Quandl, which provides only OHLC and Settle (by the day not the minute)? (so all trades should execute at one of these numbers only??
3. if 1 and 2 are correct why are the trades executed at random times? eg 19:01 and 20:01 and in many cases not at any of the prices quoted from Quandl.
to confuse me more....one trade was filled at 13:01 on a Sat afternoon! Â
Derek Melchin
Hi James,
#1 Our futures data is available in tick, second, and minute resolutions. The futures data from Quandl is in daily resolution.
#2 Correct
#3 Trades can fill at times other than midnight because we also subscribe the algorithm to our built-in futures data for VIX and SP500EMini. These securities have minute resolution by default.
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.
James
So #2 is Incorrect? Data does Not come just from quandl
The ultimate question (and just before I give up any faith in trying to understand)  how can a trade occur at 13:30 on a sat? (ie vix futures)Â
Derek Melchin
Hi James,
In the algorithm above, we subscribe to data from Quandl and from our built-in futures data. We can see this in the following lines:
self.vix = self.AddData(QuandlVix, "CBOE/VIX", Resolution.Daily).Symbol self.vx1 = self.AddData(QuandlFutures, "CHRIS/CBOE_VX1", Resolution.Daily).Symbol self.es1 = self.AddData(QuandlFutures, "CHRIS/CME_ES1", Resolution.Daily).Symbol # ... for index in [Futures.Indices.VIX, Futures.Indices.SP500EMini]: future = self.AddFuture(index)
The attached backtest logs shows that no trades executed at 13:30 on a Saturday. There are a few trades placed on Sunday evening, but this is because the futures market opens on Sunday.
There are times when the algorithm above places trades in `self.front_VX` or `self.front_ES` when there no data available for those securities at the current time in the backtest. To remedy this, we should check if they have data before trying to trade them.
has_data = False if self.front_VX and self.front_ES: has_data = data.ContainsKey(self.front_ES.Symbol) and \ data[self.front_ES.Symbol] is not None and \ data.ContainsKey(self.front_VX.Symbol) and \ data[self.front_VX.Symbol] is not None
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.
Niccolò Melacarne
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!