Skip to main content
POST
/
quantlib
/
portfolio
/
optimize
/
max-sharpe
Maximum Sharpe Ratio Portfolio
curl --request POST \
  --url https://finceptbackend.share.zrok.io/quantlib/portfolio/optimize/max-sharpe \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "expected_returns": [
    0.08,
    0.12,
    0.1,
    0.15
  ],
  "covariance_matrix": [
    [
      0.04,
      0.006,
      0.008,
      0.01
    ],
    [
      0.006,
      0.09,
      0.012,
      0.015
    ],
    [
      0.008,
      0.012,
      0.0625,
      0.018
    ],
    [
      0.01,
      0.015,
      0.018,
      0.16
    ]
  ],
  "rf_rate": 0.03,
  "min_weights": [
    0,
    0,
    0,
    0
  ],
  "max_weights": [
    0.5,
    0.5,
    0.5,
    0.5
  ]
}
'
{
  "success": true,
  "data": {
    "weights": [
      0.25,
      0.35,
      0.3,
      0.1
    ],
    "expected_return": 0.1125,
    "volatility": 0.2156,
    "sharpe_ratio": 0.3826
  }
}

Authorizations

X-API-Key
string
header
required

API key for authentication. Get your key at https://finceptbackend.share.zrok.io/auth/register

Body

application/json
expected_returns
number[]
required

Expected returns for each asset (annualized)

Example:
[0.08, 0.12, 0.1, 0.15]
covariance_matrix
number[][]
required

Asset covariance matrix (annualized)

Example:
[
[0.04, 0.006, 0.008, 0.01],
[0.006, 0.09, 0.012, 0.015],
[0.008, 0.012, 0.0625, 0.018],
[0.01, 0.015, 0.018, 0.16]
]
rf_rate
number
default:0

Risk-free rate (annualized). Critical for Sharpe ratio calculation.

Example:

0.03

min_weights
number[] | null

Minimum weight constraints for each asset

Example:
[0, 0, 0, 0]
max_weights
number[] | null

Maximum weight constraints for each asset

Example:
[0.5, 0.5, 0.5, 0.5]

Response

Maximum Sharpe ratio portfolio successfully optimized

success
boolean
Example:

true

data
object