download_data: Download and Process Data Based on Domain and Dataset

View source: R/download_data.R

download_dataR Documentation

Download and Process Data Based on Domain and Dataset

Description

Downloads and processes data based on the specified domain (e.g., Fama-French factors, Global Q factors, or macro predictors), dataset, and date range. This function checks if the specified domain is supported and then delegates to the appropriate function for downloading and processing the data.

Usage

download_data(
  domain = NULL,
  dataset = NULL,
  start_date = NULL,
  end_date = NULL,
  type = deprecated(),
  ...
)

Arguments

domain

The domain of the dataset to download (e.g., "famafrench", "globalq", "macro_predictors", "wrds", "pseudo", "constituents", "fred", "stock_prices", "osap", "tidyfinance"). Use "pseudo" to obtain pseudo data with the same schema as "wrds" for testing or rendering without a WRDS subscription.

dataset

Optional. The specific dataset to download within the domain.

start_date

Optional. A character string or Date object in "YYYY-MM-DD" format specifying the start date for the data. If not provided, the full dataset or a subset is returned, depending on the dataset type.

end_date

Optional. A character string or Date object in "YYYY-MM-DD" format specifying the end date for the data. If not provided, the full dataset or a subset is returned, depending on the dataset type.

type

[Deprecated] Use domain and dataset instead.

...

Additional arguments passed to specific download functions depending on the domain. For instance, if domain is "constituents", arguments are passed to download_data_constituents(). If domain is "tidyfinance" and dataset is "factor_library", arguments are either filter inputs (e.g., sorting_variable, rebalancing, fill_all) or an explicit ids vector that bypasses the grid filter and downloads the specified portfolios directly via download_factor_library_ids(); see download_data_huggingface() for details.

Value

A tibble with processed data, including dates and the relevant financial metrics, filtered by the specified date range.

See Also

Other download functions: download_data_constituents(), download_data_factors_ff(), download_data_factors_q(), download_data_fred(), download_data_huggingface(), download_data_macro_predictors(), download_data_osap(), download_data_risk_free(), download_data_stock_prices(), download_factor_library_grid(), download_factor_library_ids()

Examples


download_data(
  "famafrench",
  "Fama/French 5 Factors (2x3) [Daily]",
  "2000-01-01",
  "2020-12-31"
)
download_data("macro_predictors", "monthly", "2000-01-01", "2020-12-31")
download_data("constituents", index = "DAX")
download_data("fred", series = c("GDP", "CPIAUCNS"))
download_data("stock_prices", symbols = c("AAPL", "MSFT"))
download_data(
  "tidyfinance",
  "risk_free",
  "2020-01-01",
  "2020-12-31"
)
download_data(
  "tidyfinance",
  "high_frequency_sp500",
  "2007-07-26",
  "2007-07-27"
)
download_data(
  "tidyfinance",
  "factor_library",
  sorting_variable = "52w",
  rebalancing = "annual"
)
download_data("tidyfinance", "factor_library", ids = c(1L, 2L, 3L))
download_data("tidyfinance", "factor_library_grid")


tidyfinance documentation built on June 1, 2026, 1:06 a.m.