Cookie Consent by Privacy Policies Generator Vegapit
Universal Kelly Calculator
April 16, 2025, 10:44 a.m.

Diversification is a core risk management strategy. This is when risk capital is spread across risk sources minimising the variance of expected return on capital. In that setting, we often think about ways of allocating risk capital optimally. The most common approach is the one defined by John Larry Kelly, Jr. that gave birth to his famous Kelly Criterion. This article describes an algorithm which solves for an optimal allocation in his framework. It supports the general case of multiple simultaneous and independent bets with multiple exclusive outcomes.

Cartesian Product

The Kelly approach to risk allocation involves calculating what fraction of risk capital maximises the expected value of its logarithm. You can refer to this article or this one for a more in-depth description of the mathematical framework. A generic numerical approach used for function maximisation is Gradient ascent. It consists in moving variables in small increments along the gradient of the objective function to target higher values.

$$ f^{(n+1)} = f^{(n)} + \alpha \nabla \mathbf{E} (f^{(n)}) $$

The difficulty in our case is to have a systematic way of calculating both the expectation and its gradient in all possible betting configurations. The ability to generate the Cartesian product of the individual sets of possible outcomes solves this problem. For example, let's consider 2 simultaneous bets \( B_1 \) and \( B_2 \). The first has 3 outcomes \( \{ A_1, A_2, A_3 \} \) and the second has 2 noted \( \{ B_1, B_2 \} \). There are 6 (3 x 2) different final outcomes for the experiment which are the Cartesian product of the 2 individual outcome sets:

$$ \{ A_1, A_2, A_3 \} \times \{ B_1, B_2 \} = \ \{ \{A_1,B_1\}, \{A_1,B_2\},\{A_2,B_1\}, \{A_2,B_2\}, \{A_3,B_1\}, \{A_3,B_2\} \} $$

Once all possible outcomes are identified, calculating the probability and the final wealth for each is a straightforward task. The expectation of the log wealth and its gradient naturally derive from there.

Dealing with Parameter Constraints

In the Kelly framework, we solve for a fraction of capital to allocate to a certain bet covering a certain outcome. Since an individual fraction of capital has to be comprised between 0 and 1, an unconstrained shadow variable \( y \) is considered in the optimisation. It relates to the fraction of capital \( f \) by transform through a Sigmoid function:

$$ f(y) = \dfrac{1}{1 + e^{-y}} $$

Since the range of the Sigmoid function is bounded by 0 and 1, we can apply our gradient descent algorithm to the shadow variable being confident that the individual constraint on the fraction will be satisfied. On top of this individual constraint, we have the global constraint that the sum of all fractions from all bets has to be smaller or equal to 1.

$$ \sum_{i} f^{(n)}_i \leq 1 $$

This problem is handled by normalising to 1 the sum of all the final calculated fractions if the constraint is breached. This approach is not theoretically correct, however, since it would only introduce numerical errors in the cases where the betting edge is large, it should not happen often in a real world setting and when it does, we are talking missed opportunity rather than excess risk.

Case Study

In order to get a feel for the algorithm in a real world example, let's run it on 3 match odds market in football betting with arbitrary probability distribution:

Match I Home Draw Away
Decimal Odds 3.7 4.3 2.0
Probability 0.2 0.3 0.5
Kelly Criterion 0.0 0.088 0.0
Model 0.0 0.076 0.0
Probabilistic Edge -0.07 0.067 0.0
Match II Home Draw Away
Decimal Odds 3.3 4.0 2.2
Probability 0.2 0.3 0.5
Kelly Criterion 0.0 0.067 0.083
Model 0.0 0.112 0.161
Probabilistic Edge -0.1 0.05 0.045
Match III Home Draw Away
Decimal Odds 1.75 4.4 4.9
Probability 0.6 0.3 0.1
Kelly Criterion 0.067 0.094 0.0
Model 0.278 0.169 0.0
Probabilistic Edge 0.028 0.073 -0.105

We could make a few remarks on the result of this case study:

  1. The expected log wealth of the model's solution is 43% higher than the expected log wealth of the portfolio suggested by the Kelly criterion applied to each outcome. The total fraction of the portfolio waged is also substantially higher which partly explains the difference.
  2. Outcomes with high probability and positive probabilistic edge seem to have high risk capital allocation. Nothing really surprising to note that "sure" winners tend to attract greater capital.
  3. As it is the case for the Kelly criterion, outcomes with negative probabilistic edge never attract any risk capital. There again, this behaviour makes total sense intuitively.

Conclusion

This algorithm solves for optimal risk allocation in the Kelly framework as applied to the most common real world situations. It can handle optimisation of entire portfolios containing independent bets with multiple exclusive outcomes. As always with models, the user has to take the time to familiarise herself with the input and output sets to use the tool at its maximum potential.

A free demo version of the model is available on the website. It is restricted to handling up to 5 bets with binary outcomes only. If you would like to access the full algorithm, get in touch and your request will be discussed.

If you like this article, follow me on X and get notified on my next posts.