Hi all
I am trying to set the contractDepthOffset=1 but I still get the same data for both =0 and =1. i.e. the method isn't responding to the change
qb.AddFuture(Futures.Indices.VIX, Resolution.Daily, contractDepthOffset=0, fillForward=True).Symbol
qb.AddFuture(Futures.Indices.VIX, Resolution.Daily, contractDepthOffset=1, fillForward=True).Symbol
Mia Alissi
The
contractDepthOffset
argument defines which contract to use. 0 is the front month contract, 1 is the following back month contract, and so on source.However, by default, LEAN doesn't add any contracts to the FuturesChain it passes to the
OnData
method. To add a universe of Future contracts, in theInitialize
method, call theSetFilter
method of theFuture
object source.Here is an example of how to use
SetFilter
:If you don't call the
SetFilter
method, theGetFutureHistory
method won't return historical data source.If you are still facing issues, it might be due to the way you are accessing the data. The History method returns a multi-index DataFrame where the first index is the
Symbol
. The data is then sorted in rows according to the second index, the EndTime of the bar source.If you are still facing issues, you might want to try using the
GetFutureContractList
andAddFutureContract
methods as a workaround source. Here is an example:Please ensure that you are correctly accessing the data for each contract. If the issue persists, it might be a bug and you should report it on the QuantConnect forum or GitHub page.
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.
Faisal Hasham
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!