Hello,
I just started using QuantConnect and I'm try to grab the current price using the code below to determine if it is above a MA but I keep getting this error saying:
KeyError : 'the label [EURUSD] is not in the [index]'
self.symbol = "EURUSD"
eurusd_slices = self.History([self.symbol], 1) # multi-index dataframe
eurusd_bars = eurusd_slices.loc[self.symbol] # single index dataframe
eurusd_close = eurusd_bars["close"] # use lowercase
self.lastClose = eurusd_close.tail(1)
I'm using code from another strategy to get the previous day closing price.
Thanks,
Jared Broad
Current price - self.Securities["EURUSD"].Price
Or last data pushed into the algorithm: self.CurrentSlice["EURUSD"].Close
Assuming you've asked for the data.
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.
Javarrus Mickle
Thanks, that worked for me!
Javarrus Mickle
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!