LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
I used to use the AddFuture() function to request Future data. But I found the AddFutureContract() function and thought it will be more straightforward to use it if I only want to get the data of the front month contract. To use it, I have to create the Symbol object of the front month contract but I cannot find any sample code about it. Say, I want to trade the front month contract of CL (WTI crude oil), how can I create the Symbol object for the front month contract given the future symbol string 'CL'?
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.
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.
Alexandre Catarino
100.5k
,
Hi Wiston Juliac ,
It's more straightforward to use AddFuture in this case:
var future = AddFuture(ticker, Resolution.Minute);
future.SetFilter(x => x.FrontMonth().OnlyApplyFilterAtMarketOpen());
since you would need to know the exact expiry date to create the right future contract symbol.
0
Wilson Tang
78
,
Hi Alexandre Catarino,
Thanks for your response. What is the function OnlyApplyFilterAtMarketOpen() used for? If I omit it, will I sometimes get more than one front month contract's data within one trading day?
0
Edited by Wilson Tang
Derek Melchin
STAFF
,
Hi Wilson,
The OnlyApplyFilterAtMarketOpen method instructs the engine to only filter options contracts on the first time step of each market day. Using it improves performance. See the source code and comments here.
Best, Derek Melchin
0
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.
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.
Loading...
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!