Class ConstrainedPortfolioOptimizer

java.lang.Object
com.quantfinlib.optimization.ConstrainedPortfolioOptimizer

public final class ConstrainedPortfolioOptimizer extends Object
Constrained long-only optimiser: per-asset weight bounds (position caps and floors) and an optional turnover penalty against current holdings, adjusted return = μ'w − τ·Σ|w − w_current|, so the optimiser trades expected gain against the cost of getting there. Both problems are solved exactly with QuadraticProgram; turnover is linearised by the split w − w_current = u − v, u, v ≥ 0.
  • maxSharpe(double): max (μ'w − τ·T(w) − r_f)/√(w'Σw) over the bounded simplex, through the homogenisation y = κ·w of the linear-fractional program (Cornuéjols and Tütüncü 2007, §8.2): min y'Σy s.t. μ'y − τ·1'(u+v) − r_f·κ = 1, 1'y = κ, y − u + v = κ·w_current, κ·lo ≤ y ≤ κ·hi, u, v, κ ≥ 0.
  • minVolatility(): min √(w'Σw) + τ·T(w). Without a penalty this is the minimum-variance QP. With one, the optimum solves the QP min ½w'Σw + η·T(w) at η = τ·σ(w*) (equal first-order conditions); η is found by bisection.
  • Constructor Details

    • ConstrainedPortfolioOptimizer

      public ConstrainedPortfolioOptimizer(double[] expectedReturns, double[][] covariance)
  • Method Details

    • withBounds

      public ConstrainedPortfolioOptimizer withBounds(double[] min, double[] max)
      Per-asset weight bounds; must admit a fully-invested portfolio.
    • withTurnoverPenalty

      public ConstrainedPortfolioOptimizer withTurnoverPenalty(double[] currentWeights, double penaltyPerUnitTurnover)
      Adds a turnover penalty relative to the current weights.
      Parameters:
      penaltyPerUnitTurnover - expected-return units charged per unit of one-way turnover (e.g. transaction cost), ≥ 0
    • maxSharpe

      public PortfolioOptimizer.Allocation maxSharpe(double riskFreeRate)
    • minVolatility

      public PortfolioOptimizer.Allocation minVolatility()