Hi, I am trying to find the current price of each stock in my basket (10 tickers). I didn't think you needed a for statement since the code worked before without it. I wanted to just change out the chikou value for the stocks current price.
This is in the IchimokuCloud CrossOverAlphaModel Code
Erik schuh
See Above
Shile Wen
Hi Erik,
We can use self.CurrentSlice[symbol].Close or self.Securities[symbol].Price to get the current price of a security.
Best,
Shile WenÂ
Erik schuh
Shile Wen Thanks for the help. I am getting this error everytime with both of your suggestions:Â
Â
Runtime Error: AttributeError : 'SymbolData' object has no attribute 'CurrentSlice' AttributeError : 'SymbolData' object has no attribute 'CurrentSlice' (Open Stacktrace)
I don't see why object has no attiribute unless there needs to be one line added to the def get_location()
Derek Melchin
Hi Erik,
The easiest way to accomplish this is to pass the current price to the `get_location` method. This is done by updating two lines:
self.previous_location = self.get_location(row.close)
and
current_location = symbol_data.get_location(data[symbol].Price)
We then change the definition of `get_location` to
def get_location(self, price): chikou = price # ...
See the attached backtest for reference.
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.
Erik schuh
Thanks Derek!
Erik schuh
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!