The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Title: Download Open Source Asset Pricing (OpenAP) Data Directly
Version: 0.1.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/.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.2
Suggests: knitr, rmarkdown, testthat (≥ 3.0.0)
Config/testthat/edition: 3
Depends: R (≥ 4.1.0)
Imports: httr, rvest, stringr, jsonlite, magrittr, dplyr, data.table, R6, withr, lubridate, DBI, RPostgres, getPass
NeedsCompilation: no
Packaged: 2026-01-12 16:39:12 UTC; wme889
Author: Tom Zimmermann ORCID iD [aut, cre], Justus Boeker [ctb]
Maintainer: Tom Zimmermann <tom.zimmermann@uni-koeln.de>
Repository: CRAN
Date/Publication: 2026-01-17 19:50:13 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:

  1. 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.

  2. Firm Characteristics:

    • Access 209 firm characteristics from OpenAP (+ 3 additional characteristics from CRSP (Price, Size, Short-term Reversal)).

Learn more about OpenAP: Data website | GitHub code | Publication

Public fields

name_id_map

A mapping between names and their corresponding IDs in the OpenAP database.

individual_signal_id_map

A mapping of unique identifiers for individual signals.

signal_sign

The direction or "sign" of the signal (i.e. positive or negative).

url

The base URL for downloading OpenAP data.

mock

Logical; 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 year (or per default with the latest data). Loads mappings, individual signal IDs and signal documentation.

Usage
OpenAP$new(release_year = NULL, mock = FALSE)
Arguments
release_year

Optional release identifier, e.g. "2024_08".

mock

Logical; 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_name

The name of the Portfolio.


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_name

The name of the data set.

predictor

A 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 get_individual_signal_url()

Retrieves the URL for an individual signal based on its name.

Usage
OpenAP$get_individual_signal_url(signal_name)
Arguments
signal_name

The name of the signal to retrieve.

Returns

A string representing the URL of the signal.


Method dl_signal_crsp3()

Is being used in "dl_signal()" to download CRSP signals. Requires WRDS credentials.

Usage
OpenAP$dl_signal_crsp3(
  requested_crsp_signals = c("Price", "Size", "STreversal")
)
Arguments
requested_crsp_signals

A vector of CRSP signals to download.


Method apply_sign_logic()

applies the sign logic to the data based on the signal documentation.

Usage
OpenAP$apply_sign_logic(data, predictors, signal_sign, signed = TRUE)
Arguments
data

The data frame to apply the sign logic to.

predictors

A vector of predictor names.

signal_sign

A data frame containing the signal documentation.

signed

Logical; whether to apply signed transformation based on signal documentation. Default is TRUE.


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
signals

Data frame containing OpenAP firm-level signals with columns permno and yyyymm.

crsp_data

Data frame containing CRSP signals (e.g., Size, Price) with columns permno and yyyymm.


Method dl_signal()

Downloads specific firm characteristics.

Usage
OpenAP$dl_signal(predictor = NULL, signed = FALSE)
Arguments
predictor

A vector of predictor names to download.

signed

Logical; whether to apply signed transformation based on signal documentation.

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 = FALSE)
}

Method dl_all_signals()

Downloads all firm level characteristics from the release folder.

Usage
OpenAP$dl_all_signals(signed = FALSE)
Arguments
signed

Logical; whether to apply signed transformation based on signal documentation. Default is TRUE.

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
deep

Whether 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 = FALSE)

## 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)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.