hi does anyone know what i'm doing wrong?
i'm not getting any errors but the algorithm isn't trading any futures contracts.
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.
Algorithm not trading futures contracts. No errors. Need help.
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
|
|
|||||||
|
|
||||||||
|
Not finding any contracts to trade
Apollos Hill | January 2019
hi does anyone know what i'm doing wrong?
i'm not getting any errors but the algorithm isn't trading any futures contracts.
Apollos,
The first thing I noticed is that the logical conditions where the algorithm checks for the contract chain ticker (see the snippet below) are where things are breaking down. The Symbol given by chain.Key.Value is a full ticker but Futures.Indices.SP500EMini or NASDAQ100EMini are strings but just the prefix 'ES' or 'NQ', and so checking for logical equivalence will return False every time. The full list of Futures ticker prefixes can be found here. So what needs to occur, then, is filter contracts by checking if the symbol contains the proper prefixes. I've attached a backtest that is a skeleton if what your code is right now but outlines how to carry out the same general strategy of trading the front contracts and taking positions based on the contract symbol. Hopefully this will help you with the WTI/Brent section of the algorithm.
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
Ernest Shaggleford
Hi Apollos,
there were a few bugs that I found:
1. The futureNQ setfilter was using futureES variable
2. filter period was too short at 35d. Futures have quarterly expirations so need at least 90d.
3. some variables were not using self. reference
May I suggest that when debugging to log the raw OnData slice data to check any filters are working as intended.
-ES
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.
Apollos Hill
wow thanks!. i need to brush up on my futures fundamentals . I never would have noticed the 35 day thing. I trade forex and options. never done futures. i appreaciate your help ES.
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.
Ernest Shaggleford
No problem. Always fun to work out why things don't work :) Pay it forward if you get a chance.
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.
Apollos Hill
Hi ES ,
thanks! i will see who i can help out on the forums! I am getting a wierd issue that i shouldn't be..i am trading over a thousand orders per trading signal...but i'm using IF not self.portfolio[self.front.symbol].IsShort/IsLong.. then initiate trade... i think the problem is in my liquidate IF statement. what do you think?
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.
Jack Simonson
Hi Apollos,
I looked at the second backtest posted above and was replicating the problem where there were no futures contracts being returned, but it sounds like you've fixed that and now are encountering a different issue. Can you attach a backtest or the code that you're running so myself or someone in the community can assist you in debugging the algorithm?
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.
Apollos Hill
Hi Jack. Thanks for your willingness to help. Here is my backtest from a couple weeks ago. I have since taken a break on it. I'm not finding any ES/NQ contracts to trade. I commented out the WTI /Brent code so i can focus on one pair at a time.
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.
Apollos Hill
Thanks for explainig this Jack!
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!