Cyclically adjusted price-to-earnings ratio (CAPE)
Shiller's CAPE: the price over the average of real earnings over a window, its earnings yield and the excess CAPE yield over a real 10-year rate.
- Model id
equity.cape, version 1- Domain
- Equity
- Evidence
- practitioner
- Cost class
- instant: A closed-form calculation; a hosted run may take up to 2 seconds.
Formula
Where
- The cyclically adjusted price-to-earnings ratio
cape - The price of the index
price - Number of periods the earnings are averaged over: ten years of them
- Earnings in period k
earnings - The consumer price index at the date of the price
price_cpi - The consumer price index in period k
cpi - The CAPE yield: average real earnings over the price
cape_yield - The excess CAPE yield, over the real interest rate
excess_cape_yield - The real ten-year interest rate
real_rate - The nominal ten-year yield
nominal_yield - Periods in a year
periods_per_year
Each symbol's field is named beside it; the inputs and outputs, with their units and bounds, are under Variables, and the citations give each formula's source.
Variables
Rates, returns and yields are decimals: 0.05 is five percent. Bounds in brackets include their end; in parentheses they exclude it.
Inputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Pricepriceindex_level · [0.01, 1e+09] | index_level | [0.01, 1e+09] | The index level in month t |
Price CPIprice_cpiindex_level · [0.01, 1e+09] | index_level | [0.01, 1e+09] | The price index (CPI) of month t, the dollars results are in |
Earningsearningsmoney (array) · length min 1, max 480; each [-1e+09, 1e+09] | money (array) | length min 1, max 480; each [-1e+09, 1e+09] | Earnings of each period of the window before month t, oldest first (Shiller: the previous 120 months) |
CPIcpiindex_level (array) · length min 1, max 480; each [0.01, 1e+09] | index_level (array) | length min 1, max 480; each [0.01, 1e+09] | The price index of each period of the window |
Real yieldreal_yieldrate · [-0.05, 0.5] | rate | [-0.05, 0.5] | A real 10-year yield (TIPS); give this or nominal_yield |
Nominal yieldnominal_yieldrate · [-0.05, 0.5] | rate | [-0.05, 0.5] | A nominal 10-year yield, less trailing inflation for the real rate; give this or real_yield |
Inflationinflationrate · [-0.5, 1] | rate | [-0.5, 1] | Trailing annual inflation to take from the nominal yield; left out, (price_cpi / cpi[0]) ** (periods_per_year / n) - 1 over the window |
Periods per yearperiods_per_yearcount · [1, 12] | count | [1, 12] | Periods a year of the window (12 for months) |
Outputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Capecaperatio · [0, 1e+06] | ratio | [0, 1e+06] | Price over average real earnings; None when they average nothing positive, with a warning |
Cape yieldcape_yieldratio · [-1e+06, 1e+06] | ratio | [-1e+06, 1e+06] | Average real earnings over price, a decimal: 1 / CAPE |
Excess cape yieldexcess_cape_yieldratio · [-1e+06, 1e+06] | ratio | [-1e+06, 1e+06] | The CAPE yield less the real 10-year rate, a decimal |
Real ratereal_raterate · [-1, 1] | rate | [-1, 1] | The real 10-year rate the excess is over |
Average real earningsaverage_real_earningsmoney · [-1e+18, 1e+18] | money | [-1e+18, 1e+18] | The window's average earnings, in the dollars of month t |
Calculator
Run the model on your own inputs, starting from its example. Rates are decimals: 0.05 is five percent. The run goes to the pyeconomics API on this site: your values travel only in the request, and nothing is stored.
Live data runs on your own computer only
This model reads S&P composite stock price, Shiller, Consumer price index, Shiller's long-run series, S&P composite earnings, Shiller and Consumer price index, Shiller's long-run series. Their source, Robert Shiller US equity data, lets pyeconomics read the data on your own computer but not serve them from this website.
Here, enter your own values, or bring them as a file with "Use my own data". To run this page with every profile's live data, install the local app and start it: pip install "pyeconomics[app]" then pyeconomics serve.
Loading the calculator…
Worked example
Ten years of annual earnings and a nominal 10-year yield.
Example annual_window. Inputs:
{
"cpi": [220, 225, 230, 236, 241, 246, 252, 260, 275, 290],
"earnings": [100, 105, 98, 120, 140, 150, 160, 170, 190, 210],
"inflation": null,
"nominal_yield": 0.042,
"periods_per_year": 1,
"price": 4000,
"price_cpi": 300,
"real_yield": null
}Outputs:
{
"average_real_earnings": 172.50769276040774,
"cape": 23.187371739737515,
"cape_yield": 0.04312692319010193,
"excess_cape_yield": 0.03262840783037309,
"real_rate": 0.010498515359728844
}Assumptions
- Earnings and prices are deflated by one price index into the dollars of the price's month; the window is the n periods before it.
- Shiller's monthly earnings are four-quarter totals interpolated between quarters; his window is the previous 120 months.
- Profile: default binds Shiller's S&P composite price and CPI on the date, the previous 120 months of his earnings and CPI (lagged one month), and Treasury's 10-year TIPS yield; 'nominal' binds Treasury's 10-year yield, a monthly average, in place of TIPS, so the real rate is it less trailing inflation as in Shiller's file.
Limitations
- A valuation ratio, not a timing signal: high CAPEs have preceded low ten-year returns on average, with wide dispersion.
- When the window's real earnings average to nothing positive, CAPE is None with a warning; an earnings yield beyond 1e6, trailing inflation above 100% a year or a real rate outside [-1, 1] raise DomainError.
- Shiller publishes earnings months after prices: as of a recent date the earnings window ends at his last earnings, before the price's month. His file averages the earnings it has, so its latest CAPEs use fewer than 120 months. Trailing inflation then runs from the window's first price index to the price's month, more than the window's length, but is annualized over the window (about 0.15 percentage points too high at 3% inflation and a six-month lag): pass inflation to set it.
- Shiller's data are library-only: fetched at run time from his file and never stored.
Evidence
Status: practitioner. A widely used rule of thumb or convention.
Every model declares one status: standard (textbook consensus), practitioner (a widely used convention), contested (under active debate), rejected (failed out of sample) or historical (a superseded methodology).
Syllabus
The 2027 CFA® Program's topic areas this model relates to, as factual tags. Each links to CFA Institute's page for its level; pyeconomics holds none of the curriculum's text.
Data
This model can read its data for you: each bound field names a data series, and the sources listed can fill it, in the order they are tried. This website reads only the sources whose terms let it serve their data (marked "hosted"); every source is available when you run pyeconomics on your own computer.
| Field | Concept | Read as | Sources (licence class; hosted) |
|---|---|---|---|
price | S&P composite stock price, Shillerus.equity.sp_composite_price | last observation on or before the date; real time: as published by the date |
|
price_cpi | Consumer price index, Shiller's long-run seriesus.prices.cpi_long_run | last observation on or before the date; real time: as published by the date |
|
earnings | S&P composite earnings, Shillerus.equity.sp_composite_earnings | the last 120 observations on or before the date; real time: as published by the datetransform lag(periods=1) |
|
cpi | Consumer price index, Shiller's long-run seriesus.prices.cpi_long_run | the last 120 observations on or before the date; real time: as published by the datetransform lag(periods=1) |
|
real_yield | Treasury 10-year real yieldus.treasury.real_10y | last observation on or before the date; real time: as published by the date |
|
| Field | Concept | Read as | Sources (licence class; hosted) |
|---|---|---|---|
price | S&P composite stock price, Shillerus.equity.sp_composite_price | last observation on or before the date; real time: as published by the date |
|
price_cpi | Consumer price index, Shiller's long-run seriesus.prices.cpi_long_run | last observation on or before the date; real time: as published by the date |
|
earnings | S&P composite earnings, Shillerus.equity.sp_composite_earnings | the last 120 observations on or before the date; real time: as published by the datetransform lag(periods=1) |
|
cpi | Consumer price index, Shiller's long-run seriesus.prices.cpi_long_run | the last 120 observations on or before the date; real time: as published by the datetransform lag(periods=1) |
|
nominal_yield | Treasury 10-year yieldus.treasury.nominal_10y | last observation on or before the date; real time: as published by the datetransform convert(to=monthly,method=mean) |
|
Citations
- Campbell, J. Y. and Shiller, R. J. (1998). Valuation Ratios and the Long-Run Stock Market Outlook. Journal of Portfolio Management, 24(2), 11-26. doi:10.3905/jpm.24.2.11 (p. 16: price over the average of the previous ten years' real earnings)
- Campbell, J. Y. and Shiller, R. J. (1988). Stock Prices, Earnings, and Expected Dividends. Journal of Finance, 43(3), 661-676. doi:10.1111/j.1540-6261.1988.tb04598.x (Smoothed real earnings over the previous ten years)
- Shiller, R. J. U.S. Stock Price, Earnings and Dividends, monthly since 1871: ie_data.xls, the CAPE and Excess CAPE Yield columns. https://shillerdata.com/ (Sheet Data: CAPE (column M) and Excess CAPE Yield (column Q))
Changelog
- Version 1: First version.
Use it elsewhere
- Documentation
- The model's reference page
- REST API
GET or POST /v1/models/equity.cape/run- MCP tool
run_modelwith the model's id,equity.cape. Connect an assistant- Command line
pyeconomics models run equity.cape --help
The worked example, from Python and from the command line:
import pyeconomics
inputs = {
"cpi": [220, 225, 230, 236, 241, 246, 252, 260, 275, 290],
"earnings": [100, 105, 98, 120, 140, 150, 160, 170, 190, 210],
"inflation": None,
"nominal_yield": 0.042,
"periods_per_year": 1,
"price": 4000,
"price_cpi": 300,
"real_yield": None,
}
result = pyeconomics.run("equity.cape", inputs)
print(result.to_json())
pyeconomics models run equity.cape --inputs - <<'JSON'
{
"cpi": [220, 225, 230, 236, 241, 246, 252, 260, 275, 290],
"earnings": [100, 105, 98, 120, 140, 150, 160, 170, 190, 210],
"inflation": null,
"nominal_yield": 0.042,
"periods_per_year": 1,
"price": 4000,
"price_cpi": 300,
"real_yield": null
}
JSON