← Back to articles
May 22, 2026
5 min read

12 Portfolio Optimization Algorithms, Compared: HRP, Black-Litterman, NCO and Beyond

12 Portfolio Optimization Algorithms, Compared: HRP, Black-Litterman, NCO and Beyond
#portfolio optimization
#hierarchical risk parity
#HRP
#mean-variance
#Black-Litterman
#NCO
#risk parity
#Rust
#quantitative finance
#asset allocation

Every portfolio optimizer answers the same question: given the price histories of a handful of assets, what fraction of capital should sit in each one? The catch is that there is no single correct answer — only a family of answers, each one the product of a different assumption about how markets behave and how much you trust your own estimates.

So instead of betting on one method, we built a tool that runs twelve of them side by side, all behind a single interface, and lets you watch them disagree on real data. It is open source, written in Rust, and live at portfolio-optimizer.marketmaker.cc. This post is the map: what each algorithm believes, where the math comes from, and what happens when you point all twelve at the same basket of crypto.

One interface, twelve opinions

Every algorithm in the project exposes exactly the same function signature:

pub fn optimize(prices: &[Vec<f64>]) -> Vec<f64>

Prices in, weights out. The weights are long-only, non-negative, and sum to 1.0. That uniformity is the whole point — it means you can swap Hierarchical Risk Parity for Mean-Variance Optimization without touching a single line of the calling code, and you can benchmark all of them on identical inputs. Each algorithm lives in its own crate (portfolio-hrp, portfolio-mvo, portfolio-nco, …) so you can depend on just the one you need.

Under the hood they could not be more different. Let's walk the families.

The classic: Mean-Variance Optimization (MVO)

This is where modern portfolio theory began — Harry Markowitz, 1952. MVO treats allocation as a constrained optimization: maximize expected return for a given level of risk. Formally, you solve

maxwwμγ2wΣws.t.iwi=1,wi0\begin{aligned} \max_{w} \quad & w^\top \mu - \frac{\gamma}{2}\, w^\top \Sigma w \\ \text{s.t.} \quad & \sum_i w_i = 1, \quad w_i \ge 0 \end{aligned}

where μ\mu is the vector of expected returns, Σ\Sigma is the covariance matrix, and γ\gamma is your risk aversion. When the inputs are good, MVO is unbeatable: it is, by construction, the efficient frontier.

The problem is the inputs are never good. Expected returns μ\mu are estimated from noisy history, and MVO is exquisitely sensitive to them — a tiny change in an estimate can swing the allocation from 80% in one asset to 80% in another. Practitioners call it "error maximization": the optimizer happily pours capital into whichever asset's return was most over-estimated. MVO is the benchmark everyone measures against and the cautionary tale everyone cites.

The hierarchical family: HRP, HERC, GHRP, MHRP

In 2016 Marcos López de Prado proposed a different idea: don't invert the covariance matrix at all. Hierarchical Risk Parity (HRP) sidesteps MVO's instability by never solving the optimization problem directly. It works in three stages:

  1. Tree clustering — convert the correlation matrix into a distance metric, dij=12(1ρij)d_{ij} = \sqrt{\tfrac{1}{2}(1 - \rho_{ij})}, and build a hierarchy of assets so that similar assets sit on the same branch.
  2. Quasi-diagonalization — reorder the covariance matrix so correlated assets are adjacent, concentrating large values along the diagonal.
  3. Recursive bisection — split the tree top-down, allocating capital between the two halves in inverse proportion to their variance.

The result is a portfolio that respects the structure of the market — correlated assets compete with each other for weight, not with everything at once. HRP is dramatically more stable out-of-sample than MVO precisely because it never inverts an ill-conditioned matrix.

The project ships four members of this family:

  • HRP — the original López de Prado algorithm.
  • HERC (Hierarchical Equal Risk Contribution) — replaces the inverse-variance split with an equal-risk-contribution rule at each node, so every cluster contributes equally to total risk.
  • GHRP (Generalized HRP) — a parameterized generalization that lets you tune the clustering and allocation steps.
  • MHRP (Modified HRP) — a variant that adjusts the bisection weighting for heavier-tailed return distributions.

They are close cousins, but on real data they diverge meaningfully — which is exactly why having all four is useful.

Injecting a view: Black-Litterman

The Black-Litterman model (Goldman Sachs, 1990s) was built to fix MVO's most practical flaw: it forces you to supply expected returns for every asset, even ones you have no opinion about. Black-Litterman instead starts from a neutral market-implied equilibrium and lets you blend in your own views, weighted by how confident you are.

E[R]=[(τΣ)1+PΩ1P]1×[(τΣ)1Π+PΩ1Q]\begin{aligned} E[R] = {} & \big[(\tau\Sigma)^{-1} + P^\top \Omega^{-1} P\big]^{-1} \\ & \times \big[(\tau\Sigma)^{-1}\Pi + P^\top \Omega^{-1} Q\big] \end{aligned}

Here Π\Pi is the equilibrium return, PP and QQ encode your views ("asset A will outperform asset B by 2%"), and Ω\Omega is the uncertainty of those views. When you have no views, it collapses back to the market portfolio; when you are certain, it tilts hard toward your bets. It is the most opinion-aware of the twelve.

The hybrid: Nested Clustered Optimization (NCO)

NCO, also from López de Prado, is a clever marriage of the two worlds above. It clusters assets like HRP, then runs a small, well-conditioned Mean-Variance Optimization inside each cluster and again across clusters. By only ever inverting small, stable sub-matrices, NCO captures MVO's optimality where it is safe to use it, while avoiding the instability of inverting one giant covariance matrix. It is often the best of both behaviors.

The rest of the lineup

  • Entropy Pooling (Meucci) — a probabilistic framework that finds the distribution closest to your prior (by relative entropy) while satisfying a set of views as constraints. Elegant when you want to express uncertainty rather than point forecasts.
  • OLPS (Online Portfolio Selection) — a family of sequential strategies (universal portfolios, follow-the-winner, mean-reversion) that rebalance as new prices arrive, with provable regret bounds. The only genuinely online method in the set.
  • RBA (Robust Bayesian Allocation) — wraps the allocation in a Bayesian shrinkage layer, pulling noisy estimates toward a sensible prior so a single weird month can't dominate the weights.
  • TIC (Theory-Implied Correlation) — replaces the raw sample correlation matrix with one denoised against a theoretical structure (often an economic taxonomy), which can sharply improve hierarchical methods that feed on correlations.
  • Pipeline — our composite "house" algorithm: an HRP backbone with an optional long/short overlay and a CVaR (tail-risk) constraint. Through the uniform long-only optimize() entry point it behaves like HRP; its long/short and tail-risk machinery comes alive when you drive it with explicit signals.

What happens when you race all twelve

Here is the fun part. We pointed all twelve at a deliberately mixed basket — three strong winners (ZEC, Tether Gold, 1000RATS) and three heavy losers (FLOW, KAVA, LINEA) — over the window September 2025 to February 2026, and let each one allocate.

Algorithm Annualized return Sharpe
RBA +149%
MVO +74% 2.52
Entropy Pooling +57% 1.93
NCO +44%
HERC +30%
Black-Litterman +7%
OLPS −74%
MHRP −78%
GHRP −95%
HRP / Pipeline −103% −2.45
TIC −131%

A loud caveat before you read anything into this: these numbers come from one basket over one window, and the basket was rigged to contain extreme winners and losers on purpose. This is not a performance claim and absolutely not advice — it is a demonstration of behavioral divergence. Run it on your own assets and the ranking will reorder completely.

But the shape of the result is the lesson. The return-seeking methods — MVO, RBA, Entropy Pooling, NCO — concentrated capital into the winners and printed strong positive returns. The pure risk-parity methods — HRP, TIC, MHRP, GHRP — spread weight evenly for diversification's sake, which meant holding the losers too, and went negative. Neither behavior is "wrong." Risk parity is built to survive when you can't tell winners from losers in advance; on a basket where the future was rigged to be knowable, it pays the price for its humility. That tension — concentration versus diversification, conviction versus robustness — is the entire field in one table.

Open source and live

The whole thing is open: twelve Rust algorithm crates as git submodules, an Axum HTTP backend that dispatches all of them, and a Next.js front end with an interactive efficient-frontier chart and a side-by-side comparison table. You can:

  • try it live at portfolio-optimizer.marketmaker.cc — pick assets, a date range, and an algorithm, and watch the weights and frontier update;
  • open the Compare Methods tab to run all twelve on identical prices at once;
  • depend on any single crate (portfolio-hrp, portfolio-nco, …) in your own Rust project.

Takeaways

  1. There is no universal best optimizer. The right choice depends on how much you trust your return estimates. Trust them → MVO/Black-Litterman. Don't → HRP and friends.
  2. MVO is optimal and fragile. It defines the efficient frontier but maximizes estimation error. Treat its weights with suspicion unless your inputs are genuinely reliable.
  3. Hierarchical methods trade peak performance for stability. They rarely top a single backtest but rarely blow up either — which is what actually matters when the future is unknown.
  4. A uniform interface is a superpower. Once every algorithm is prices -> weights, comparing them honestly costs nothing, and switching is free.

The best way to understand twelve algorithms is to watch them argue. Go run the comparison on assets you actually care about.

References

  1. Markowitz, H. (1952). Portfolio Selection. The Journal of Finance.
  2. López de Prado, M. (2016). Building Diversified Portfolios that Outperform Out of Sample. The Journal of Portfolio Management.
  3. López de Prado, M. (2020). Machine Learning for Asset Managers. Cambridge University Press.
  4. Black, F., & Litterman, R. (1992). Global Portfolio Optimization. Financial Analysts Journal.
  5. Meucci, A. (2008). Fully Flexible Views: Theory and Practice. Risk.
  6. Marketmaker.cc: marketmaker.cc

Authors

Eugen Soloviov · suenot@gmail.com Trading-systems engineer building bots since 2017: cross-exchange arbitrage (connected up to 30 venues), cointegration-based pairs arbitrage across spot and futures, scalping, news and sentiment-driven strategies, trend algorithms, and portfolio management and balancing algorithms. Also builds sub-millisecond order execution, big-data warehouses, backtesting engines, AI agents, and trading interfaces (incl. open-source profitmaker.cc). Stack: JS/TS, Python, Rust/Zig/Go, DevOps, backend, frontend, architecture.

Marina Zhuravleva · marinade20p3@gmail.com Fifth-year student at Bauman Moscow State Technical University (Automatic Control Systems), specializing in financial mathematics. Background in calibrating stochastic-volatility (Heston) and local-volatility (Dupire) models, fair pricing of options including exotics via both Monte-Carlo and analytic formulas, hedging-error reduction, and exposure to LSV models.

Kirill Kiselev · kkiselev.nsk@gmail.com Fourth-year student at the Faculty of Mechanics and Mathematics, Novosibirsk State University (NSU); thesis on Heston-model calibration and delta-hedging within the same model. Works on portfolio optimization.


Citation

@article{soloviov2026portfoliooptimization,
  author = {Soloviov, Eugen and Zhuravleva, Marina and Kiselev, Kirill},
  title = {12 Portfolio Optimization Algorithms, Compared: HRP, Black-Litterman, NCO and Beyond},
  year = {2026},
  url = {https://marketmaker.cc/en/blog/post/portfolio-optimization-algorithms-compared},
  description = {A tour of twelve portfolio allocation algorithms — MVO, the hierarchical family (HRP, HERC, GHRP, MHRP), Black-Litterman, NCO, Entropy Pooling, OLPS, RBA, TIC and a composite pipeline — behind a single Rust interface, with an honest side-by-side comparison on a mixed crypto basket.}
}
Disclaimer: The information provided in this article is for educational and informational purposes only and does not constitute financial, investment, or trading advice. Trading cryptocurrencies involves significant risk of loss.

MarketMaker.cc Team

Quantitative Research & Strategy

Discuss in Telegram
Newsletter

Stay Ahead of the Market

Subscribe to our newsletter for exclusive AI trading insights, market analysis, and platform updates.

We respect your privacy. Unsubscribe at any time.