Hi all,
I am new to both quantconnect and as a developer. I was trying to create a simple 5 ema and 13 ema crossover strategy on ES Futures and I got the following error:
“[ERROR] FATAL UNHANDLED EXCEPTION:Engine.Run(): During the algorithm initialization, the following exception has occurred: Please register to receive data for symbol 'ES 0' using the AddSecurity() function. in Indicators.cs:line 2090 Please register to receive data for symbol 'ES 0' using the AddSecurity() function.,ApiConnection.TryRequest(backtest/status/update): Error: The operation has timed out.”
Can someone help me understand what I need to change to get this code to run properly? When I try to run the same type of strategy on SPY, It works accurately. I think there is an issue with contract selection but I am not sure how to troubleshoot the problem.
The communities wisdom would be greatly appreciated!
from AlgorithmImports import *
import QuantConnect
class test(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2022, 12, 1) # Set Start Date
self.SetEndDate(2022, 12, 23) # End Date
self.SetCash(100000) # Set Strategy Cash
self.emini = self.AddFuture(Futures.Indices.SP500EMini)
self.emini.SetFilter(0, 90)
self.fast = self.EMA(Futures.Indices.SP500EMini, 5)
self.slow = self.EMA(Futures.Indices.SP500EMini, 13)
def OnData(self, data):
if self.fast.Current.Value > self.slow.Current.Value:
self.MarketOrder(Futures.Indices.SP500EMini, 1)
elif self.fast.Current.Value < self.slow.Current.Value:
self.MarketOrder(Futures.Indices.SP500EMini, -1)
Derek Melchin
Hi Subin,
See the attached backtest.
Best,
Derek Melchin
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.
Subin Chacko
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!