Class IndexConstruction
java.lang.Object
com.quantfinlib.markets.IndexConstruction
INDEX construction — the arithmetic behind "the market was up 1%".
Three weighting schemes produce three different markets from the same
stocks:
- cap-weighted (S&P 500 style): weight = float-adjusted market cap share. Self-rebalancing under price moves (a stock that doubles doubles its own weight — no trading needed), which is why cap-weight is the lowest-turnover scheme and the natural benchmark;
- price-weighted (Dow style): weight = price share. A $400 stock moves the index 8x as much as a $50 stock regardless of company size — a historical accident kept alive by tradition;
- equal-weighted: constant 1/N. Systematically tilts small and must TRADE every rebalance to stay equal — the turnover is the price of the tilt.
The DIVISOR is how a level series survives membership and
share changes: level = sum(price * shares * float) / divisor.
When a member is added, dropped or re-floated, the divisor is rescaled
so the level is CONTINUOUS through the change —
newDivisor = oldDivisor * newAggregate / oldAggregate — so the
index only ever moves for price reasons (pinned by test: a member swap
leaves the level unchanged at the instant of the swap).
turnover(w1, w2) = 0.5 * sum |w1 - w2| is the one-way fraction
of the portfolio that must trade between two weight vectors — the
index-tracking cost driver. Research lane, deterministic.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleadjustDivisor(double oldDivisor, double oldAggregate, double newAggregate) The rescaled divisor that keeps the level CONTINUOUS through a membership/share/float change: pass the aggregate cap before and after the change (both at the same instant).static double[]capWeights(double[] prices, double[] shares, double[] floatFactors) Float-adjusted cap weights:w_i ∝ price_i * shares_i * float_i.static double[]equalWeights(int n) Equal weights, 1/N.static doublelevel(double[] prices, double[] shares, double[] floatFactors, double divisor) Index level from an aggregate and a divisor.static double[]priceWeights(double[] prices) Price weights:w_i ∝ price_i(the Dow's accident).static doubleturnover(double[] from, double[] to) One-way turnover between two aligned weight vectors:0.5 * sum|w1-w2|.
-
Method Details
-
capWeights
public static double[] capWeights(double[] prices, double[] shares, double[] floatFactors) Float-adjusted cap weights:w_i ∝ price_i * shares_i * float_i. -
priceWeights
public static double[] priceWeights(double[] prices) Price weights:w_i ∝ price_i(the Dow's accident). -
equalWeights
public static double[] equalWeights(int n) Equal weights, 1/N. -
level
public static double level(double[] prices, double[] shares, double[] floatFactors, double divisor) Index level from an aggregate and a divisor. -
adjustDivisor
public static double adjustDivisor(double oldDivisor, double oldAggregate, double newAggregate) The rescaled divisor that keeps the level CONTINUOUS through a membership/share/float change: pass the aggregate cap before and after the change (both at the same instant). -
turnover
public static double turnover(double[] from, double[] to) One-way turnover between two aligned weight vectors:0.5 * sum|w1-w2|.
-