Skip to content

Portfolio

Utility, risky share and Kelly fraction

Mean-variance utility, the utility-maximizing risky share, the CRRA certainty equivalent of a gamble, and the Kelly fraction.

Model id
portfolio.utility, version 1
Domain
Portfolio
Evidence
standard
Cost class
instant: A closed-form calculation; a hosted run may take up to 2 seconds.

Formula

U=E[r]−12Aσ2U = E[r] - \tfrac{1}{2} A \sigma^2y∗=E[r]−rfAσ2y^* = \frac{E[r] - r_f}{A \sigma^2}1+CE=(∑ipi(1+ri)1−γ)1/(1−γ)1 + CE = \Big(\sum_i p_i (1 + r_i)^{1 - \gamma}\Big)^{1/(1 - \gamma)}γ=1: 1+CE=e∑ipiln⁡(1+ri)\gamma = 1:\ 1 + CE = e^{\sum_i p_i \ln(1 + r_i)}fbet∗=p−1−pb,fasset∗=μ−rσ2f^*_{\mathrm{bet}} = p - \frac{1 - p}{b}, \quad f^*_{\mathrm{asset}} = \frac{\mu - r}{\sigma^2}g=r+f(μ−r)−12f2σ2g = r + f(\mu - r) - \tfrac{1}{2} f^2 \sigma^2

Where

UU
Mean-variance utility utility
E[r]E[r]
Expected return expected_return
AA
Risk aversion risk_aversion
σ2\sigma^2
Variance of the return: the volatility squared volatility
y∗y^*
The share of wealth in the risky asset that makes utility largest optimal_share
rfr_f
Risk-free rate risk_free_rate
CECE
Certainty equivalent return certainty_equivalent
pip_i
Probability of outcome i probabilities
rir_i
Return in outcome i outcomes
γ\gamma
Relative risk aversion relative_risk_aversion
fbet∗f^*_{\mathrm{bet}}
The Kelly fraction of a bet full_kelly
pp
Probability of winning win_probability
bb
Net odds: what a winning bet of 1 pays odds
fasset∗f^*_{\mathrm{asset}}
The Kelly fraction of a risky asset full_kelly
μ\mu
The asset's expected return per year drift
rr
Risk-free rate per year, in the Kelly fraction of an asset risk_free_rate
gg
Expected growth rate of wealth at the fraction f growth_rate
ff
The fraction of wealth held in the asset fraction

Each symbol's field is named beside it; the inputs and outputs, with their units and bounds, are under Variables, and the citations give each formula's source.

Variables

Rates, returns and yields are decimals: 0.05 is five percent. Bounds in brackets include their end; in parentheses they exclude it.

Inputs

Mean-variance utility, E - A sigma^2 / 2 (mean_variance_utility): 4 inputs
Inputs of the calculation mean_variance_utility
NameDescription
CalculationcalculationtextMean-variance utility, E - A sigma^2 / 2
Expected returnexpected_returnreturn · [-1, 10]Expected return per year
Volatilityvolatilityvolatility · [0, 10]Volatility per year; zero for a risk-free asset
Risk aversionrisk_aversionratio · [0, 100]Risk aversion A; zero is risk neutral
Utility-maximizing share in the risky asset (optimal_risky_share): 5 inputs
Inputs of the calculation optimal_risky_share
NameDescription
CalculationcalculationtextUtility-maximizing share in the risky asset
Expected returnexpected_returnreturn · [-1, 1]Expected return of the risky portfolio a year
Risk free raterisk_free_raterate · [-0.99, 1]Risk-free rate a year
Volatilityvolatilityvolatility · [0.01, 10]Volatility of the risky portfolio a year
Risk aversionrisk_aversionratio · [0.1, 100]Risk aversion A, above zero
Certainty-equivalent return under CRRA (certainty_equivalent): 4 inputs
Inputs of the calculation certainty_equivalent
NameDescription
CalculationcalculationtextCertainty-equivalent return under CRRA
Outcomesoutcomesreturn (array) · length min 1, max 1000; each [-1, 100]Possible returns
Probabilitiesprobabilitiesprobability (array) · length min 1, max 1000; each [0, 1]Probability of each outcome; they sum to one
Relative risk aversionrelative_risk_aversionratio · [0, 100]Relative risk aversion gamma; 1 is log utility, 0 risk neutral
Kelly fraction of a bet or an asset (kelly): 7 inputs
Inputs of the calculation kelly
NameDescription
CalculationcalculationtextKelly fraction of a bet or an asset
Win probabilitywin_probabilityprobability · [0, 1]Discrete bet: probability of winning
Oddsoddsratio · [0.001, 1000]Discrete bet: net odds, the profit per unit staked on a win
Driftdriftrate · [-1, 1]Continuous asset: expected (arithmetic) return a year
Risk free raterisk_free_raterate · [-0.99, 1]Continuous asset: risk-free rate a year; zero if omitted
Volatilityvolatilityvolatility · [0.01, 10]Continuous asset: volatility a year
Multipliermultiplierratio · (0, 1]Fraction of the full Kelly fraction to use; 0.5 is half Kelly

Outputs

Mean-variance utility, E - A sigma^2 / 2 (mean_variance_utility): 3 outputs
Outputs of the calculation mean_variance_utility
NameDescription
CalculationcalculationtextMean-variance utility, E - A sigma^2 / 2
Utilityutilityreturn · [-10000, 10]Utility: the certainty-equivalent return a year
Risk penaltyrisk_penaltyratio · [0, 10000]The penalty for risk, A sigma^2 / 2
Utility-maximizing share in the risky asset (optimal_risky_share): 6 outputs
Outputs of the calculation optimal_risky_share
NameDescription
CalculationcalculationtextUtility-maximizing share in the risky asset
Optimal shareoptimal_shareratio · [-200000, 200000]Share of wealth in the risky portfolio; above 1 borrows, below 0 is short
Expected returnexpected_returnreturn · [-1, 410000]Combined portfolio's expected return
Volatilityvolatilityvolatility · [0, 2000]Combined portfolio's volatility
Utilityutilityreturn · [-1, 410000]Combined portfolio's utility
Sharpe ratiosharpe_ratioratio · [-200, 200]Sharpe ratio of the risky portfolio
Certainty-equivalent return under CRRA (certainty_equivalent): 4 outputs
Outputs of the calculation certainty_equivalent
NameDescription
CalculationcalculationtextCertainty-equivalent return under CRRA
Certainty equivalentcertainty_equivalentreturn · [-1, 100]Certain return with the gamble's expected utility
Expected returnexpected_returnreturn · [-1, 100]Probability-weighted mean of the outcomes
Risk premiumrisk_premiumreturn · [0, 101]Expected return less the certainty equivalent
Kelly fraction of a bet or an asset (kelly): 5 outputs
Outputs of the calculation kelly
NameDescription
CalculationcalculationtextKelly fraction of a bet or an asset
FormformtextWhich Kelly formula applied
Full kellyfull_kellyratio · [-20000, 20000]The growth-maximizing fraction; at or below zero there is no edge
Fractionfractionratio · [-20000, 20000]The multiplier times the full fraction; for a discrete bet never below zero, as a bet cannot be taken short
Growth rategrowth_raterate · [-0.99, 21000]Expected log growth at that fraction: per bet, or a year for a continuous asset

Calculator

Run the model on your own inputs, starting from its example. Rates are decimals: 0.05 is five percent. The run goes to the pyeconomics API on this site: your values travel only in the request, and nothing is stored.

Loading the calculator…

Worked example

Example utility_of_a_risky_portfolio. Inputs:

{
  "calculation": "mean_variance_utility",
  "expected_return": 0.08,
  "risk_aversion": 3,
  "volatility": 0.2
}

Outputs:

{
  "calculation": "mean_variance_utility",
  "risk_penalty": 0.06000000000000001,
  "utility": 0.01999999999999999
}

Assumptions

  • Mean-variance utility and the risky share take returns and volatilities a year as decimals, and a risk aversion A on the scale where U = E - A sigma^2 / 2.
  • The certainty equivalent takes discrete outcomes whose probabilities sum to one (within 1e-9; they are rescaled to exactly one).
  • A discrete bet wins b per unit staked with probability p and loses the stake otherwise; a continuous asset follows geometric Brownian motion with the given drift and volatility, rebalanced continuously.
  • Every output is a formula result for the parameters the user supplies, the same for every user: not investment advice, and not advice to take any allocation or bet.

Limitations

  • The risky share and the continuous Kelly fraction need a volatility of at least 1% and returns within [-1, 1] a year, which keeps them representable; leverage and short sales are unconstrained.
  • Full Kelly assumes the probabilities and odds, or drift and volatility, are known exactly; with estimation error it over-bets, which is why fractional Kelly is offered.

Evidence

Status: standard. Textbook consensus, such as bond duration or the CAPM formula.

Every model declares one status: standard (textbook consensus), practitioner (a widely used convention), contested (under active debate), rejected (failed out of sample) or historical (a superseded methodology).

Syllabus

The 2027 CFA® Program's topic areas this model relates to, as factual tags. Each links to CFA Institute's page for its level; pyeconomics holds none of the curriculum's text.

Citations

  1. Kelly, J. L. (1956). A new interpretation of information rate. Bell System Technical Journal, 35(4), 917-926. doi:10.1002/j.1538-7305.1956.tb03809.x (pp. 919-920, the even-money fraction maximizing the growth rate)
  2. Thorp, E. O. (2006). The Kelly criterion in blackjack, sports betting and the stock market. In Handbook of Asset and Liability Management, Vol. 1, 385-428. Elsevier. doi:10.1016/S1872-0978(06)01009-X (Section 2, pp. 389-391, bets at even money and at b-to-1 odds; Section 7.1, eqs. (7.1)-(7.3), the continuous approximation). ISBN 9780444508751
  3. Merton, R. C. (1969). Lifetime portfolio selection under uncertainty: the continuous-time case. The Review of Economics and Statistics, 51(3), 247-257. doi:10.2307/1926560 (Section IV, eqs. (25) and (29'), constant relative risk aversion)
  4. Pratt, J. W. (1964). Risk aversion in the small and in the large. Econometrica, 32(1/2), 122-136. doi:10.2307/1913738 (The definition of the risk premium, the paper's opening equation)

Changelog

  • Version 1: First version.

Use it elsewhere

Documentation
The model's reference page
REST API
GET or POST /v1/models/portfolio.utility/run
MCP tool
run_model with the model's id, portfolio.utility. Connect an assistant
Command line
pyeconomics models run portfolio.utility --help

The worked example, from Python and from the command line:

Python
import pyeconomics

inputs = {
    "calculation": "mean_variance_utility",
    "expected_return": 0.08,
    "risk_aversion": 3,
    "volatility": 0.2,
}
result = pyeconomics.run("portfolio.utility", inputs)
print(result.to_json())
Command line
pyeconomics models run portfolio.utility --inputs - <<'JSON'
{
  "calculation": "mean_variance_utility",
  "expected_return": 0.08,
  "risk_aversion": 3,
  "volatility": 0.2
}
JSON