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

Maximum Sharpe Ratio

Install and import#

bash
npm install fintech-algorithms
ts
import { maximumSharpe } from "fintech-algorithms/portfolio-construction/mean-risk-optimization/maximum-sharpe-ratio";

Signature#

maximumSharpe(assetIdsInput, muInput, covarianceInput, riskFreeReturnInput, options)

Finds the weights that maximize the Sharpe ratio for a declared risk-free return, with the benchmark, horizon and volatility denominator stated rather than implied.

Parameters#

NameTypeNotes
assetIdsInputunique non-empty string arrayidentifier/order
muInputfinite number arraysimple return for one horizon
covarianceInputfinite `N x N` number matrixsquared return
riskFreeReturnInputfinite numbersimple return for the same horizon
options{ maxIterations?: unknown; }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#

assetIdsInput
["A", "B"]
muInput
[0.08, 0.11]
covarianceInput
[
  [0.01, 0],
  [0, 0.0225]
]
riskFreeReturnInput
0.02

Call#

maximumSharpe(assetIdsInput, muInput, covarianceInput, riskFreeReturnInput, options)

Returns#

object with 20 fields: status, variant, method, branch, assetIds, mu, riskFreeReturn, weights, …

{
  "status": "optimal",
  "variant": "maximum-sharpe-long-only-pd",
  "method": "exhaustive-support-enumeration",
  "branch": "positive_excess_support",
  "assetIds": ["A", "B"],
  "mu": [0.08, 0.11],
  "riskFreeReturn": 0.02,
  "weights": [0.6, 0.4],
  "expectedReturn": 0.092,
  "excessReturn": 0.072,
  "variance": 0.0072000000000000015,
  "volatility": 0.08485281374238571,
  "sharpe": 0.8485281374238569,
  "budgetResidual": 0
}

Showing 14 of 20 fields.

Diagrams#

Maximum Sharpe Ratio — article hero
Maximum Sharpe Ratio — sharpe simplex

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#

  • Primary and official sources inspected
  • Google discovery audit
  • Related data-quality sources
  • Source roles
  • 2026-09-16

The rest of the Mean-Risk Optimization family#