Skip to main content

download_open_source.download_data_factors_q()

Download and process Global Q factor data.

Usage

Source

download_open_source.download_data_factors_q(
    dataset=None,
    start_date=None,
    end_date=None,
    type=None,
    url="https://global-q.org/uploads/1/2/2/6/122679606/"
)

Downloads and processes Global Q factor data based on the specified dataset, date range, and source URL. The processing includes date conversion, renaming variables to a standardized format, scaling factor values, and filtering by the specified date range.

Parameters

dataset: str = None

The name of the dataset to download. Recognized prefixes are ‘q5_factors_daily’, ‘q5_factors_weekly’, ‘q5_factors_weekly_w2w’, ‘q5_factors_monthly’, ‘q5_factors_quarterly’, and ‘q5_factors_annual’. Pass an explicit year suffix to pin the vintage (e.g., ‘q5_factors_daily_2024’). If only the bare prefix is supplied, the 2024 vintage is appended as a default; any other dataset without a recognized prefix raises ‘ValueError’.

start_date: str = None

A character string or date in ‘YYYY-MM-DD’ format specifying the start date for the data. If not provided, the full dataset is returned.

end_date: str = None

A character string or date in ‘YYYY-MM-DD’ format specifying the end date for the data. If not provided, the full dataset is returned.

type: str = None

Deprecated. Use ‘dataset’ instead. If supplied, the value is translated to a dataset name via ‘list_supported_datasets’ and a DeprecationWarning is emitted.

url: str = "https://global-q.org/uploads/1/2/2/6/122679606/"
The base URL from which to download the dataset files.

Returns

pl.DataFrame
A data frame with processed factor data, including the date, risk-free rate, market excess return, and other factors, filtered by the specified date range.

Examples

from tidyfinance import download_data_factors_q
download_data_factors_q(
    'q5_factors_daily_2024', '2020-01-01', '2020-12-31'
)
download_data_factors_q('q5_factors_annual_2024')