rankΒΆ
Defined in fynance.signal
- rank(pred, top, bottom)[source]
Cross-sectional long/short by rank.
For each time step (row of a 2-D
(T, n_assets)prediction), go long thetophighest-ranked assets and short thebottomlowest, equally weighted within each leg (dollar-neutral).- Parameters:
- predarray-like, shape (T, n_assets)
Cross-sectional predictions.
- top, bottomint
Number of assets in the long and short legs.
- Returns:
- numpy.ndarray
Weights of shape
(T, n_assets).