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
Where
- Mean-variance utility
utility - Expected return
expected_return - Risk aversion
risk_aversion - Variance of the return: the volatility squared
volatility - The share of wealth in the risky asset that makes utility largest
optimal_share - Risk-free rate
risk_free_rate - Certainty equivalent return
certainty_equivalent - Probability of outcome i
probabilities - Return in outcome i
outcomes - Relative risk aversion
relative_risk_aversion - The Kelly fraction of a bet
full_kelly - Probability of winning
win_probability - Net odds: what a winning bet of 1 pays
odds - The Kelly fraction of a risky asset
full_kelly - The asset's expected return per year
drift - Risk-free rate per year, in the Kelly fraction of an asset
risk_free_rate - Expected growth rate of wealth at the fraction f
growth_rate - 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
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Mean-variance utility, E - A sigma^2 / 2 | |
Expected returnexpected_returnreturn · [-1, 10] | return | [-1, 10] | Expected return per year |
Volatilityvolatilityvolatility · [0, 10] | volatility | [0, 10] | Volatility per year; zero for a risk-free asset |
Risk aversionrisk_aversionratio · [0, 100] | ratio | [0, 100] | Risk aversion A; zero is risk neutral |
Utility-maximizing share in the risky asset (optimal_risky_share): 5 inputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Utility-maximizing share in the risky asset | |
Expected returnexpected_returnreturn · [-1, 1] | return | [-1, 1] | Expected return of the risky portfolio a year |
Risk free raterisk_free_raterate · [-0.99, 1] | rate | [-0.99, 1] | Risk-free rate a year |
Volatilityvolatilityvolatility · [0.01, 10] | volatility | [0.01, 10] | Volatility of the risky portfolio a year |
Risk aversionrisk_aversionratio · [0.1, 100] | ratio | [0.1, 100] | Risk aversion A, above zero |
Certainty-equivalent return under CRRA (certainty_equivalent): 4 inputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Certainty-equivalent return under CRRA | |
Outcomesoutcomesreturn (array) · length min 1, max 1000; each [-1, 100] | return (array) | length min 1, max 1000; each [-1, 100] | Possible returns |
Probabilitiesprobabilitiesprobability (array) · length min 1, max 1000; each [0, 1] | probability (array) | length min 1, max 1000; each [0, 1] | Probability of each outcome; they sum to one |
Relative risk aversionrelative_risk_aversionratio · [0, 100] | ratio | [0, 100] | Relative risk aversion gamma; 1 is log utility, 0 risk neutral |
Kelly fraction of a bet or an asset (kelly): 7 inputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Kelly fraction of a bet or an asset | |
Win probabilitywin_probabilityprobability · [0, 1] | probability | [0, 1] | Discrete bet: probability of winning |
Oddsoddsratio · [0.001, 1000] | ratio | [0.001, 1000] | Discrete bet: net odds, the profit per unit staked on a win |
Driftdriftrate · [-1, 1] | rate | [-1, 1] | Continuous asset: expected (arithmetic) return a year |
Risk free raterisk_free_raterate · [-0.99, 1] | rate | [-0.99, 1] | Continuous asset: risk-free rate a year; zero if omitted |
Volatilityvolatilityvolatility · [0.01, 10] | volatility | [0.01, 10] | Continuous asset: volatility a year |
Multipliermultiplierratio · (0, 1] | ratio | (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
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Mean-variance utility, E - A sigma^2 / 2 | |
Utilityutilityreturn · [-10000, 10] | return | [-10000, 10] | Utility: the certainty-equivalent return a year |
Risk penaltyrisk_penaltyratio · [0, 10000] | ratio | [0, 10000] | The penalty for risk, A sigma^2 / 2 |
Utility-maximizing share in the risky asset (optimal_risky_share): 6 outputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Utility-maximizing share in the risky asset | |
Optimal shareoptimal_shareratio · [-200000, 200000] | ratio | [-200000, 200000] | Share of wealth in the risky portfolio; above 1 borrows, below 0 is short |
Expected returnexpected_returnreturn · [-1, 410000] | return | [-1, 410000] | Combined portfolio's expected return |
Volatilityvolatilityvolatility · [0, 2000] | volatility | [0, 2000] | Combined portfolio's volatility |
Utilityutilityreturn · [-1, 410000] | return | [-1, 410000] | Combined portfolio's utility |
Sharpe ratiosharpe_ratioratio · [-200, 200] | ratio | [-200, 200] | Sharpe ratio of the risky portfolio |
Certainty-equivalent return under CRRA (certainty_equivalent): 4 outputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Certainty-equivalent return under CRRA | |
Certainty equivalentcertainty_equivalentreturn · [-1, 100] | return | [-1, 100] | Certain return with the gamble's expected utility |
Expected returnexpected_returnreturn · [-1, 100] | return | [-1, 100] | Probability-weighted mean of the outcomes |
Risk premiumrisk_premiumreturn · [0, 101] | return | [0, 101] | Expected return less the certainty equivalent |
Kelly fraction of a bet or an asset (kelly): 5 outputs
| Name | Unit | Bounds | Description |
|---|---|---|---|
Calculationcalculationtext | text | Kelly fraction of a bet or an asset | |
Formformtext | text | Which Kelly formula applied | |
Full kellyfull_kellyratio · [-20000, 20000] | ratio | [-20000, 20000] | The growth-maximizing fraction; at or below zero there is no edge |
Fractionfractionratio · [-20000, 20000] | ratio | [-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] | rate | [-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
- 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)
- 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
- 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)
- 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_modelwith 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:
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())
pyeconomics models run portfolio.utility --inputs - <<'JSON'
{
"calculation": "mean_variance_utility",
"expected_return": 0.08,
"risk_aversion": 3,
"volatility": 0.2
}
JSON