Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Research get_pricing() function gives only limited data, majority of rows filled with nan

Dear All,

I wanted to do some research on my backtest and found if I want to load the security data which was bought by my algorithm by get_pricing() somehow I only get data for a limited years. I do now find it in the documentations and I am bit confused. Can you please help?

for instance if I run the below query, I get data from more-or-like 2014 january till the end date, but not before - they are all nans. Why is that the case? What am I missing here?

pricing_series = get_pricing('GOOG', start_date="2008-08-01", end_date="2016-08-01", fields='price')
pricing_series.plot()

Thank you in advance!

3 responses

GOOG and GOOG_L are two separate share classes. Take a look here https://www.investopedia.com/ask/answers/052615/whats-difference-between-googles-goog-and-googl-stock-tickers.asp

GOOG didn't exist before April 2014 which is why you see NaNs for price. You probably want to trade GOOGL which is actually GOOG_L on the Quantopian platform. Try the later symbol which references the class A stock and you will get the full history.

Good luck.

Hi Dan,

Many thanks for your feedback.

Actually, my problem was a bit more extensive, but with the help of your reply, I found a solution.
GOOG was only a far-fetched example - my mistake that I didn't share an exact one. There were a plenty of tickers which I traded in the ALGO and unable to find price data for them in RESEARCH. An actual example:

My algorithm bought:

  • Ticker: PNK-21187
  • Date:Timestamp('2014-04-01 00:00:00')

But when I tried to load data like:

get_pricing('PNK', start_date='2014-03-01', end_date='2014-04-01', frequency='daily')

I got only NANs. Now I understand that the problem was that I was ignoring the SID which is part of the ticker in the backtest environment and also it only can be used as an integer. As first I thought SIDs are mainly important in the ALGO section, but RESEARCH work with Symbol. The correct method would've been:

get_pricing(21187, start_date='2014-03-01', end_date='2014-04-01', frequency='daily')

  • the get_backtest function gives back tickers like 'PNK-21187' where
    the second part is the actual sid that should be used
  • note that '21187' doesn't work as a string only as integer

I also found helpful that in RESEARCH notebook I can use print(symbols(21187)) or print(symbols('PNK')) or print(symbols('PNK').sid) to check these. Because the ticker as highlighted in documentation can refer to different equitites in time, and that was my really basic problem: symbols('PNK') != symbols(21187)

Hope this explanation helps someone :)

@Robert Glad you got it figured out. Your explanation was helpful. Good advice to use the SID whenever possible and not the ticker symbol. As you noted, ticker symbols can change and can also be non-unique. The SID is definitive.