Is there a template to get started with Futures in Python? Thank you.
QUANTCONNECT COMMUNITY
Is there a template to get started with Futures in Python? 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.
Alexandre Catarino
We wrote this algorithm based on the C# template.
The key is to filter the FuturesChains object found in the Slice object that arrives in the OnData event handler to find the front contract no earlier than 90 days (since in this example, we are looking to that expire date from current date):
# find contracts expiring no earlier than in 90 days contracts = [ i for i in chain.Value \ if i.Expiry > self.Time.Date.AddDays(90) ] # if there are contracts under those conditions, # pick the front contract if len(contracts) > 0: contract = sorted(contracts, \ key=lambda x: x.Expiry, reverse=True)[0]
AMP 2
Thanks Alexandre. Is there a way to build continuous contracts from those individual contracts? Suppose you want to calculate an EMA200 on ES, you probably need to concatenate 3 contracts since they are only liquid 3 months each. How this would be done in QC? Thank you for your help.
Alexandre Catarino
At the moment, there is no way to build continous contracts, but they are definitely in our TODO list of features. Since Futures and Options support is still beta we are working on improvements and stability before adding more features.
Yiannis Petrou
How high on your todo list is it:)
AMP 2
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!