Hi community!
Exited to share that we have shipped continuous futures into production. We have implemented 3 contract rolling methods, 4 price scaling adjustments as well as adding support for back months.
From now on, the canonical future returned by the AddFuture calls, is the new continuous future. Through this same AddFuture API you can specify which mapping, price scaling and front or back month configuration you want to use. The new continuous future security is setup as tradable and will never expire since it will map underlying future contracts accordingly, these mapping events will be fed into the algorithm (as Equities) through the SymbolChan≥dEvent.
Note that previously by default the addition of the canonical future to the algorithm, would feed data of the future chain contracts who's expiration were in the 0 to 35 day window. We have disabled this behavior making the continuous future the default data feed. Previous behavior can be recovered by specifying the expiration filter future.SetFi<er(timeδ(0),timeδ(35))/future.SetFi<er(TimeSpan.Zero,TimeSpan.FromDays(35));.
Price Scalling
- ForwardPanamaCanal: Eliminates price jumps between two consecutive contracts, adding a factor based on the difference of their prices. First contract is the true one, factor 0
- BackwardsPanamaCanal: Eliminates price jumps between two consecutive contracts, adding a factor based on the difference of their prices. Last contract is the true one, factor 0
- BackwardsRatio: Eliminates price jumps between two consecutive contracts, multiplying the prices by their ratio. Last contract is the true one, factor 1.
- Raw: No price adjustment is made.
Contract Mapping
- LastTradingDay: The contract maps on the previous day of expiration of the front month.
- FirstDayMonth: The contract maps on the first date of the delivery month of the front month. If the contract expires prior to this date, then it rolls on the contract's last trading date instead.
- OpenInterest: The contract maps when the back month contract has a higher traded volume that the current front month.
Front and Back Months
From the AddFuture API contractDepthOffset will allow specifying which contract to use, 0 (default) is the front month, 1 the following back month and so on. Initially we have added support for the first 2 back months contracts.
At the same time Lean internals mapping and scaling refactor has moved us closer to easily supporting other markets that would require these features, like Indian or European markets.
As always please let us know if you have any issues or concerns, and we will look into them ASAP.
Enjoy!
Spacetime
Awesome! Can not wait to use it! Thank You!!
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.
Spacetime
hello, can someone please provide a simple sma crossover example using continuous contracts.
Can I just pass the continuous contract as shown below in onData()?
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.
.ekz. INVESTOR
What a great update Martin Molinero! Fantastic work, team.
I'm new to futures. Can anyone share tips on what to choose for price scaling, contract mapping and month selection?
Would love any resources articles / tutorials / videos / etc.
Thanks in advance.
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.
Martin Molinero
Hey!
Just sharing a continuous future backtest using some SMAs.
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.
Spacetime
oh i see ! got it ! thanks!! I was confused at first and now I know.
cheers!
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.
Johnny Cash
Can you provide an example of the same backrest using SCF data?
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.
Johnny Cash
I ll try again..
There is a code on git-hub, which I mentioned in my first post, using SCF continuous future data. When I back-test it, it gives no trade, while it should , since it is a simple buy and hold strategy. I think Martin is the last editor of that code, so I post the question here, also because I would like to compare the results of different test, or in research just the time series.Testing data is of fundamental importance in any back-testing, especially when using continuous future.
Some kind of reply would be appreciated. I have tested other continuous future data in the past, and found it very important to do it before doing any trading, For example SCF and Tradestation can differ substantially in some cases. I can do some comparison outside quantconnect , but first I would like to have a definitive answer about SCF data use on quantconnect,. In the past I noticed SCF data format changed but quantconnect did not update the import methods, and my post regarding it was removed, and I need to know if anything has changed since then.
Thanks
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.
.ekz. INVESTOR
Wish I could help. Perhaps try asking in the slack or discord.
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.
Martin Molinero
Hey Johnny Cash !
There is an issue reported for this, Quandl was bought by Nasdaq and their API changed and broke the Lean custom data definition. We will try to address this ASAP, you can subscribe for notifications on the issue.
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.
Jared Broad
Hi Johnny Cash
Our continuous futures support is different from the SCF Quandl Dataset. We have generated our own continuous futures mappings and compared them to third-party sources and are able to make that available for free, built into the QuantConnect Cloud. For discussion about SCF and Quandl please spin up a new thread and we can try and help there.
Best
Jared
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.
Laurent Crouzet
Hey Martin Molinero
Thanks for having added Continuous Futures: that is a very useful way to avoid spending too much time managing the individual contracts.
However, when trying to use the Continuous futures in a Notebook, nothing is returned (it seems to be also the case for individual futures, while it worked before).
Could you let us know how we can ask for a history of prices for Continous Futures data from now on?
For instance, the following example only show an empty Dataframe in a Notebook (for “continuousContract.Symbol” and “continuousContract.Symbol.ID.Symbol”):
qb_future = QuantBook()
continuousContract = qb_future.AddFuture(Futures.Indices.SP500EMini, dataNormalizationMode = DataNormalizationMode.BackwardsRatio, dataMappingMode = DataMappingMode.OpenInterest, contractDepthOffset = 0)
history = qb_future.History([continuousContract.Symbol], 50, Resolution.Daily)
print(history)
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.
Laurent Crouzet
Actually, I also tried to use the qb_future.GetFutureHistory (which used to work in Notebooks before the Continuous Futures implementation), but using the standard method described in the docs…
the DataFrames keep being empty (using either continuousContract.Symbol.ID.Symbol or continuousContract.Symbol):
start_time = datetime(2021, 11, 1, 9, 30)
end_time = datetime(2021, 11, 23, 16, 0)
future_history = qb_future.GetFutureHistory(continuousContract.Symbol.ID.Symbol, start_time, end_time)
historyall = future_history.GetAllData()
print(historyall)
Do I miss something obvious? Or the Continuous Futures did break the previous way to request historical data in a Notebook?
Happy Thanksgiving to you and to the whole QC Community!
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.
Jared Broad
I set the date to make it work. I've made a Github issue to make it set default dates (or throw with an error message) when not provided.
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.
Laurent Crouzet
Thanks Jared Broad!
I am now able to confirm that:
The Github you opened (Not returning silently an empty array in research Notebooks) would be very worthwhile!
Yesterday, while trying to find a way to correctly ask for data using futures, I changed the resolution to Daily (to reduce the quantity of data - so I thought!), and I should have been more careful: that was probably the issue for the History call, in addition to the lack of “SetStartDate”, as the Daily data are not available for futures!
Similar to the Github you just made, I also think that returning an error message if no data can be available in the research Notebook (Hour / Daily resolution are still not available for any future) would help avoiding such a stupid error!
At last, I tried to use the previously advised way of handling history calls (the solution I used until last week, which used to work for each individual future), as explained in the docs here:
"Making History CallsSimilar to options, future historical data can't be accessed using qb.History. Instead, we need to use qb.GetFutureHistory, which lets us access historical futures data."
Good news is that thanks to your great work to provide Continuous Futures, the standard (and simpler) History calls works for futures from now on (so the Docs can be amended).
However, I cannot manage to make it work in the previous way, using GetFutureHistory and GetAllData.
Even by providing a SetStartDate
Maybe because we cannot add a 4th argument for GetFutureHistory to ask for a precise resolution in the history call, while it was Resolution.Minute by default previously?
This code used to work (showing data for the different futures, order by their expiration dates) until last week, and adding qb_future.SetStartDate(2021, 11, 1) do not help:
qb_future = QuantBook()
es = qb_future.AddFuture(Futures.Indices.SP500EMini, Resolution.Minute)
start_time = datetime(2021, 11, 1, 9, 30)
end_time = datetime(2021, 11, 9, 16, 0)
future_history = qb_future.GetFutureHistory(es.Symbol, start_time, end_time)
historyall = future_history.GetAllData()
historyall
Maybe the GetFutureHistory() will be deprecated in the future?
If yes, will there be a way to still use individual future contracts in the research Notebook, as before?
Nothing urgent here, I will use the Continuous Futures instead for my current research, using my new more powerful R2-8 node!
Happy Thanksgiving again!
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.
Jared Broad
Hi All!
We tweaked the implementation this evening to let you reference the underlying contracts to trade them in live trading – #first-in-the-world.
When you add the contract you're given the reference to the continuous-contract-security, which has unrealistic prices in many of the adjustment methods. You can't trade this - but the underlying contract is available with a new Mapped property;
This way you can develop identical algorithms for backtesting and live trading without tweaking the code much or at all.
Please note some continuous contracts will have discontinuities in live trading! This is due to how the contracts are mapped and not something we have control over. If you're using them for technical indicators you should ideally
- Bind to the symbol changed event
- Reset your indicators
- Re-seed your indicators from a history call.
The history calls should be smooth.
Happy Trading!
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.
Ariel Nechemia
Hi Jared!
Thanks for the great work and the resources! Is there any way you could give us an example of what the code could look like resetting the indicators given the change in contract? I've found this template but I'm struggling to implement it with my code for continuous futures. It would be great to see an example, perhaps using the crossovers example posted in the github above.
Cheers!
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.
Johnny Cash
Hi,
Great work!
Can you please post a link to the github source code of the continuous future calculation implementation? I tried to look at it here , but i cannot see where is splicing performed.
Thanks
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.
Varad Kabade
Hi Johnny Cash,
We recommend going through the different files changed after integrating this issue to find what you are looking for. Refer to the following link.
Best,
Varad Kabade
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.
Johnny Cash
Hi,
I have created a simple notebook to check carefully the attributes of a Future object:
to my surprise the margin model does not have any margins set up. The only other attribute which seem to be relevant is the Leverage, which is set to 1 (strange..it should be much higher for futures), and at least in the notebook, I cannot modify it. I have also checked how contract multipliers are handled, and they are ok. One way to backtest future would be to use some indicative leverage (10 or 20 lets say) and ignore the contract specific margins. In any case the contract specific margins seem not to be available, and leverage cannot be changed from 1.
Are future strategies being properly margined? If yes, where is the margin data?
I have also checked several strategy library future algorithms using custom data and they do not set up the contractMultiplier attribute, so I doubt the results are correct. At least the native future QC data has the multiplier correctly set up.
PS
How can notebooks be share directly instead of copying the code as done above? Below I can only see the back-test sharing option.
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.
Martin Molinero
Hi all!
Big Chai
-What would be the rolling method when the current contract which we have bought expires? Does buying the _currentContact roll the futures automatically as they expire?
The positions are currently not being rolled automatically, you will have to handle this manually. Please take a look at this basic template algorithm it's rolling the position.
Ariel Nechemia
-Is there any way you could give us an example of what the code could look like resetting the indicators given the change in contract?
Please take a look at this basic template algorithm it's rolling the position, resetting the indicators should be done in a similar pattern
Johnny Cash
-Can you please post a link to the github source code of the continuous future calculation implementation?
The implementation that creates the mappings and factors is closed source at the moment sorry, the implementation that applies the factors and mappings is part of Lean itself, can see this with more detail in the linked PR.
-Are future strategies being properly margined? If yes, where is the margin data?
Future margins are in the data folder, see for example cme. They require at least one data point to be able to determine which date is it see implementation that's why you are not seeing it being loaded on research.
-I have also checked several strategy library future algorithms using custom data and they do not set up the contractMultiplier attribute, so I doubt the results are correct.
Contract multiplier is driven by the symbol properties data base, see spdb. Custom data will need specifying the symbol properties manually with the desired settings.
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.
Gil Sapir
Jared Broad Martin Molinero
But what actually will be bought when buying this canonical contract when using it on live trading?
And if the “oldest” contract will be bought, what happens if it's bought and during the holding period- the contract will be rolled/expired (again, asking on live trading)?
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.
Manoj Agarwala
Excellent feature addition, it has eliminated a lot of headache for me. I was able to delete several hundred lines of code.
Though, I wish following flag was supported by AddFutures:
Auto_roll_forward = True | False
I also suggest the following flags should be supported by indicators (important for live trading):
Auto_update_for_splits
Auto_update_for_dividends
Auto_update_for_continuous_futures_symbol_change
Also, it will be awesome if you could bring similar type of complexity reduction in options. My first hand experience dealing with futures leads me to guesstimate tat continuous futures has led to 10x complexity reduction.
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.
Johnny Cash
Hi,
regarding “The implementation that creates the mappings and factors is closed source at the moment sorry, the implementation that applies the factors and mappings is part of Lean itself, can see this with more detail in the linked PR.”,
Is this closed source software installed in local lean installations, or it only works on the cloud?
Are there other closed source components in the local lean installation?
Does the margin calculation support spread credits, as per CME SPAN calculator, or it only adds the out-rights margins? I am talking about any spread for which there is a SPAN credit, only exchange traded spreads. This is quite important also in live trading.
Thanks
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.
Livermore
could you provide one example for research env?
how to GetFutureHistory for continuous future contract?
thanks.
below code does not work.
qb = QuantBook()
es = qb.AddFuture(Futures.Energies.CrudeOilWTI,
dataNormalizationMode = DataNormalizationMode.BackwardsRatio,
dataMappingMode = DataMappingMode.OpenInterest,
contractDepthOffset = 0)
start_time = datetime(2021, 6, 18, 10, 30)
end_time = datetime(2099, 7, 16, 16, 0)
future_history = es.GetFutureHistory(es.Symbol, start_time, end_time)
history = future_history.GetAllData()
history
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.
Varad Kabade
Hi Livermore,We recommend using the following:
Refer to the attached notebook,Note that currently the default is es.SetFilter(0,0) therefore GetFutureHistory will not return any data. We can also use es.SetFilter(0,180) as an alternative to above.Best,Varad Kabade
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.
Xinmin Cai INVESTOR
Martin Molinero
Regarding: “LastTradingDay: The contract maps on the previous day of expiration of the front month.”
I am not a future expert. But if I understand correctly, for physically settled contracts, such as gold (GC) and silver (si), brokers will close positions before the first notice date, which is usually 1 month before the last trade date. When the ticker is remapped using LastTradingDay, does it use the last trade date or the first notice date in the code?
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.
Xinmin Cai INVESTOR
Can someone give an example of how the data consolidation should be done with the continuous future price? For example, consolidating data into 15 minutes per bar.
Do we still do the old way of consolidating future data like documented here? If not, what is the proper way to consolidate data?
I tried the following and it doesn't work out. I only get one-period data feed on 2021-12-26 18:15:00 from OnDataConsolidated. That is the first 15 min bar. After that, there is no log produced.
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.
Martin Molinero
Hey Xinmin Cai !
Sorry for the delay. The code snippet you shared does work correctly, I'm attaching a backtest using it successfully.
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.
Xinmin Cai INVESTOR
Martin Molinero Thanks, Martin!
A follow-up question on this. If I specify fillDataForward=False in the self.AddFuture() call, does it work? I changed this but it feels there is no data coming through.
I am doing this is because I got a fill on a stale price. I want to make sure, my algo doesn't fill on stale price.
Appreciate the help!
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.
Richard Thomas Harrison
Xinmin Cai re first notice date: I don't think the dataset that QuantConnect has for futures includes first notice dates, I've asked them about this before and I ended up contacting AlgoSeek and I'm pretty sure AlgoSeek doesn't have first notice dates. Martin Molinero any comment on this?
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.
Varad Kabade
Hi Richard Thomas Harrison,
For now, all futures are cash-settled as we don't allow underlying (Live Cattle?) to be posted on the account, thus the FDN is not required (and we don't support this element).
Best,
Varad Kabade
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.
Ariel Nechemia
Is anyone else able to get tick level data in the research notebook? I can get second and minute level, but despite defining a time period or a specific bar count, I only get error messages like this:
NullReferenceException: Object reference not set to an instance of an object.
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.
Varad Kabade
Hi Ariel Nechemia,
Unfortunately, we cannot get Tick data in the research environment. Sorry for the inconvenience caused. We have opened a GitHub issue to get it resolved to subscribe to the following for updates:
https://github.com/QuantConnect/Lean/issues/4297
Best,
Varad Kabade
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.
Mathieu Meynier
Hello,
Could you please provide an example with front AND back contracts (contractDepthOffset = 1 for instance). I dont get any data on the back contracts when trying.
Thanks
Mathieu
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.
Louis Szeto
Hi Mathieu
We've created a GH issue on the "back contract" support by contractDepthOffset. Please subscribe to this issue for the progress.
For now, a workaround would be using GetFutureContractList and AddFutureContract.
Best
Louis
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.
Mathieu Meynier
Hi Louis,
Ok, thanks !
I'll use the GetFutureContractList method for now
Best,
Mathieu
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.
Flame
I've been doing more work with futures and I think that the mapping may need another option to change based on daily volume. I've been using the OpenInterest mapping mode, but I've found some issues. For example, Brent Last Day Financial (BZ) has a high open interest in December. This means that the current mapped contract is December 2022, but there is low daily volume compared to the June contract. Does anyone have any suggestions?
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.
Laurent Crouzet
As Flame, I think that the daily volume (for instance the average of trading volume over the last 2 to 3 days?) would be the best to really trade the “most active future contract”.
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.
Flame
For anyone wanting to trade front month futures based on daily trading volume I wrote the below code to help. Hopefully its useful
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.
Tom M
@Flame - thanks a lot for this. Do you know how you would add indicators to this framework? I was able to do so with the continuous contracts but, as you stated, ran into some issues i.e. open interest ≠ front month. So, trying to use yours but not sure how to do it. Thanks!
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.
Flame
Tom M - Hi Tom, the easiest way to use indicators with this implementation is to add the indicator you want to the FuturesContract class and then you can access the indicator value from the CurrentContract in the FuturesChain. By default, the FuturesChain class adds contracts that expire in the next 120 days down to the 2 days before expiry. This means as each contract is added it will also begin collecting data for the indicator you added to the contract so that by the time its in the front month it should be fully warmed up.
Hopefully that helps, but let me know if you have any queries.
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.
Tom M
Thanks Flame … I am having other issues with continuous futures at the moment (see attached post), so going to wait until I figure out what's going on before proceeding. I will reference your post when I come back to futures. But conceptually what you sent thru makes sense
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.
Brent Oster
In case others find it useful, this is an example of using NQ futures history to warm up some indicators using custom consolidators and then purchasing one NQ contract.As of when I wrote this it should work on backtests and live, though it does require the 3.0 beta.Enabling the 3.0 beta also required me to turn off the new Firefox privacy feature as it was interfering with the new dev environment.
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.
Joshua Lieberman
I'm curious how I should expect backwards panama series to work in a live trading scenario, as the way I see it:
Is my understanding correct, or is there some trick to avoid this tradeoff I'm missing?
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.
Louis Szeto
Hi Joshua
Your understanding is correct. The last contract data is the true one, and all previous ones will be refactored after an update. But remember, price adjustment of continuous futures is just a data smoothing technique actually, which gives us a more realistic study of the underlying asset's past price changes. So we shouldn't aggregate the raw data for comparison with the previously processed data. Instead, call a History object/dataframe every time you need a study of that.
Best
Louis
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.
LukeI
Can anyone help a noob with creating an algorithm to purchase VIX continuous futures? When I tried it said that it's not available to buy but I think there is a continuous VIX futures contract that interactive brokers has available for live trade. I just don't know how to call it out on Quantconnect.
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.
Louis Szeto
Hi Lukel
You have to call .Mapped property and trade the underlying contract. Continuous future is just a method to map over contracts for studying historical data like it was traded continuously under single symbol.
Read the Future Security Master docs for details.
Best
Louis
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.
Brian Christopher
I'm having trouble using the continuous contract symbol to access the data in a historical dataframe.
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.
Derek Melchin
Hi Brian,
Use the following snippet:
See the attached backtest for reference.
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.
Garrison Whipple INVESTOR
How do I access the minimum tick size of the altered tick price. like 0.23222556 instead of 0.25 due to it being mathematically changed. Or how can I access the multiplier of the contract price? future.SymbolProperties.MinimumPriceVariation will only get me 0.25 when I am using open interest and backwards ratio for continuous futures.
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.
Derek Melchin
Hi Garrison,
Please provide an example.
See the attached backtest for reference.
We were able to get the minimum price variation of 0.25 with other data normalization modes and and data mapping modes. See the attached backtest for reference.
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.
Garrison Whipple INVESTOR
Derek Melchin the contract multiplier you mentioned is 50 which is the dollars to tick multiplier, I am looking for something like the backwards ratio scale on this page: Lean: QuantConnect.Data.Auxiliary.MappingContractFactorRow Class Reference or the backwards ratio scale referenced on this page: Algorithmic Trading Platform - QuantConnect.com .
When I use continuous futures with the backwards ratio and open interest the ticks get altered and in order for me to find out how many ticks away the price has gone the 0.25 default tick does not help me because all the ticks and prices get multiplied by the backwards ratio scale, so they become 0.25 times the scale 0.9914163090128755364806866953 and is now 0.2478…
All I am looking for is a way to quickly get that altered tick size or the backwards ratio scale used for the current futures contract that is selected,
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.
Derek Melchin
Hi Garrison,
It's not currently possible to access the backwards ratio scale of continuous futures. To be notified when it's possible, subscribe to the following GitHub Issue:
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.
Garrison Whipple INVESTOR
How can I prevent this continuous futures algo from erroring out when using Futures.Energies.CrudeOilWTI contract on 9/22/2020 after the market has closed? is says: “Runtime Error: (,)” Stack Trace: “(<QuantConnect.Symbol object at 0x7fbbd1eaa540>,)”
It errors the same time that the EndofDay function runs
Same thing happens when using Futures.Grains.Corn contracts on 12/14/2020 Stack Trace: “(<QuantConnect.Symbol object at 0x7f94f23bdcc0>,)”
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.
Louis Szeto
Hi Garrison
You only stored the canonical symbol of CL in the dict self.symbolData. It will direct to the current mapped symbol. However, when the symbol mapped is changed, your algorithm is still subscribing to the old contract’s data. So, the old symbol will get called in the OnEndOfDay handler and it is not linked to the canonical symbol. It can be easily solved if you add a if-condition to check whether the symbol is in the dict
Best
Louis
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.
Profit
Is there a property or a helper method that returns the current offset factor (the difference between the prices of continuous future and the current mapped contract?). If not, how to compute the proper limit and/or stop prices when placing orders?
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.
Profit
I thought I found a way to compute the offset, but it doesn't work as expected. I'm using ForwardPanamaCanal and expected constant offset for a given mapped contract but instead seeing varying offset which doesn't make sense. Can someone explain what's missing and how to do this properly?
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.
Srk Quant
Martin Molinero This is fantastic news! I recently noticed that TradingView and IB also added this feature. So this will make backtesting much easier. For beginners to learn what all these “panama canal” means, I would love to see some lessons that we could take. What is the plan for adding this to the Futures learning course ?
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.
Louis Szeto
Hi Sri Quant
That would be a great idea, but we currently have not planned to do so yet. Right now, please refer to the continuous contract documentation and Future Security Master‘s dataset page for information. You might also seeks some external sources (e.g. quantpedia) to learn more about the adjustment methods.
Best
Louis
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.
Garth McGinley
Hi all,
I've been working with the continuous futures functionality and have been seeing some strange behavior whereby there is a rather large discrepancy between prices passed to onData and those used by order handling. I'm including a simple code example that buys then sells 5 futures. For comparison, this code prints the onData bar prices and the order details. You can see that the prices for the onData bars are consistently about $30-40 higher than the prices returned by the market order fills. I'm hoping this is a subtle configuration issue that maybe I don't understand or am missing regarding this feature, but I haven't been able to pinpoint why these discrepancies are present and I'm hoping someone from the community can help.
Thanks!
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!