Liquidity Beta
Calculate the Liquidity Beta of Pastor and Stambaugh (2003) per ticker and month: how much the ticker’s return moves with shocks to the liquidity of the whole US stock market, beyond the market, size and value factors.
Pastor and Stambaugh measure market liquidity as the average order flow reversal of stocks (how much of a day’s volume-signed return reverses the next day) and take its unexpected changes as the liquidity factor. Stocks whose returns fall when liquidity dries up, as it did in 1987, 1998, 2008 and March 2020, are risky for investors who may need to sell then, and in the paper the stocks with the highest liquidity betas earned about 7.5% a year more than those with the lowest, after the market, size, value and momentum factors.
The formula is as follows:
\[\text{Excess Return}_{t} = \beta_{0} + \beta_{L} \cdot L_{t} + \beta_{M} \cdot \text{MKT}_{t} + \beta_{S} \cdot \text{SMB}_{t} + \beta_{H} \cdot \text{HML}_{t} + \epsilon_{t}\] \[\text{Liquidity Beta} = \beta_{L}\]Where \(L_{t}\) is the innovation in aggregate liquidity (the paper’s non-traded factor) or the traded liquidity factor, MKT, SMB and HML are the Fama and French three factors and the regression is ordinary least squares on the monthly excess returns of the 60 months up to and including the month shown, with at least 36 of them, as the paper estimates historical liquidity betas.
Also known as: Pastor-Stambaugh liquidity beta, liquidity risk beta, BetaLiquidityPS, LIQ beta.
Example · AAPL, MSFT, KO · 2015 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_liquidity_beta:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "KO"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2015-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_liquidity_beta().loc["2025-07":]
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
How much did the returns of Apple, Microsoft and Coca-Cola move with the Pastor-Stambaugh market liquidity factor in each month of the second half of 2025, with data from 2015?
Which returns:
| Item | AAPL | MSFT | KO |
|---|---|---|---|
| 2025-07 | -0.0336 | 0.0605 | -0.1607 |
| 2025-08 | -0.0313 | 0.0639 | -0.1604 |
| 2025-09 | -0.0451 | 0.0160 | -0.1714 |
| 2025-10 | -0.0431 | 0.0163 | -0.1743 |
| 2025-11 | -0.0310 | 0.0172 | -0.1755 |
| 2025-12 | -0.0294 | 0.0173 | -0.1730 |
6 rows
Parameters
get_liquidity_beta accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
factor | str | The liquidity factor. Options are: “innovation” (the innovations in aggregate liquidity, the factor of the paper), “traded” (the traded factor, the return of the stocks with the highest historical liquidity betas minus the lowest, from 1968). Defaults to “innovation”. | "innovation" |
window | int | The number of months of each regression; it needs 60% of them (36 of the default 60). At least 6. Defaults to 60. | 20 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the Liquidity Beta. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |
transform | str | list[str] | None | Time series steps applied in order, such as “sma:12” (moving average), “ema:12”, “std:12”, “zscore:60”, “percentile:120”, “yoy”, “pct_change:3,annualize:3”, “log”, “diff”, “cumsum” or “hp_trend” and “hp_cycle” (Hodrick-Prescott), before growth. A window needs that many periods of history, so the first periods can be empty. Defaults to None. | None |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
References
- Paper Pastor, L. and Stambaugh, R. F. (2003). “Liquidity Risk and Expected Stock Returns.” Journal of Political Economy, 111(3), 642-685.
- Paper Fama, E.F. and French, K.R. (1993). “Common Risk Factors in the Returns on Stocks and Bonds.” Journal of Financial Economics, 33(1), 3-56.
- Library Shares similar logic as statsmodels’ RollingOLS