Price to Earnings Ratio (PE)
Calculate the price earnings ratio (P/E), a valuation ratio that compares a company’s stock price to its earnings per share.
The price earnings ratio is a widely used valuation metric that helps investors assess the relative value of a company’s stock. A higher P/E ratio may indicate that the market has high expectations for the company’s future growth, while a lower P/E ratio may suggest that the company is undervalued.
The formula is as follows:
\[\text{Price to Earnings Ratio} (P / E) = \text{Share Price} / \text{Earnings per Share} (\text{EPS})\]Also known as: PE ratio, P/E ratio, price-earnings ratio, earnings multiple.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Price to Earnings Ratio (PE) for you. Just ask in plain English.
Calculate the Price to Earnings Ratio (PE) in Python
The Price to Earnings Ratio (PE) is available in the Ratios module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_price_to_earnings_ratio as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")
pe_ratio = toolkit.ratios.get_price_to_earnings_ratio()
Which returns:
| 2021 | 2022 | 2023 | 2024 | 2025 | |
|---|---|---|---|---|---|
| AAPL | 31.6299 | 21.254 | 31.3868 | 41.1631 | 36.418 |
| TSLA | 215.568 | 34.0154 | 57.6961 | 198.126 | 418.189 |
Parameters
get_price_to_earnings_ratio accepts the following parameters:
- include_dividends (bool, optional): Whether to include dividends in the calculation. Defaults to False.
- diluted (bool, optional): Whether to use diluted shares in the calculation. Defaults to True.
- rounding (int, optional): The number of decimals to round the results to. Defaults to 4.
- growth (bool, optional): Whether to calculate the growth of the ratios. Defaults to False.
- lag (int | str, optional): The lag to use for the growth calculation. Defaults to 1.
- standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.
- trailing (int, optional): Defines whether to select a trailing period. E.g. when selecting 4 with quarterly data, the TTM is calculated.
Related Valuation Ratios
The Ratios module page introduces the module, and the sidebar lists all of its functions.