numeraire.sort_portfolios#

numeraire.sort_portfolios(signal: DataFrame, returns: DataFrame, *, n_bins: int = 10, breakpoint_universe: DataFrame | None = None, weights: DataFrame | None = None, direction: int = 1) SortResult[source]#

Cross-sectional n_bins sort of signal with per-period weighted portfolio returns.

signal / returns are (date x asset) and aligned (see module docstring). Breakpoints are the n_bins-quantiles of the signal over breakpoint_universe (a (date x asset) boolean mask, e.g. NYSE membership) when given, else over all valid names; every valid asset is then binned against those cutoffs. weights ((date x asset), e.g. market cap) gives value-weighting — omit for equal-weighting. direction (+1/-1) orients the long-short (+1 = long the top bin). Bins with no assets get a NaN return.