Class FactorReturns
java.lang.Object
com.quantfinlib.alpha.FactorReturns
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 Summary
Modifier and TypeMethodDescriptionstatic double[]longShort(AlphaContext ctx, AlphaFactor factor, int startIndex, int quantiles, int rebalanceEvery) Per-bar long-short factor returns over(t, t+1]fort = startIndex .. bars−2, so the result hasbars − 1 − startIndexentries.
-
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]fort = startIndex .. bars−2, so the result hasbars − 1 − startIndexentries. Bars before the first scored rebalance return 0.- Parameters:
quantiles- number of buckets (5 = top minus bottom quintile)rebalanceEvery- bars between re-sorts
-