∇ProvenDecisions
Ctrl K

Maximum Sharpe ratio portfolio: a fractional programming example, solved and checked

The maximum Sharpe ratio portfolio is a classic fractional programming problem. Here it is solved by a real solver (CLARABEL (Charnes-Cooper SOCP)) and checked: every constraint, and the optimality certificate. Change the numbers below and solve your own.

Answer. You asked for: the optimal portfolio weights w1, w2, w3 (the portfolio with the highest Sharpe ratio). The largest objective value is 0.802721, at w1 = 0.306812, w2 = 0.116549, w3 = 0.576639. All 4 constraints are satisfied exactly. Optimal, numerically checked.

Solve your own version free, no account needed

The problem

Three assets have excess returns 8%, 12% and 6%, volatilities 15%, 25% and 10%, and correlations 0.3 (1-2), 0.1 (1-3), 0.2 (2-3). With no short sales, which portfolio has the highest Sharpe ratio?

How the model was built

The objective as written from the problem, before the numbers are multiplied out:

The model

Each line has a plain-language note on the right.

make this as large as possible
limit 1: left side must equal 1
fraction of portfolio in asset 1 (excess return 8%, volatility 15%) cannot be negative
fraction of portfolio in asset 2 (excess return 12%, volatility 25%) cannot be negative
fraction of portfolio in asset 3 (excess return 6%, volatility 10%) cannot be negative

What is being decided

There are 3 decision variables.

VariableTypeMeaning
w1real numberfraction of portfolio in asset 1 (excess return 8%, volatility 15%)
w2real numberfraction of portfolio in asset 2 (excess return 12%, volatility 25%)
w3real numberfraction of portfolio in asset 3 (excess return 6%, volatility 10%)

Goal and limits

Maximize the objective subject to 4 constraints, of which 3 are simple bounds on a single variable.

Problem type

Ratio of linear to norm, complexity level 4: a ratio objective: the Charnes-Cooper change of variables (y = x t) makes it convex. Solved with CLARABEL (Charnes-Cooper SOCP) at the Medium solver tier.

The answer at a glance

The optimal value of each decision, as the solver returned it.

w10.306812w20.116549w30.576639

Which constraints hold the answer in place

Binding (no slack left): (1) w1 + w2 + w3 = 1. Changing a binding constraint changes the answer; a slack one can move a little without effect.

#ConstraintValueLimitSlackBinding
1w1 + w2 + w3 = 1110yes
2w1 >= 00.30681200.306812
3w2 >= 00.11654900.116549
4w3 >= 00.57663900.576639

Algebraic model (low level)

Decision variables, objective and every constraint written out; this is exactly what the solver receives.

Model code (cvxpy)

The same model in cvxpy, ready to run.

import cvxpy as cp

w1 = cp.Variable(name='w1')  # fraction of portfolio in asset 1 (excess return 8%, volatility 15%)
w2 = cp.Variable(name='w2')  # fraction of portfolio in asset 2 (excess return 12%, volatility 25%)
w3 = cp.Variable(name='w3')  # fraction of portfolio in asset 3 (excess return 6%, volatility 10%)

objective = cp.Maximize((0.08*w1 + 0.12*w2 + 0.06*w3)/cp.sqrt(0.0225*w1**2 + 0.0225*w1*w2 + 0.003*w1*w3 + 0.0625*w2**2 + 0.01*w2*w3 + 0.01*w3**2))
constraints = [
    w1 + w2 + w3 == 1,
    w1 >= 0,
    w2 >= 0,
    w3 >= 0,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='CLARABEL')
print(problem.status, problem.value)
print('w1 =', w1.value)
print('w2 =', w2.value)
print('w3 =', w3.value)

Solve your own

This is the model as the app reads it. Change any number and solve it in the free box on the front page (no account needed).

maximize (0.08*w1 + 0.12*w2 + 0.06*w3) / sqrt(0.0225*w1^2 + 0.0625*w2^2 + 0.01*w3^2 + 0.0225*w1*w2 + 0.003*w1*w3 + 0.01*w2*w3)
subject to
w1 + w2 + w3 = 1
w1, w2, w3 >= 0
# w1 = fraction of portfolio in asset 1 (excess return 8%, volatility 15%)
# w2 = fraction of portfolio in asset 2 (excess return 12%, volatility 25%)
# w3 = fraction of portfolio in asset 3 (excess return 6%, volatility 10%)
# asked: the optimal portfolio weights w1, w2, w3 (the portfolio with the highest Sharpe ratio)

Change the numbers and solve it

Checked: the app's answer matches the reference answer in our test set, which two solvers (CLARABEL, OSQP) agree on. Built 2026-11-10.

Related examples

All 50 solved examples

Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.

What do you want to optimize?

Type the math, describe it in words, snap a photo or say it. ProvenDecisions builds the model, solves it, checks it and walks you through it.

One constraint per line, or separated by commas. Add integer: x, y or binary: z for whole-number decisions. LaTeX works too.

Try: