| Title: | Download Open Source Asset Pricing (OpenAP) Data Directly |
| Version: | 0.2.0 |
| Description: | Convenient download functions enabling access Open Source Asset Pricing (OpenAP) data. This package enables users to download predictor portfolio returns (over 200 cross-sectional predictors with multiple portfolio construction methods) and firm characteristics (over 200 characteristics replicated from the academic asset pricing literature). Center for Research in Security Prices (CRSP)-based variables such as Price, Size, and Short-term Reversal can be downloaded with a Wharton Research Data Services (WRDS, https://wrds-www.wharton.upenn.edu/) subscription. For a full list of what is available, see https://www.openassetpricing.com/. Data are read from the OpenAP Hugging Face dataset https://huggingface.co/datasets/OpenSourceAP/CrossSection, which holds data releases from 2020 onward. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Depends: | R (≥ 4.1.0) |
| Imports: | httr, curl, jsonlite, nanoparquet, dplyr, R6, DBI, RPostgres, getPass |
| NeedsCompilation: | no |
| Packaged: | 2026-10-26 11:53:15 UTC; Tom |
| Author: | Tom Zimmermann |
| Maintainer: | Tom Zimmermann <tom.zimmermann@uni-koeln.de> |
| Repository: | CRAN |
| Date/Publication: | 2026-10-26 13:10:15 UTC |
OpenAP Download
Description
Provides access to data from the Open Source Asset Pricing (OpenAP) project directly in R. The package enables users to access two primary types of data:
-
Predictor Portfolio Returns:
Access 212 cross-sectional predictors.
Download portfolio returns using various portfolio construction methods, including original paper methods, deciles, quintiles, equal-weighted, value-weighted, price filters and more.
-
Firm Characteristics:
Access 209 firm characteristics from OpenAP (+ 3 additional characteristics from CRSP (Price, Size, Short-term Reversal)).
Data are read from the OpenAP Hugging Face dataset (https://huggingface.co/datasets/OpenSourceAP/CrossSection), where each data release is a branch. Releases 2020.05 through 2026.10 are available; 2026.10 is the default.
Learn more about OpenAP: Data website | GitHub code | Publication: doi:10.1561/104.00000112
Public fields
name_id_mapA mapping between dataset names and their download URLs for the selected release.
individual_signal_id_mapKept for backward compatibility. Signals are now read from the release's firm characteristics file, so this is an empty data frame.
signal_signThe signal documentation (
SignalDoc.csv) of the release, including the sign of each signal. Empty for releases withoutSignalDoc.csv(2021.04 and earlier).urlThe Hugging Face URL of the selected release.
release_idThe selected release, e.g.
"2025_10".hf_revisionThe Hugging Face branch of the selected release, e.g.
"2025.10".mockLogical; if TRUE, network calls are skipped and mock data is returned for all download functions
Methods
Public methods
Method new()
Initializes the OpenAP class instance with data for the specified release (or per default with the 2026.10 release). Loads the release's file list and signal documentation.
Usage
OpenAP$new(release_year = NULL, mock = FALSE)
Arguments
release_yearOptional release identifier, e.g.
"2024_08". Accepts"2024.08"too."2023"and"2022"are the 2023.08 and 2022.03 releases.mockLogical; if TRUE, network initialization is skipped and small mock datasets are returned instead of downloading data. This is intended for examples, testing, and offline use.
Examples
# Offline example
obj <- OpenAP$new(mock = TRUE)
# Real initialization (requires internet connection)
\dontrun{
openap <- OpenAP$new()
openap_24 <- OpenAP$new(release_year = "2024_10")
}
Method list_port()
Returns a list of available portfolio types for the OpenAP dataset, depending on the specified release year.
Usage
OpenAP$list_port()
Examples
# List available portfolios (offline example)
openap <- OpenAP$new(mock = TRUE)
openap$list_port()
# Real usage (internet connection required)
\dontrun{
openap <- OpenAP$new()
openap$list_port()
}
Method get_url()
Retrieves the URL for a specific dataset based on its name.
Usage
OpenAP$get_url(data_name)
Arguments
data_nameThe name of the Portfolio.
Method get_urls()
Retrieves the URLs for a dataset. Unsigned firm characteristics are two files in the 2020 releases; every other dataset is one file.
Usage
OpenAP$get_urls(data_name)
Arguments
data_nameThe name of the dataset.
Method dl_port()
Downloads portfolio data for a specified data set and optionally filters by predictor.
Usage
OpenAP$dl_port(data_name, predictor = NULL)
Arguments
data_nameThe name of the data set.
predictorA vector of predictor names to filter (optional).
Examples
# Download entire portfolio file (offline example)
openap <- OpenAP$new(mock = TRUE)
df <- openap$dl_port("op")
# Download with specific predictor(s) only
df <- openap$dl_port("op", predictor = "Accruals")
# Real usage (internet connection required)
\dontrun{
openap <- OpenAP$new()
df <- openap$dl_port("op", predictor = "Accruals")
df <- openap$dl_port("op", predictor = c("Accruals", "Mom12m"))
}
Method dl_signal_crsp3()
Is being used in "dl_signal()" to download CRSP signals. Requires WRDS credentials.
Reads the CRSP CIZ monthly stock file (crsp.msf_v2).
Usage
OpenAP$dl_signal_crsp3(
requested_crsp_signals = c("Price", "Size", "STreversal"),
signed = TRUE
)Arguments
requested_crsp_signalsA vector of CRSP signals to download.
signedLogical; if TRUE (default), signals are signed (
Price = -log(|prc|)etc.).
Method merge_crsp_with_signals()
Merges downloaded OpenAP firm-level signals with CRSP-based signals (e.g., Size, Price, STreversal).
Usage
OpenAP$merge_crsp_with_signals(signals, crsp_data)
Arguments
signalsData frame containing OpenAP firm-level signals with columns
permnoandyyyymm.crsp_dataData frame containing CRSP signals (e.g., Size, Price) with columns
permnoandyyyymm.
Method dl_signal()
Downloads specific firm characteristics. Only the requested columns of the release's firm characteristics file are downloaded.
Usage
OpenAP$dl_signal(predictor = NULL, signed = FALSE)
Arguments
predictorA vector of predictor names to download.
signedLogical; if TRUE, signals are signed so that high values predict high returns (the release's
signed_predictors_dl_widefile). If FALSE (default), signals are as constructed (Predictors). CRSP signals follow the same choice.
Returns
A data frame containing the signal data.
Examples
# Download firm characteristics (offline example)
openap <- OpenAP$new(mock = TRUE)
# Single signal (OpenAP or WRDS)
df <- openap$dl_signal("BM")
# Multiple signals
df <- openap$dl_signal(c("BM", "STreversal"))
# Real usage (requires internet connection)
\dontrun{
openap <- OpenAP$new()
df <- openap$dl_signal("BM")
df <- openap$dl_signal(c("BM", "STreversal"))
df <- openap$dl_signal("BM", signed = TRUE)
}
Method signal_urls()
Retrieves the URLs of the firm characteristics file(s) of the release.
Usage
OpenAP$signal_urls(signed)
Arguments
signedLogical; signed or unsigned characteristics.
Method dl_all_signals()
Downloads all firm level characteristics from the release folder.
Usage
OpenAP$dl_all_signals(signed = TRUE)
Arguments
signedLogical; whether signals are signed so that high values predict high returns. Default is TRUE, the release's
signed_predictors_dl_widefile. The 2020 releases have unsigned signals only.
Returns
A data frame containing all firm level characteristics.
Examples
# Download all signals (offline example)
openap <- OpenAP$new(mock = TRUE)
signals_data <- openap$dl_all_signals()
# Real usage (requires internet connection)
\dontrun{
openap <- OpenAP$new()
signals_data <- openap$dl_all_signals()
}
Method dl_signal_doc()
Downloads the signal documentation CSV for the release.
Usage
OpenAP$dl_signal_doc()
Returns
A data frame containing the signal documentation.
Examples
# Load signal documentation (offline example)
openap <- OpenAP$new(mock = TRUE)
signal_doc <- openap$dl_signal_doc()
# Real usage (requires internet connection)
\dontrun{
openap <- OpenAP$new()
signal_doc <- openap$dl_signal_doc()
}
Method clone()
The objects of this class are cloneable with this method.
Usage
OpenAP$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
## ------------------------------------------------
## Method `OpenAP$new`
## ------------------------------------------------
# Offline example
obj <- OpenAP$new(mock = TRUE)
# Real initialization (requires internet connection)
## Not run:
openap <- OpenAP$new()
openap_24 <- OpenAP$new(release_year = "2024_10")
## End(Not run)
## ------------------------------------------------
## Method `OpenAP$list_port`
## ------------------------------------------------
# List available portfolios (offline example)
openap <- OpenAP$new(mock = TRUE)
openap$list_port()
# Real usage (internet connection required)
## Not run:
openap <- OpenAP$new()
openap$list_port()
## End(Not run)
## ------------------------------------------------
## Method `OpenAP$dl_port`
## ------------------------------------------------
# Download entire portfolio file (offline example)
openap <- OpenAP$new(mock = TRUE)
df <- openap$dl_port("op")
# Download with specific predictor(s) only
df <- openap$dl_port("op", predictor = "Accruals")
# Real usage (internet connection required)
## Not run:
openap <- OpenAP$new()
df <- openap$dl_port("op", predictor = "Accruals")
df <- openap$dl_port("op", predictor = c("Accruals", "Mom12m"))
## End(Not run)
## ------------------------------------------------
## Method `OpenAP$dl_signal`
## ------------------------------------------------
# Download firm characteristics (offline example)
openap <- OpenAP$new(mock = TRUE)
# Single signal (OpenAP or WRDS)
df <- openap$dl_signal("BM")
# Multiple signals
df <- openap$dl_signal(c("BM", "STreversal"))
# Real usage (requires internet connection)
## Not run:
openap <- OpenAP$new()
df <- openap$dl_signal("BM")
df <- openap$dl_signal(c("BM", "STreversal"))
df <- openap$dl_signal("BM", signed = TRUE)
## End(Not run)
## ------------------------------------------------
## Method `OpenAP$dl_all_signals`
## ------------------------------------------------
# Download all signals (offline example)
openap <- OpenAP$new(mock = TRUE)
signals_data <- openap$dl_all_signals()
# Real usage (requires internet connection)
## Not run:
openap <- OpenAP$new()
signals_data <- openap$dl_all_signals()
## End(Not run)
## ------------------------------------------------
## Method `OpenAP$dl_signal_doc`
## ------------------------------------------------
# Load signal documentation (offline example)
openap <- OpenAP$new(mock = TRUE)
signal_doc <- openap$dl_signal_doc()
# Real usage (requires internet connection)
## Not run:
openap <- OpenAP$new()
signal_doc <- openap$dl_signal_doc()
## End(Not run)