Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Is it possible to get historical P/E with get_fundamentals?

I was wondering if there's a way to get P/E ratio for a specific date with the get_fundamentals method in research mode. I know there's the base_date field with range_specifier but the result doesn't seem to be what I'm expecting. Can anyone give me some insight? Thanks very much.

3 responses

Below is what I have now but it is a bit off from what I can see on Google or Yahoo Finance, so I'm not sure if I'm doing it correctly.

fundamentals = init_fundamentals()
df = get_fundamentals(
query(fundamentals.valuation_ratios.pe_ratio,
fundamentals.valuation.market_cap,
fundamentals.valuation_ratios.pb_ratio,
fundamentals.valuation_ratios.pcf_ratio,
fundamentals.valuation_ratios.forward_pe_ratio,
fundamentals.valuation_ratios.peg_ratio,
fundamentals.balance_sheet.patents,
fundamentals.asset_classification.morningstar_sector_code,)
.filter(fundamentals.share_class_reference.symbol=="AAPL")
.limit(1)
,"2015-08-16", "1d")

for stock in df:
print stock.asset_name, ":", stock.symbol, "-", df[stock]['pe_ratio']
print stock.asset_name, ":", stock.symbol, "-", df[stock]['pb_ratio']
print stock.asset_name, ":", stock.symbol, "-", df[stock]['market_cap']

Result:
APPLE INC : AAPL - 13.12
APPLE INC : AAPL - 5.1497
APPLE INC : AAPL - 647201919780

Those metrics are all based on price. The data you see on the front page of Yahoo Finance or Google is real time (i.e. today's real time price). Apple for example is up ~1% today as I write this so it follows that the ratios and values would be higher because their price has gone up since the most recent snapshot provided to us by Morningstar yesterday.

Disclaimer

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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.

Right, I do realized that but even if I used the closing price on 16th, I'm still not getting 13.12 pe_ratio.