fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Robust Mean-Variance

Install and import#

bash
npm install fintech-algorithms
ts
import { robustMeanVariance } from "fintech-algorithms/portfolio-construction/bayesian-and-robust-allocation/robust-mean-variance";

Signature#

robustMeanVariance(mean, covariance, uncertaintyShape, kappa, riskPenalty, maxIterations, tolerance)

Optimizes against an explicit ellipsoidal uncertainty set around the mean, so the robustness claim names the uncertainty it is built to survive.

Parameters#

NameTypeNotes
meanlength `n` vectordecimal return/period
covariance`n x n`return²/period
uncertaintyShapeMatrix
kappascalardimensionless radius
riskPenaltyunknown
maxIterationsunknown
toleranceunknown

Worked example#

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input#

mean
[0.09, 0.05]
covariance
[
  [0.04, 0],
  [0, 0.01]
]
uncertaintyShape
[
  [0.02],
  [-0.02]
]
kappa
1

Call#

robustMeanVariance(mean, covariance, uncertaintyShape, kappa, riskPenalty, maxIterations, tolerance)

Returns#

object with 10 fields: weights, nominalReturn, uncertaintyPenalty, robustReturn, variance, objective, worstCaseMean, iterations, …

{
  "weights": [0.5, 0.5],
  "nominalReturn": 0.07,
  "uncertaintyPenalty": 0,
  "robustReturn": 0.07,
  "variance": 0.0125,
  "objective": 0.05750000000000001,
  "worstCaseMean": [0.09, 0.05],
  "iterations": 1,
  "projectedGradientNorm": 0,
  "status": "optimal"
}

Diagrams#

Robust Mean-Variance — article hero

Calculation flow#

Diagram
flowchart TB
    N0[Declare the mean set] --> N1
    N1[Project exposure] --> N2
    N2[Find the worst mean] --> N3
    N3[Optimize on simplex] --> N4
    N4[Check stationarity]

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

  • Robust Portfolio Selection Problems — Donald Goldfarb and Garud Iyengar.
  • Robust Asset Allocation — Reha H. Tütüncü and Mark Koenig.
  • Estimation error and robust optimization — MOSEK ApS.
  • Ellipsoidal support function

The rest of the Bayesian and Robust Allocation family#