download_factor_library_ids: Download factor library returns for a vector of portfolio IDs

View source: R/download_data_huggingface.R

download_factor_library_idsR Documentation

Download factor library returns for a vector of portfolio IDs

Description

Given a vector of portfolio IDs from the tidy-finance/factor-library-grid Hugging Face dataset, downloads the corresponding return data from the tidy-finance/factor-library dataset on Hugging Face. The function identifies the unique ⁠(sorting_variable, sorting_variable_lag, sorting_method, n_portfolios_main)⁠ combinations for the requested IDs, downloads one parquet file per combination in full, and then inner-joins to retain only the requested IDs. The grid metadata is joined back onto the result.

Usage

download_factor_library_ids(ids)

Arguments

ids

Integer or numeric vector of portfolio IDs to download. IDs correspond to rows of the tidy-finance/factor-library-grid dataset.

Details

Use this function when you already know the portfolio IDs you want (for example, from a previous call to download_data_huggingface() with dataset = "factor_library"). To resolve IDs from filter criteria (sorting variable, weighting scheme, breakpoints, etc.) and download in a single call, use download_data_huggingface() instead.

Raises an error if ids is empty or contains IDs that cannot be matched to a parquet file (listing the affected IDs and their key columns).

Value

A tibble of portfolio returns with the grid metadata columns for the requested IDs appended.

See Also

Other download functions: download_data(), 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()

Examples

## Not run: 
  download_factor_library_ids(c(1L, 2L, 3L))

## End(Not run)

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