Skip navigation links

Package tech.nmfin.portfoliooptimization.markowitz

Mean-variance portfolio construction from supplied return and covariance estimates.

See: Description

Package tech.nmfin.portfoliooptimization.markowitz Description

Mean-variance portfolio construction from supplied return and covariance estimates.

Prepare consistent estimates

Choose an ordered asset list and retain it for the expected-return vector, covariance rows/columns, bounds and reported weights. Supply fractional returns for a common horizon; for example 0.08 is eight percent, and covariance is in squared-return units. A benchmark used for Sharpe calculations uses that same horizon.

These optimizers take estimated future moments. They do not obtain prices, align calendars, forecast moments, correct look-ahead bias or estimate trading costs. Use only information available at the rebalance time when evaluating historical decisions. Estimation quality and covariance conditioning remain caller responsibilities.

Construct, solve, inspect

  1. Create MarkowitzByQP with explicit weight bounds or a constraint object.
  2. Request a positive risk-aversion coefficient. This runs the optimization; construction alone does not produce weights.
  3. Check the sum-to-one budget, all bounds and every additional constraint.
  4. Evaluate the returned weights independently with PortfolioUtils.

The objective is \(q w^{\mathsf T}\Sigma w-\mu^{\mathsf T}w\). The fw() method returns this minimized value, not its negative utility. Variance and volatility are different quantities. The budget equality is added automatically; componentwise bound constraints alone do not encode the budget.

Frontiers and repeated rebalancing

Changing q solves again and replaces the stored portfolio. Retain the weights and independently calculated metrics for each successful frontier point. Check necessary bound feasibility (lower sum at most one, upper sum at least one) before solving. If a solve fails, reject that point rather than labeling old weights as a new solution. A frontier is not a backtest: apply the trading calendar, realized returns, turnover and costs in a separate evaluation layer.

Skip navigation links

Copyright © 2010-2026 NM Group. All Rights Reserved.