Hello,
Suppose I want to make an alpha model that looks at the term structure of some futures and gives an insight based on this, for example, I want to see if the VIX futures are in backwardation or not so
# in Initialize method
self.vx1 = self.AddFuture(Futures.Indices.VIX,
dataNormalizationMode=DataNormalizationMode.BackwardsRatio,
dataMappingMode=DataMappingMode.OpenInterest,
contractDepthOffset=0)
self.vx2 = self.AddFuture(Futures.Indices.VIX,
dataNormalizationMode=DataNormalizationMode.BackwardsRatio,
dataMappingMode=DataMappingMode.OpenInterest,
contractDepthOffset=1)
Then in my alpha object, how do I access vx1 and vx2 to check if vx1>vx2 for instance?
I have the feeling that it is currently impossible because the only symbol I have access to in the Update and OnSecuritiesChanged is /VX.
Thanks in advance for the help!
Pablo
Ho and I know I could use VIX Central Contango data for the exact example, but I want to know for futures in general.
Derek Melchin
Hi Pablo,
To get the continuous contract Symbol into the Alpha model, either pass the Symbol to the Alpha model constructor or get it from the OnSecuritiesChanged method. To determine if the Symbol added to the universe in the OnSecuritiesChanged method is the continuous contract Symbol, use the IsCanonical method .
See the attached backtest for a full example.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
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.
Pablo
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!