Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Confused about return value of "get_pricing('GOOG')"

In a research notebook, symbols('GOOG') suggests that GOOG is the right ticker symbol for Alphabet, Inc. aka Google. However, get_pricing('GOOG') returns an array full of NaNs. What's the right way to get GOOG's historical prices?

I posted a question about this with a simple demonstration notebook a couple of days ago, but I think it was probably cryptically terse.

4 responses

Take a look at the documentation https://www.quantopian.com/help#quantopian_research_get_pricing. You need to specify a begin and end date as well as what data you want. Something like this:

# this returns a list (one symbol and one field)  
pricing_series = get_pricing('GOOG', start_date="2015-08-01", end_date="2016-08-01", fields='price')

If just a single quoted ticker symbol is given then it returns a pandas series. If you use a list (even if the list has a single ticker) then it will return a pandas dataframe.

# this returns a dataframe- notice the brackets around the symbol. still one field  
pricing_df = get_pricing(['GOOG'], start_date="2015-08-01", end_date="2016-08-01", fields='price')

If you enter multiple fields (the default if not specified) then the result is a pandas panel.

# this returns a panel- list of symbols and a list of fields  
pricing_panel = get_pricing(['GOOG'], start_date="2015-08-01", end_date="2016-08-01", fields={'volume', 'price'})

Most importantly though you need to specify the dates you want it for. After that you just need to be careful accessing the returned object because it changes depending upon the requested symbol quantity and field quantity.

Attached is a notebook showing this behavior.

Thank you, Dan. Why do the default values for get_pricing result in NaN's? Start and end dates of 01/03/2013-4 seem sane, and the fields documentation says "Default behavior is to return all fields."

Need to add the 'symbol_reference_date' parameter. Otherwise it defaults to today. GOOG doesn't exist today so it returns NaN.

# Use the symbol_reference_date parameter.  
pricing_series = get_pricing('GOOG', start_date="2013-03-01", end_date="2014-03-01", fields='price', symbol_reference_date="2013-05-01")

Got it. Thanks.