View source: R/download_data_huggingface.R
| download_data_huggingface | R Documentation |
Downloads data from a supported Hugging Face dataset. For
"high_frequency_sp500", parquet files are filtered by date range and
row-bound. For "factor_library", portfolio characteristics are selected via
filter_factor_library_grid(), the matching return data is downloaded, and
the result is filtered to start_date/end_date when both are supplied.
For "factor_library_grid", the grid itself is returned via
download_factor_library_grid().
download_data_huggingface(
dataset = NULL,
start_date = NULL,
end_date = NULL,
type = deprecated(),
...
)
dataset |
Character(1). The dataset to download. Supported values are
|
start_date |
Date or character. Start date (inclusive) in
|
end_date |
Date or character. End date (inclusive) in |
type |
|
... |
For |
Note on dataset = "factor_library" defaults: The defaults below reflect
one common portfolio construction choice, but may not suit every research
question. Always verify that the selected combination matches your intended
design.
Supported columns and their defaults for ...:
sorting_variable: Required. The firm characteristic used
to sort stocks into portfolios, named like the Open Source Asset
Pricing signals (e.g., "size" for market equity, "bm" for
book-to-market). See download_factor_library_grid() for all
values. No default is applied.
min_size_quantile (defaults to 0.2): Fraction of the smallest
stocks (by market cap) excluded from the portfolio universe. 0.2
drops the bottom 20%.
exclude_financials (defaults to FALSE): Whether to drop
financial-sector stocks (SIC 6000-6799) from the universe.
exclude_utilities (default: FALSE): Whether to drop
utility-sector stocks (SIC 4900-4999) from the universe.
exclude_negative_earnings (defaults to FALSE): Whether to
drop firms with negative earnings before sorting.
sorting_variable_lag (defaults to "6m"): Lag applied to the
sorting variable before portfolio assignment: "1m" (the timing of
Open Source Asset Pricing), "3m", "6m", or "ff"
(Fama-French).
rebalancing (defaults to "monthly"): How frequently portfolios
are reformed: "monthly" or "annual".
n_portfolios_main (defaults to 10): Number of quantile groups
(e.g., 10 for decile portfolios).
sorting_method (defaults to "univariate"): Whether portfolios
are formed on a single sort ("univariate") or on a double sort with
size as the second variable ("bivariate-dependent" or
"bivariate-independent").
n_portfolios_secondary (defaults to NULL): Number of size
groups for the secondary sort.
Required when sorting_method is not "univariate".
breakpoints_exchanges (defaults to: "NYSE"): Exchange(s) used
to compute breakpoints. "NYSE" uses only NYSE-listed stocks to
define quantile cutoffs (the conventional Fama-French approach).
breakpoints_min_size_threshold (defaults to NA): Minimum
size quantile of the stocks that set the main breakpoints (e.g.,
0.2). NA means no minimum-size screen is applied.
weighting_scheme (defaults to "VW"): Return weighting within
portfolios: "VW" for value-weighted, "EW" for equal-weighted, or
"capped VW" for value-weighted with capped weights.
A tibble with the downloaded data. For "high_frequency_sp500",
contains 5-second aggregated orderbook snapshots filtered to the requested
date range. For "factor_library", contains the columns id, date, and
ret joined with the full grid metadata for the matched portfolio IDs.
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_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(),
download_factor_library_ids()
## Not run:
download_data_huggingface(
"high_frequency_sp500", "2007-07-26", "2007-07-27"
)
download_data_huggingface(
"factor_library",
sorting_variable = "high52",
rebalancing = "annual"
)
download_data_huggingface(
"factor_library", sorting_variable = "assetgrowth", fill_all = TRUE
)
download_data_huggingface(
"factor_library",
sorting_variable = "size",
start_date = "2000-01-01",
end_date = "2020-12-31"
)
download_data_huggingface("factor_library", ids = c(1L, 2L, 3L))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.