portfolios.filter_options()

Create filter options for sample construction.

Usage

Source

portfolios.filter_options(
    exclude_financials=False,
    exclude_utilities=False,
    min_stock_price=None,
    min_size_quantile=None,
    min_listing_age=None,
    exclude_negative_book_equity=False,
    exclude_negative_earnings=False,
    **kwargs
)

Creates a dict of filter options used for sample construction in tidyfinance-related functions. These options control which observations are retained before portfolio sorting.

Parameters

exclude_financials: bool = False

Whether to exclude financial firms (SIC codes 6000 to 6799).

exclude_utilities: bool = False

Whether to exclude utility firms (SIC codes 4900 to 4999).

min_stock_price: float = None

Minimum stock price required to include an observation. Must be strictly positive when provided. None (the default) applies no price filter.

min_size_quantile: float = None

Minimum cross-sectional size quantile (based on lagged market cap) required to include an observation. Must be strictly between 0 and 1 when provided. The cutoff is computed from NYSE stocks only; this requires an ‘exchange’ column in the data (as mapped via ‘data_options’). None (the default) applies no size quantile filter.

min_listing_age: float = None

Minimum number of months a stock must have been listed in CRSP. Must be non-negative when provided. None (the default) applies no listing age filter.

exclude_negative_book_equity: bool = False

Whether to exclude observations with non-positive book equity.

exclude_negative_earnings: bool = False

Whether to exclude observations with non-positive earnings.

**kwargs
Additional optional arguments, stored verbatim in the dict.

Returns

dict
Dict containing the specified filter options.

Examples

from tidyfinance import filter_options
filter_options(
    exclude_financials=True,
    exclude_utilities=True,
    min_stock_price=1,
    min_listing_age=12,
)