Skip to content

Optimizers

The three portfolio optimizers — MSR (Max Sharpe), GMV (Min Variance), EW (Equal Weight) — what each maximizes, the weight constraints, and how the solver works.

Once a strategy has selected the top topN assets, the optimizer decides how much of each to hold. All optimizers produce weights that sum to 1 and respect the per-asset bounds minWeight / maxWeight (defaults 0.01 / 0.95).

OptimizerType = 'MSR' | 'GMV' | 'EW'.

MSR — Maximum Sharpe Ratio

Maximizes risk-adjusted return using expected returns and the covariance matrix:

max_w (wᵀμ − r_f) / √(wᵀ Σ w)
s.t.  Σw = 1,  minW ≤ w_i ≤ maxW

Guardrail: if no asset’s expected return clears the risk-free rate, every feasible portfolio has negative excess return and naively maximizing Sharpe would chase the riskiest asset. In that case MSR falls back to GMV (the rational risk-off portfolio). This is a deliberate behavior of the engine, not a bug.

GMV — Global Minimum Variance

Minimizes portfolio volatility, ignoring expected returns:

min_w √(wᵀ Σ w)

Implemented via the MSR solver with equal expected returns (when all expected returns are equal, maximizing Sharpe ≡ minimizing variance). Use it when you trust your covariance estimate more than your return estimate.

EW — Equal Weight

The simplest allocation: w_i = 1/N for every selected asset. No estimation, no solver — a strong, hard-to-beat baseline and a good control when comparing smarter optimizers in the Lab.

How the solver works

MSR and GMV use a projected gradient descent that stands in for scipy.optimize.minimize (SLSQP) in the Python original: it steps against the numerical gradient of the objective, then projects weights back onto the feasible set (clip to [minW, maxW], renormalize to sum 1) with an adaptive step size. It’s deterministic and runs in the browser. The same module can also trace the efficient frontier (efficientFrontier) for visualization.