In a test algorithm, I'm calling this in Initialize
self.AddForex('EURJPY', Resolution.Daily, Market.Oanda)
Then in OnData I call this
for key in self.Securities.Keys:
self.Log(key)
And it returns 3 values (the first 2 of which will cause Lean to error out if I try to access it)
'EURUSD 8G' # Where is this coming from?
'USDJPY 8G' # Where is this coming from?
'EURJPY' # This is the only one I'm expecting
I then try to progamatically access data with these self.Securities.Keys and get an error: 'EURUSD 8G' wasn't found in the TradeBars object
Does anyone know why this is happening? Am I doing something wrong? Should I be accessing my symbols' data another way?
Thanks in advance!
Rahul Chowdhury
Hey Devin,
The default base currency for Lean is USD. This means if we subscribe to a currency pair where both pairs are foreign, like EURJPY, the algorithm will need to be able to convert between EURUSD and USDJPY to be able to properly work with EUR and JPY.
Also keep in mind, when accessing data from the slice object, it's best to use the Symbol object to identify the security. You can learn more about security identifiers in the documentation.
Best
Rahul
Jerryfan
I have also encountered this 'EURUSD 8G', not sure if there is a solution? It's been almost 1 year since you raised the question.
Derek Melchin
Hi Jerryfan,
To resolve the issue, we should provide the Symbol of the forex pair when accessing the `self.Securities` dictionary. See the attached backtest for an example.
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.
Devin Curry
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!