Class FactorReturns

java.lang.Object
com.quantfinlib.alpha.FactorReturns

public final class FactorReturns extends Object
Factor return streams built from the library's own factors, the input AlphaReport.attribute(double[], double[][], List) regresses a portfolio on.

longShort(AlphaContext, AlphaFactor, int, int, int) is the Fama-French style construction: on each rebalance date sort the active cross-section by score, buy the top quantile and sell the bottom quantile equal-weighted, then hold both legs buy-and-hold until the next rebalance (weights drift with prices; no free daily rebalancing). The factor return of bar t is r_long(t) − r_short(t), each leg's return being the change in the leg's value since the previous bar. Returns are terminal-event aware through AlphaContext.returnOver(int, int, int): a name that delists mid-hold contributes its delisting return and is then held as cash.

  • Method Details

    • longShort

      public static double[] longShort(AlphaContext ctx, AlphaFactor factor, int startIndex, int quantiles, int rebalanceEvery)
      Per-bar long-short factor returns over (t, t+1] for t = startIndex .. bars−2, so the result has bars − 1 − startIndex entries. Bars before the first scored rebalance return 0.
      Parameters:
      quantiles - number of buckets (5 = top minus bottom quintile)
      rebalanceEvery - bars between re-sorts