Skip to main content

download_wrds.download_data_wrds_compustat()

Download data from WRDS Compustat.

Usage

Source

download_wrds.download_data_wrds_compustat(
    dataset=None,
    start_date=None,
    end_date=None,
    type=None,
    additional_columns=None,
    only_usd=False,
    only_us=None,
    quiet=False
)

Downloads financial data from the WRDS Compustat database for a given dataset, start date, and end date. The function filters the data according to industry format, data format, and consolidation level, and returns the most current data for each reporting period. Additionally, the annual data also includes the calculated book equity (‘be’), operating profitability (‘op’), and investment (‘inv’) for each company following Fama and French (1993, 2015), as well as income before extraordinary items (‘ib’).

Parameters

dataset: str = None

The dataset to download (‘compustat_annual’ or ‘compustat_quarterly’).

start_date: str = None

A character string or date in ‘YYYY-MM-DD’ format specifying the start date for the data. If not provided, a subset of the 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, a subset of the dataset is returned.

type: str = None

Deprecated. Use ‘dataset’ instead. If supplied, a leading ‘wrds_’ prefix is stripped (e.g., ‘wrds_compustat_annual’ becomes ‘compustat_annual’) and a DeprecationWarning is emitted.

additional_columns: list of str = None

Additional columns from the Compustat table as a list of strings.

only_usd: bool = False

A boolean indicating whether only USD-denominated shares should be returned (i.e., excluding Canadian firms). Defaults to False.

only_us: bool = None

Deprecated. Use ‘only_usd’ instead. If supplied, the value is forwarded to ‘only_usd’ and a DeprecationWarning is emitted.

quiet: bool = False
If True, the messages about the WRDS connection and the download progress are suppressed. Defaults to False.

Returns

pl.DataFrame
A data frame with financial data for the specified period, including variables for book equity (‘be’), operating profitability (‘op’), investment (‘inv’), and others.

References

Fama, E. F., and French, K. R. (1993). Common risk factors in the returns on stocks and bonds. Journal of Financial Economics, 33(1), 3-56. https://doi.org/10.1016/0304-405X(93)90023-5

Fama, E. F., and French, K. R. (2015). A five-factor asset pricing model. Journal of Financial Economics, 116(1), 1-22. https://doi.org/10.1016/j.jfineco.2014.10.010

Examples

from tidyfinance import download_data_wrds_compustat
download_data_wrds_compustat(
    'compustat_annual', '2020-01-01', '2020-12-31'
)
download_data_wrds_compustat(
    'compustat_quarterly', '2020-01-01', '2020-12-31'
)
download_data_wrds_compustat(
    'compustat_annual', additional_columns=['aodo', 'aldo']
)