Kelly Criterion
Calculate the Kelly Criterion, the share of capital to put at risk that maximizes the expected logarithmic growth of wealth, from the returns of an investment portfolio or asset.
The discrete form is Kelly’s (1956) bet: a probability of winning and a ratio of the average win to the average loss, as the QuantStats package calculates it from returns. The continuous form is Thorp’s (2006) for returns that are close to normally distributed: the average excess return over the risk free rate divided by the variance of the excess returns. Since investors rarely bet the full Kelly amount, whose wealth swings widely, fraction gives a fractional Kelly such as half Kelly.
The formulas are as follows:
\[\text{Discrete:}\;\; \text{Kelly} = \text{Win Rate} - (1 - \text{Win Rate}) / \text{Payoff Ratio}\] \[\text{Continuous:}\;\; \text{Kelly} = \text{Average Excess Return} / \text{Variance of the Excess Returns}\] \[\text{Win Rate} = \text{Number of Positive Returns} / \text{Number of Non-Zero Returns}\] \[\text{Payoff Ratio} = \text{Average Positive Return} / | \text{Average Negative Return} |\]A value of 0.25 means putting a quarter of the capital at risk, a value above 1 means borrowing to invest and a negative value means the history shows a negative edge.
For more information, see the following sources:
- Kelly, J.L. (1956). “A New Interpretation of Information Rate.” Bell System Technical Journal, 35(4), 917-926.
- Thorp, E.O. (2006). “The Kelly Criterion in Blackjack, Sports Betting, and the Stock Market.” Handbook of Asset and Liability Management, Volume 1, 385-428.
- MacLean, L.C., Thorp, E.O. & Ziemba, W.T. (2011). “The Kelly Capital Growth Investment Criterion.” World Scientific.
Kelly Criterion in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_kelly_criterion as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "KO"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_kelly_criterion()
Or, after setting up the Finance Toolkit MCP, ask:
Which Kelly fraction did the returns of Apple, Microsoft and Coca-Cola support in each year from 2021 to 2025?
Which returns:
| AAPL | MSFT | KO | |
|---|---|---|---|
| 2021 | 0.1113 | 0.1649 | 0.0911 |
| 2022 | -0.056 | -0.0611 | 0.0557 |
| 2023 | 0.1639 | 0.1547 | -0.0248 |
| 2024 | 0.1137 | 0.0601 | 0.061 |
| 2025 | 0.0433 | 0.0694 | 0.0717 |
Parameters
get_kelly_criterion accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The period to use for the calculation. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "weekly" |
within_period | bool | Whether to calculate the Kelly Criterion from the daily returns within each period (e.g. each year if period = ‘yearly’) or from the returns of the periods themselves over the whole history. Defaults to True. | True |
rolling | int | The rolling window size to use for the calculation. If set, the Kelly Criterion is calculated over a rolling window of this many periods across the full return history instead of per period. Defaults to None. | 4 |
method | str | “discrete” (Kelly’s bet from the win rate and payoff ratio) or “continuous” (average excess return over its variance). Defaults to “discrete”. | "discrete" |
fraction | float | The share of the full Kelly bet, e.g. 0.5 for half Kelly. Defaults to 1.0. | 1.0 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the ratios. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |