numeraire.core.sorts#

Portfolio sorts — the cross-sectional decile-sort constructor (anomaly / characteristic sorts).

At each date, assets are ranked on a signal into n_bins portfolios and each portfolio’s return is a (value- or equal-) weighted average; the long-short is the extreme-bin spread. The one subtlety that matters for reproducing published anomaly returns is the breakpoint universe: NYSE-style breakpoints are computed on a subset (e.g. NYSE stocks) but applied to the full cross-section, so the many small NASDAQ names don’t drag the cutoffs down. Pass breakpoint_universe to enable this; leave it None for name-count (all-stock) breakpoints.

signal and returns are already aligned: returns.loc[t] is the return earned over the holding period by the position formed from signal.loc[t] (the engine / caller owns the PIT lag).

sort_portfolios

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

SortResult

Per-period sorted-portfolio returns plus the long-short spread.