Before you go, check out these stories!

0
Hackernoon logoHow To Master the Art of Risk Management [feat. Gambler's Ruin and Kelly Betting] by@punk

How To Master the Art of Risk Management [feat. Gambler's Ruin and Kelly Betting]

Would you believe it if you were told you’re more likely to survive a lightning strike than your beloved puppy’s occasional unfriendly bites? As shown by the National Safety Council, the lifetime odds of dying from being bitten by a dog is 1 to 112,400 while the odds of dying from a lightning strike is 1 to 161,856. Although a lightning strike may sound deadlier, the reality is a bit more complex. And here’s the catch.

A basic statistical concept which was first discussed in 1656 in a letter written by French mathematician Blaise Pascal called Gambler’s Ruin leads us to understand that the prospect of constantly being exposed to risky events could alter our perception of the individual event.

The fact that we are more exposed to dogs in our lifetime makes dog bites eventually deadlier than lightning strikes (unless you are one of the X-men who fights supervillains with her meteorological superpowers).

Gambler’s Ruin provides a statistical linkage between the probability of individual events and the probability of an eventual event. This concept is one of the building blocks in trading. In this probabilistic game, whether we are aware of it or not, there is always a probability associated with our strategy that is subject to wins and losses.

Because of this, there is a chance that the strategy we are using could lead to ruin. But how? Or when? More importantly, what we can we do about it?

The famous Kelly Criterion invented by a Bell Lab Scientist in 1961 named John L Kelly Jr. can help us find the answers to these questions.

A Simple Coin Toss Game

Let’s consider a simple coin-tossing game. If the toss comes out H (head), the bettor receives the entire wager, else if it comes out T (tail) the wager is lost. Let the probability of outcome H be p and T be q = 1 − p. Assume now that we have an unfair coin with p > 0.5, meaning it is more likely for a toss to come out H than T.

The reward ϕ of each toss is a random variable,

where ϕ+ and ϕ– represent the multipliers of the wager corresponding to wins and losses respectively. Here we are assuming that the entire wager is either won or lost in the moment, i.e., ϕ+ = 1 and ϕ– = -1.

The expectation value of the reward R of a toss is then

How much should the player bet? Suppose C0 is the initial equity – or amount of money –  available to the player, and he/she bets a portion f of the equity every time.

After a number N of bets, the final equity CN becomes

Derivation of the Optimal Bet Size - The Kelly Bet

Let’s study the optimal bet size of the above simple coin toss game. The first question to ask is what kind of optimality we would like to achieve. In this article, we would like to maximize the expected long-term growth rate i.e, the average log-return of each independent toss.

We want to choose f  in such a way that E[log(1+)] is maximized. As

Setting the first derivative of the above expression to 0 and solving it for gives us f = 2p − 1. This is the bet size that achieves the maximum expected long-term growth. We denote this as the Kelly bet fKelly = 2p − 1.

The Kelly bet in its general form for any ϕ+ and ϕ– can be derived as

Implementation and Simulation of the Coin Toss Game

We simulated a CoinTossGame based on the above rules to conduct our experiment

Here are the parameters of the simulation:

  • win_rate: p, the probability of a win;
  • profit: ϕ+, the multiplier of the wager when the outcome corresponds to a win;
  • loss: ϕ−, the multiplier of the wager when the outcome corresponds to a loss;
  • number_of_tosses: N, the number of tosses in a single run of the game;
  • number_of_runs: the number of runs of the game;
  • bet_size: f;
  • starting_captial: C0

Each column represents a run of the game and shows the logarithm of the running equity.

First, let’s experiment with 10 runs of 30 tosses with an unfair coin in which the winning probability p is 70% and the set profit = 1 and loss = -1. Remember that the Kelly bet size of this game is 2p − 1 = 2 · 0.7 − 1 = 40% or 0.4.

Characteristics of Over-Betting, Under-Betting, and Kelly-Betting

Let’s simulate many runs of repeated bets and examine the behavior of the running equity with different bet sizes. In particular, we are going to simulate over-betting, under-betting, and Kelly-betting respectively.

Over-Betting

Now we are going to run some simulations to examine the effect on the final equity using a larger than ideal bet size. First, let’s simulate 1000 equity curves of 100 tosses with bet size = 80% which is double of our Optimal Kelly bet 40%

We can see after many runs of the game that over-better is more likely to lead to bankruptcy.  The reason is that there is always a non-zero probability of successive loss, and over-betting just gets the equity to come down geometrically in this case.

Under-Betting

Next, we simulate 1000 equity curves of 100 tosses with bet size = 20% which is half of our 40% Kelly bet. We are under-betting in this case.

As we can observe, comparatively more runs of the game end up with decent final equity when under-betting. However, as we are under-betting, we’re playing it safe which at the same time means limiting our equity growth-rate.

Kelly Betting

Last but not least, we simulate 1000 equity curves of 100 tosses with bet size = Kelly

We can observe here that with Kelly betting we are able to achieve the optimal outcome.

Distribution of the Final Equity Under Over-Betting, Under-Betting and Kelly-Betting

The figure below shows the distribution of the final equity (in log scale) with over-betting, under-betting and Kelly-betting respectively.

The above figure shows that with over-betting, even if we have an individual with a high win rate (70%), we are very likely to be led to ruin after many bets due to the possible occurrence of many successive losses which decrease our equity geometrically.

With under-betting, we have a lower chance of going broke, but we are not able to optimize our equity growth.

With Kelly-betting, we have the maximum expected long-term growth rate (i.e, the expected final log equity in this case) but compared to under-betting, with a more dispersed final equity clustered around the positive region.

Asymmetric Relation - The Use of (half-) Kelly for Better Position Sizing

Let’s repeat the above simulation process for different bet sizes so that we can observe the detailed variation of the expected long-term growth rate versus bet size. This time, we will simulate 1000 runs of 1000 tosses with starting capital = 100.

Let’s plot the expected long-term growth rate versus a number of bet sizes.

We can clearly see the asymmetrical relationship between the bet size and growth rate. The expected long-term growth rate is, by definition, maximized with the Kelly bet. The long-term expected growth rate falls much more rapidly as soon as the bet size is larger than Kelly, while under-betting leads to less severe outcomes. This asymmetrical relationship is consistent, irrespective of the individual winning probability.

The Kelly bet size fKelly is the optimal bet size that yields the maximum expected long-term growth rate. We have learned now that if a bettor bets above Kelly, he or she is likely to be led to ruin.

We can also see that playing it safe is not such a bad idea, as it still leads to relatively positive results.

This should bring to our attention that even with a 70% win rate bet, if we are over-betting, we could eventually ruin our equity with the occurrence of a successive loss. This principle applies even in less predictable games.

Potential Application in Trading

In quantitative trading, we unavoidably assume that the past carries information for us to make better decisions in the future. Strategy back-testing could help identifying the probability distribution of strategy returns.

However, one must ensure the said distribution is stable enough to obtain a reliable Kelly bet calculation. A way to do this is to use a rolling-window approach to estimate the probability distribution on a dynamic basis. Coin toss outcomes could easily be estimated with the Gaussian approach, but financial market predictions are more challenging.

We have to remember that financial markets are much more complex than a simple coin toss game where outcomes are quite random. In financial markets, prices do not fluctuate randomly. The price return distributions are often highly skewed and the parameters of those distributions not stable enough (or statistically not stationary) for model construction.

Conclusion

To perform best with uncertainties, we must have a sense of the odds at play because that helps us to estimate the most practical strategy by understanding and applying the Kelly Criterion.

Even if you are confident about your edge in a game, in this probabilistic world you may want to prepare yourself for ruin. Especially when your exposure to risks gets larger.

In trading, since the probability distribution of a strategy could be elusive, the under-betting strategy (Half or Quarter of Kelly) helps taking care of the known unknowns. It at least gives us more time to maximize our profits as we engage the market.



Tags

The Noonification banner

Subscribe to get your daily round-up of top tech stories!