Back

AttributeError: '0, Culture=neutral, PublicKeyToken=null]]' object has no attribute 'loc'

Hi All,

I am encountering the following error with the default research notebook at line h1.loc["SPY"]["close"].plot():

AttributeError: '0, Culture=neutral, PublicKeyToken=null]]' object has no attribute 'loc'

Why is that happen and how to resolve it ? Thanks very much! Kevin
Update Backtest







The reason why the error occurred is that when calling qb.History() there were no assets specified; the only parameters were the number of bars and the resolution.

The line should have been: h1 = qb.History(qb.Securities.Keys, 360, Resolution.Daily)

Since qb.Securities.Keys is called, all the securities added will be requested in this line.

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.


Thanks Guru, that error was gone.

However, a new warning pop out:

--------

/opt/miniconda3/lib/python3.6/site-packages/ipykernel_launcher.py:2: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.

--------

Does this warning impact the correctness of the result ?

Thanks.
0

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