Back

Self.Securities.Keys holds bad data: 'EURUSD 8G' wasn't found in the TradeBars object

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!

Update Backtest







0

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.


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

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed