I am currently not getting Nasdaq 100 data
Don't have an account? Join QuantConnect Today
QuantConnect Community Discussions
QUANTCONNECT COMMUNITY
LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
The Open-Quant League is a quarterly competition between universities and investment clubs for the best-performing strategy. The previous quarter's code is open-sourced, and competitors must adapt to survive.
Request for C# code to retrieve E-mini Nasdaq 100 futures data.
Continue ReadingRefer to our Research Guidelines for high quality research posts.
Create an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
|
|||||||
|
|
||||||||
|
How do I get E - mini Nasdaq 100 index Futures Data C#?
Itumeleng Moreotlotlo | May 2021
Hi Itumeleng Moreotlotlo,
The algorithm above has a few issues:
(1) The SetHoldings method is trying to place orders with _chainSymbol
SetHoldings(_chainSymbol, 0.50);
(2) The algorithm places trades every minute(3) The quantity for the TP and SL orders should all be negative(4) We should only cancel TP/SL orders when an order is filled
if (orderEvent.Status != OrderStatus.Filled)
{
return;
}
(3) The quantity for the TP and SL orders should all be negative
(4) We should only cancel TP/SL orders when an order is filled
if (orderEvent.Status != OrderStatus.Filled)
{
return;
}
See this backtest for reference. Refer to this thread to know more about TP/SL orders
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.
QuantConnect™ 2025. All Rights Reserved
Itumeleng Moreotlotlo
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.
Itumeleng Moreotlotlo
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 Itumeleng Moreotlotlo,
In the above algorithm, the OnData method receives an object of type Slice, not of typeTradeBar. In the OnData method, we need to find the contract chain for our symbol, and for each contract, in the chain, we create 2 EMA Indicators(fast and slow). Refer to this doc about using futures data . After selecting the contract we want to trade (Here, we selected contract according to expiry date), we check for the signal and place our order. Refer to the attached backtest for reference, which includes the changes mentioned 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.
Itumeleng Moreotlotlo
Hi Varad, I am kind of new into this, I tried implementing the dictionaries into my updated strategy and it is not giving back results can you please 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.
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.
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!