Class TurnoverAwareOptimizer

java.lang.Object
com.quantfinlib.alpha.TurnoverAwareOptimizer

public final class TurnoverAwareOptimizer extends Object
Turnover-penalised, constrained mean-variance optimiser solved by ADMM.
  maximise   αᵀw − λ·wᵀΣw − κ·‖w − w₀‖₁
  subject to A w = 0                       (dollar, sector, beta neutrality ...)
             −cap_i ≤ w_i ≤ cap_i          (position limits)
             |w_i − w₀,i| ≤ tradeLimit_i   (liquidity, for example a %ADV cap)

w₀ is the book currently held (drifted to today's prices), so turnover becomes a controlled input instead of a measured outcome: the L1 term charges κ per unit traded, and a name only moves when its marginal alpha net of risk exceeds κ. With linear costs in bps, κ is the one-way cost as a fraction (10 bps = 0.001) times whatever scaling the alpha vector carries.

Algorithm (Boyd, Parikh, Chu, Peleato and Eckstein 2011, Foundations and Trends in ML 3(1), §5.2, scaled form): split w = z with the smooth part and the equality constraints on w and the L1 term and boxes on z.

  • w-step: the equality-constrained quadratic [2λΣ + ρI, Aᵀ; A, 0][w; ν] = [α + ρ(z − u); 0], whose matrix is inverted once;
  • z-step: per coordinate, soft-threshold v = w + u around w₀ by κ/ρ, then clip to the intersection of the position and trade boxes (the exact minimiser of a one-dimensional convex function on an interval);
  • u ← u + w − z.

Stops when the primal residual ‖w − z‖ and the dual residual ρ‖z − z_prev‖ are both below tolerance·√n. The returned weights are z: they satisfy the boxes exactly and the equality constraints to within the reported residual. If the boxes and the equalities have no common point the iteration does not converge, and TurnoverAwareOptimizer.Result.converged() is false.

  • Method Details

    • optimize

      public static TurnoverAwareOptimizer.Result optimize(double[] alpha, double[][] covariance, double[] previous, double[][] equality, double[] caps, double[] tradeLimits, TurnoverAwareOptimizer.Settings settings)
      Solves the turnover-penalised mean-variance problem.
      Parameters:
      alpha - expected returns per name (no NaN; exclude names with cap 0)
      covariance - per-period covariance, symmetric positive semidefinite
      previous - current book w₀ (zeros for a fresh start)
      equality - rows of A (may be empty), each aligned with alpha
      caps - per-name |w| limit (≥ 0)
      tradeLimits - per-name |Δw| limit (≥ 0; Double.POSITIVE_INFINITY = none)