Class PortfolioOptimizer
java.lang.Object
com.quantfinlib.optimization.PortfolioOptimizer
Portfolio Optimization Engine (long-only, fully invested).
Supports maximum-Sharpe and minimum-volatility portfolios plus efficient frontier construction. The optimizer uses stochastic search over the simplex (Dirichlet sampling) followed by deterministic pairwise-transfer refinement, which is robust for non-smooth objectives and needs no external solver. Results are deterministic for a given seed.
Expected returns and covariance must share the same periodicity (e.g. both annualized, or both daily).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAn optimized allocation with its risk/return profile (same periodicity as the inputs). -
Constructor Summary
ConstructorsConstructorDescriptionPortfolioOptimizer(double[] expectedReturns, double[][] covariance) PortfolioOptimizer(double[] expectedReturns, double[][] covariance, long seed) -
Method Summary
Modifier and TypeMethodDescriptionefficientFrontier(int points) Efficient frontier: minimum-volatility portfolios across a grid of target returns between the min and max asset expected returns.maxSharpe(double riskFreeRate) Maximum Sharpe ratio portfolio.Minimum volatility portfolio.static double[]rebalance(double[] currentWeights, double[] targetWeights) Rebalancing deltas: target minus current weights, per asset.
-
Constructor Details
-
PortfolioOptimizer
public PortfolioOptimizer(double[] expectedReturns, double[][] covariance) -
PortfolioOptimizer
public PortfolioOptimizer(double[] expectedReturns, double[][] covariance, long seed)
-
-
Method Details
-
maxSharpe
Maximum Sharpe ratio portfolio.riskFreeRatein the same periodicity as the inputs. -
minVolatility
Minimum volatility portfolio. -
efficientFrontier
Efficient frontier: minimum-volatility portfolios across a grid of target returns between the min and max asset expected returns. -
rebalance
public static double[] rebalance(double[] currentWeights, double[] targetWeights) Rebalancing deltas: target minus current weights, per asset.
-