Download factor library returns for a vector of portfolio IDs
Source:R/download_data_huggingface.R
download_factor_library_ids.RdGiven 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 returns are
stored in files of 1,000 consecutive IDs named after the range they cover
(e.g., id_0000001-0001000.parquet), so the function downloads only the
files that hold the requested IDs. The grid metadata is joined onto the
result.
Value
A tibble with the columns id, date, and ret (the monthly
long-short excess return) and the grid metadata columns for the
requested IDs.
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 none of the requested IDs exist in the grid. IDs whose
portfolio sort produced no portfolios have no returns; they are absent from
the result, with a warning, and the result has no rows if none of the
requested IDs has returns. Returns are stored in single precision, and
months without a valid long-short return are stored as 0.
See also
Other download functions:
download_data(),
download_data_constituents(),
download_data_factors_ff(),
download_data_factors_q(),
download_data_fred(),
download_data_fred_md(),
download_data_huggingface(),
download_data_jkp(),
download_data_macro_predictors(),
download_data_osap(),
download_data_pastor_stambaugh(),
download_data_risk_free(),
download_data_stambaugh_yuan(),
download_data_stock_prices(),
download_factor_library_grid()
Examples
if (FALSE) { # \dontrun{
download_factor_library_ids(c(1L, 2L, 3L))
} # }