Skip to main content

download.download_data_osap()

Download and process Open Source Asset Pricing data.

Usage

Source

download.download_data_osap(
    start_date=None,
    end_date=None,
    sheet_id="10sOryk_ddjkXagaajTKUk1nwJs2ZLRiI"
)

Downloads the data from the Open Source Asset Pricing project at https://www.openassetpricing.com/data/ from Google Drive using a specified file ID, processes the data by converting column names to snake_case, aligning the date to the beginning of the month, scaling the percentage long-short returns to numeric values, and optionally filters the data based on a provided date range.

The dataset contains monthly long-short returns of the predictor portfolios. Every column other than ‘date’ is a return expressed in percent, so all of them are divided by 100 to convert them into plain numeric (decimal) returns.

Google Drive limits how often a shared file can be downloaded. When the limit is reached, Google Drive returns an error page instead of the data and the function returns an empty data frame with a warning that says why. The limit is usually lifted within 24 hours.

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.

sheet_id: str = "10sOryk_ddjkXagaajTKUk1nwJs2ZLRiI"
The Google Drive file ID of the wide CSV of monthly long-short returns. The default, ‘10sOryk_ddjkXagaajTKUk1nwJs2ZLRiI’, is the October 2025 release (v2.0.0). Pass the ID of another release to download it instead.

Returns

pl.DataFrame
A data frame containing the processed data. The column names are converted to snake_case, the ‘date’ column is aligned to the beginning of the month, all predictor columns (long-short returns in percent) are divided by 100 to obtain plain numeric (decimal) returns, and the data is filtered by the specified date range if ‘start_date’ and ‘end_date’ are provided.

Examples

from tidyfinance import download_data
osap = download_data(
    'Open Source Asset Pricing',
    start_date='2020-01-01',
    end_date='2020-06-30',
)