Markowitz Mean-Variance
Install and import#
npm install fintech-algorithmsimport { markowitzMeanVariance } from "fintech-algorithms/portfolio-construction/mean-risk-optimization/markowitz-mean-variance";Signature#
markowitzMeanVariance(assetIdsInput, muInput, covarianceInput, targetReturnInput, options)Solves for the lowest-variance asset weights that still meet a declared return target, from expected returns and a covariance matrix.
Parameters#
| Name | Type | Notes |
|---|---|---|
assetIdsInput | ordered string array | One stable identifier per column/row |
muInput | finite number array | Expected return for one declared horizon |
covarianceInput | finite number matrix | Variance/covariance for that same horizon and return unit |
targetReturnInput | finite number | Same expected-return unit/horizon as mu |
options | MarkowitzOptions | optional |
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#
["A", "B"][0.06, 0.14][
[0.04, 0.01],
[0.01, 0.09]
]0.1{
"maxIterations": 10000
}Call#
markowitzMeanVariance(assetIdsInput, muInput, covarianceInput, targetReturnInput, options)Returns#
object with 21 fields: assetIds, mu, targetReturn, weights, expectedReturn, variance, volatility, budgetResidual, …
{
"assetIds": ["A", "B"],
"mu": [0.06, 0.14],
"targetReturn": 0.1,
"weights": [0.4999999999999999, 0.5000000000000001],
"expectedReturn": 0.1,
"variance": 0.037500000000000006,
"volatility": 0.19364916731037085,
"budgetResidual": 0,
"targetResidual": 0,
"lowerBoundResidual": 0,
"fwGapS": 0,
"fwGap": 0,
"matrixScale": 0.09,
"status": "optimal"
}Showing 14 of 21 fields.
Diagrams#
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.
References#
- Primary technical sources
- Input-lineage sources
- Contextual Google destinations inspected
- Citation boundaries
- 2026-09-16