Numerically solve Kelly criterion for multiple simultaneous bets

Since its discovery a few decades ago, the **Kelly criterion** has become a reference for professional gamblers and speculators alike. This very simple formula calculates the fraction of risk capital which should be allocated on a single bet in order to maximise long term returns. But, can this approach be extended to the case of simultaneous independent bets which are quite common in investing or sports betting? In this short piece, we will look into a numerical method to calculate the optimal risk allocation across multiple bets based on Kelly's approach, and run through an intuitive analysis of the results.

In 1956, John Larry Kelly, Jr, a researcher at *Bells Lab*, discovered a simple formula for the optimal fraction of risk capital that should be waged on a particular bet, in order to maximise returns over the long run. His formula is derived by maximising the expectation of the logarithm of the final wealth:

where *p* is the probability of winning the bet, *b* is the win/loss ratio, and *f* the fraction of wealth to be waged. Using basic calculus, the optimal allocation *f_star* comes out as:

This famous formula, called the **Kelly Criterion**, took the speculating world by storm probably due to its simplicity and elegance. But what happens when we would like to take part in several simultaneous independent bets? Is the optimal allocation across our portfolio of bets equivalent to the optimal allocation calculated on every single bet? It would be very convenient, but unfortunately, this is not the case. Let's get into the multiple bets case in more detail.

The expectation of the log of the final wealth after 2 simultaneous independent bets can be expressed as:

In the case of two bets, solving for *f_star1* and *f_star2* algebraically is clearly more time consuming to achieve than for the single bet case. Even if the solving process ultimately narrows down to a straightforward system of 2 linear equations with 2 unknowns variables, characterising such a system for an arbitrary number of bets is not simple. A numerical approach is far more appealing especially as the gradient of the objective function can be easily calculated. Going down the numerical route, first involves coding a function that would return the expectation of the log of the final wealth and its gradient for any number of independent simultaneous bets. Here is its implementation in the **Rust** programming language:

```
use ndarray::prelude::*;
use itertools::Itertools;
pub fn expectation_log_wealth( bets_data: &Vec<(f64,f64)>, fs: &Vec<f64>) -> (f64, Vec<f64>) {
assert_eq!( bets_data.len(), fs.len() );
let mut res = 0f64;
let mut grad = Array::from_elem(bets_data.len(), 0f64);
for indices in std::iter::repeat(0).take(bets_data.len()).map(|i| i..i+2).multi_cartesian_product() {
let mut prob = 1f64;
let mut wealth = 1f64;
let mut local_grad = Array::from_elem(bets_data.len(), 0f64);
for (i, &j) in indices.iter().enumerate() {
if j == 0 {
prob *= bets_data[i].0;
wealth += fs[i] * bets_data[i].1;
local_grad[i] += bets_data[i].1;
} else {
prob *= 1f64 - bets_data[i].0;
wealth -= fs[i];
local_grad[i] -= 1f64;
}
}
res += prob * wealth.ln();
grad += &(prob * &local_grad / wealth);
}
(res, grad.to_vec())
}
```

Then an optimisation routine for maximising the function armed with its gradient has to be used. The **Gradient Ascent** algorithm seems to be a natural fit for this role. Here is its implementation using the previously defined function:

```
pub fn multiple_kelly_criterion(bets_data: &Vec<(f64,f64)>, fs: &Vec<f64>, alpha: f64, eps: f64) -> (f64, Vec<f64>) {
assert_eq!( bets_data.len(), fs.len() );
let mut opt_prev_res : Option<f64> = None;
let mut new_fs = fs.clone();
loop{
let (res, grad) = expectation_log_wealth( &bets_data, &new_fs );
new_fs = (Array::from(new_fs) + Array::from(grad) * alpha).to_vec().iter()
.map(|&x| {
if x > 1f64 {
1f64
} else if x < 0f64 {
0f64
} else {
x
}
}).collect::<Vec<f64>>();
if let Some( prev_res ) = opt_prev_res {
if (res - prev_res).abs() < eps {
opt_prev_res = Some( res );
break;
}
}
opt_prev_res = Some( res );
}
(opt_prev_res.unwrap(),new_fs)
}
```

Using this approach, let's try and get an intuitive understanding of the results for a specific example.

Let's consider a portfolio of 7 simultaneous bets with positive edge. The table below states each bet's characteristics, its individual Kelly criterion and the optimal wager numerically calculated.

Probability | Win/loss ratio | Sequential f* (Kelly Criterion) | Simultaneous f* |
---|---|---|---|

0.3 | 12.8 | 24.53% | 19.97% |

0.4 | 6.4 | 30.63% | 22.41% |

0.5 | 3.2 | 34.38% | 20.55% |

0.6 | 1.6 | 35% | 15.40% |

0.7 | 0.8 | 32.5% | 9.61% |

0.8 | 0.4 | 30% | 5.67% |

0.9 | 0.2 | 40% | 5.58% |

We observe that *the optimal wagers calculated are smaller than the Kelly Criteria (Sequential bets) in absolute terms*. Surprisingly, in the simultaneous setting, the distribution of the optimal wagers across bets is drastically different from the distribution in a sequential setting.

How could this be the case?

The paper Algorithms for optimal allocation of bets on many simultaneous events - C. Whitrow (2007) documented an attempt to gain some understanding on the distribution of the optimal wagers in the case of multiple simultaneous and independent bets. A very interesting observation was made on this topic: *For a large number of bets, the optimal wagers tend to be proportional to the "probabilistic edge" of each bet*

The validity of result is very apparent in our example, as the chart below illustrates:

The paper's author investigated the exact mathematical relationship between these quantities using regression, but unfortunately, failed to bring any intuitive explanation as to why such relationship exists.

The decades-old approach developed by **J.L.Kelly Jr**, to optimally allocate risk capital on a single bet, is easily extendable to a multiple simultaneous bets situation thanks to numerical optimisation methods. However, it is important to mention that optimising long term returns is only one aspect of the risk allocation process. The other is to minimise the risk of ruin which is crucial for financial survival when bad luck strikes. Hence the optimal approach for capital allocation is a trade off between these two metrics. Risk preferences do play a big role in this process, turning risk capital allocation into a very subjective exercise. For these reasons, Kelly's wagers tend to be used as references only, helping speculators getting to an allocation fitting their specific risk appetite.

If you like this post, follow me on Twitter and get notified on the next posts.