# Maximum Sharpe Ratio

`D14-F01-A03` · Portfolio Construction → Mean-Risk Optimization · archetype `record-transform` · difficulty 4/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/portfolio-construction/mean-risk-optimization/maximum-sharpe-ratio/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

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

## Signature

```ts
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

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `assetIdsInput` | `unique non-empty string array` | yes | identifier/order |
| `muInput` | `finite number array` | yes | simple return for one horizon |
| `covarianceInput` | `finite `N x N` number matrix` | yes | squared return |
| `riskFreeReturnInput` | `finite number` | yes | simple return for the same horizon |
| `options` | `{ maxIterations?: unknown; }` | no | default: "{}" |

## Worked example

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`:

```json
["A", "B"]
```

`muInput`:

```json
[0.08, 0.11]
```

`covarianceInput`:

```json
[
  [0.01, 0],
  [0, 0.0225]
]
```

`riskFreeReturnInput`:

```json
0.02
```

### Call

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

### Returns

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

```json
{
  "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.

## Verification and provenance

Tier: **contract**.

The module loads, the entry point is callable and its declared signature matches the compiled code. The example below is real captured output, but no independently published figure asserts the numbers.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.2.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/portfolio-construction/mean-risk-optimization/maximum-sharpe-ratio/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/portfolio-construction/mean-risk-optimization/maximum-sharpe-ratio/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/portfolio-construction/llms.txt
