portfolios.breakpoint_options()
Create breakpoint options for portfolio sorting.
Usage
portfolios.breakpoint_options(
n_portfolios=None,
percentiles=None,
breakpoints_exchanges=None,
smooth_bunching=False,
breakpoints_min_size_threshold=None,
**kwargs
)Generates a structured dict of options for defining breakpoints in portfolio sorting. It includes parameters for the number of portfolios, percentile thresholds, exchange-specific breakpoints, and smooth bunching, along with additional optional parameters.
Parameters
n_portfolios: int = None-
Number of portfolios to create. Must be a positive integer. If not provided, defaults to None.
percentiles: list of float = None-
Percentile thresholds for defining breakpoints. Each value must be between 0 and 1. If not provided, defaults to None.
breakpoints_exchanges: str or list of str = None-
Non-empty exchange (or list of exchanges) from which to compute the breakpoints. If not provided, defaults to None.
smooth_bunching: bool = False-
Indicates whether smooth bunching should be applied.
breakpoints_min_size_threshold: float = None-
When set to a value between 0 and 1, stocks with market capitalization below this quantile are excluded from breakpoint computation. The quantile is computed among ‘breakpoints_exchanges’ stocks if specified, otherwise among all stocks. Requires a market capitalization column in the data (see ‘data_options’). Defaults to None (no size filtering).
**kwargs- Additional optional arguments. These will be captured in the resulting structure as part of the dict.
Returns
dict- Dictionary containing the provided breakpoint options, including any additional arguments passed via ’**kwargs’.
Examples
from tidyfinance import breakpoint_options
# Quintile portfolios with NYSE breakpoints
breakpoint_options(
n_portfolios=5,
breakpoints_exchanges='NYSE',
)
# Custom percentile thresholds (mutually exclusive with n_portfolios)
breakpoint_options(
percentiles=[0.3, 0.7],
breakpoints_exchanges='NYSE',
)
# Exclude the smallest 20% of NYSE stocks from breakpoint computation
breakpoint_options(
n_portfolios=10,
breakpoints_exchanges='NYSE',
breakpoints_min_size_threshold=0.2,
)