Hi,
I'am developing a strategy for EURUSD and for LEAN everything works ok,
but on web-platform I received the following error:
Backtest Error: Error initializing algorithm: This may be because history is using fake data while pre-analyzing an algorithm for a backtest
Backtest Error: Error initializing algorithm: This asset symbol (EURUSD 5O) was not found in your security list. Please add this security or check it exists before using it.
Here is a piece of code which is in Initialize() function:
Ticker = "EURUSD";
SetStartDate(new DateTime(2014, 05, 01));
SetEndDate(2014, 05, 05);
SetCash(100000);
AddForex(Ticker, Resolution.Second);
m_Symbol = QuantConnect.Symbol.Create(Ticker, SecurityType.Forex, Market.FXCM);
What is wrong with my code?
Genorse Gilbert
Hi Alexandr,
Try the below:
Also, remember that Forex uses the QuoteBar class for second and minute resolution data instead of TradeBar. It will be good to post the rest of the code since some of your problems may lye outside of what you posted.
private string symbol = "EURUSD";
public override void Initialize()
{
SetStartDate(2014, 5, 1);
SetEndDate(2014, 5, 5);
SetCash(100000);
AddSecurity(SecurityType.Forex, symbol, Resolution.Second);
Securities[symbol].FeeModel = new FxcmFeeModel();
}
Respectfully,
Geno
JayJayD
The method AddSecurity returns an Security object, one of the properties of the security is its Symbol.
Same thing with AddCfd, AddForex, AddEquity, etc.
You can try something like this:
private const string ticker = "EURUSD"; Symbol symbol; public override void Initialize() { symbol = AddForex(ticker).Symbol; }
So you can refer to the symbol in the rest of the Algorithm.
Alexandr Trenkenshu
Thank you, guys, you really helped me.
Alexandr Trenkenshu
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!