Hey guys, I'm having an issue with the history call function. When I call history on SPY, it returns a data table but SPY has extra characters tacked on. To be exact, this is the name it returns "SPY R735QTJ8XC9X". This looks like maybe it's trying to pull options data instead of equity data? I'm not sure.
The call function I'm using is below (SPY as a string is the only item in the self.symbols list). When going into debug, checking the history item shows that the data is there, just the name is different. I tried a few different time frames around 2006 and 2012 just to see if it was an error in one spot but they returned the same data.
history = self.History(self.symbols, 150, Resolution.Daily)
Any help is appreciated. Thanks!
Alexandre Catarino
Hi Brad Hearne ,
Those characters represent the properties of a given security.
For more details, please check out the docs, under Security Identifiers.
We have changed how pandas data frame with the history information is indexed and tried to ensure backward compatibility.
Consequently, we can use
spyHistory = history.loc["SPY"]
to access SPY data even though the actual index is "SPY R735QTJ8XC9X".
Brad Hearne
Ok, that makes sense. Does that change how we check to confirm an equity is in the history call? Previously, I've used
for symbol in self.symbols:
if symbol in history.index.get_level_values(0): ...
to get all of the equity indices/names to compare to the the equity pool I'm looking at to ensure the data is there before trying to work with the df. When calling this against the df for the SPY history, the if statement doesn't get satisfied anymore and it's now being skipped over. Has this call been updated?
Also, thanks for the quick reply!
Brad Hearne
It looks like simply using history.index works instead of the history.index.get_level_values(0)! It's seeing the equity names in the dataframe now from that. Thanks!
Brad Hearne
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!