download_open_source.download_data_pastor_stambaugh()
Download and process Pastor-Stambaugh liquidity factors.
Usage
download_open_source.download_data_pastor_stambaugh(
start_date=None,
end_date=None,
url="https://faculty.wharton.upenn.edu/wp-content/uploads/2016/11/liq_data_1962_2025.txt"
)Downloads and processes the liquidity factor data of Pastor and Stambaugh (2003) from Stambaugh's data library <https://fnce.wharton.upenn.edu/profile/stambaug/#misc>_. The source is a whitespace-delimited text file whose header lines start with a percent sign. The function reads the three liquidity series, aligns the monthly date to the beginning of the month, and optionally filters the data based on a provided date range.
The series are already expressed as plain numeric (decimal) values in the source data, so no rescaling is applied. The traded liquidity factor is only available from 1968 onward; earlier observations are coded as -99 in the source file and are returned as missing values.
Parameters
start_date: str = None-
A character string or date in ‘YYYY-MM-DD’ format specifying the start date for the data. If not provided, the full dataset is returned.
end_date: str = None-
A character string or date in ‘YYYY-MM-DD’ format specifying the end date for the data. If not provided, the full dataset is returned.
url: str = "https://faculty.wharton.upenn.edu/wp-content/uploads/2016/11/liq_data_1962_2025.txt"- The URL of the liquidity data file. Because the file name embeds the last year of data, the default points to the most recent file known at release time; override it when a newer file becomes available.
Returns
pl.DataFrame- A data frame with the columns ‘date’ (aligned to the beginning of the month), ‘agg_liq’ (levels of aggregate liquidity), ‘innov_liq’ (innovations in aggregate liquidity, the non-traded liquidity factor), and ‘traded_liq’ (the traded liquidity factor LIQ_V), filtered by the specified date range if ‘start_date’ and ‘end_date’ are provided.
References
Pastor, L., and Stambaugh, R. F. (2003). Liquidity risk and expected stock returns. Journal of Political Economy, 111(3), 642-685. https://doi.org/10.1086/374184
Examples
from tidyfinance import download_data_pastor_stambaugh
pastor_stambaugh = download_data_pastor_stambaugh(
start_date='2020-01-01', end_date='2020-12-31'
)