numeraire.core.sorts.sort_portfolios#
- numeraire.core.sorts.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_binssort ofsignalwith per-period weighted portfolio returns.signal/returnsare(date x asset)and aligned (see module docstring). Breakpoints are then_bins-quantiles of the signal overbreakpoint_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.