Popular Posts

Editor'S Choice - 2020

Kelly Criteria or How Hedge Fund Traders Calculate Position Size

Among the many different information sources, it is sometimes quite difficult to find the necessary information and collect it into a single whole. This is mainly due to the fact that most authors of books, articles and courses on trading are people who are far from mathematics. Therefore, many things are described superficially, some points are interpreted generally incorrectly. The second problem is that many Forex lovers are also people who are not deeply versed in this very mathematics, and it would be difficult to understand some of the nuances of the same money management without delving into the wilds of formulas.

Today we will analyze what the Kelly criterion is and how to apply it on the market without complex formulas and mathematical terms. All conclusions and proofs, research, theorems and other difficulties will be omitted, but instead I will talk about the results of all the terrible things listed above in a simple and understandable language.

Kelly test history

Like the d'Alembert and Martingale strategies, the Kelly criterion has been known to sports betting enthusiasts for many years. They have been trying to solve the problem of the optimal rate since the eighteenth century, with the discussion of the St. Petersburg Paradox by Daniel Bernoulli. Even on this issue, the points of view were divided: some are trying to minimize the probability of losing the entire deposit for a certain number of future transactions, while others, on the contrary, want to get the maximum possible increase for this number of transactions. Another approach is to value money using the utility function. In other words, it all comes down to making the most of your deposit. In the 18th century, Daniel Bernoulli used the utility function when trying to solve the St. Petersburg Paradox, but to no avail.

John Larry Kelly recalled the formula in 1956, noting some of its interesting properties. At that time, he worked for AT&T Bell Laboratories, a telecommunications, electronic, and computer systems company. Strictly speaking, this formula was applied by him precisely in this area. Then, five years later, these properties were studied and summarized in a study by Briman. Well, already in the same year, Markowitz decided to apply the formula to securities. And a year later, in 1962, Edward O. Thorpe described the criterion in detail in the first edition of his book Beat the Dealer (Beat the Dealer). Such a difficult story for this criterion, named not in honor of a real author and gained distribution in the financial markets also by the will of a completely different person.

What is the Kelly criterion and how to calculate it?

The Kelly criterion has a number of properties for a given trading system with a positive mathematical expectation and here are the most "magical" of them:

  • the amount of capital is growing unlimitedly;
  • the probability of ruin of a player tends to zero with an increase in the number of trades.

Indeed, when applying the Kelly criterion, capital will grow faster than when using any other method of managing funds. In fact, by determining the lot size by this method, the trader acts optimally, but only in a very special case. Here, by optimality itself we mean this:

  • as quickly as possible capital reaches a predetermined value;
  • reaching the maximum amount of capital after a fixed number of transactions.

It smells like overclocking, right? That's right, and a little later you will understand why.

First, let's look at the Kelly criterion formula. In the literature you can find a huge number of different formulas for calculation, and all of them will be true. There are a lot of variants of betting formulas on the network, which also authors of articles are trying to apply to financial markets. The most common of the formulas I met looks like this:

X = p - q / w, where:

p is the probability of winning;

q is the probability of losing;

w is the average value of the gain (it is also often recommended to use the average value of the gain relative to the average loss).

Based on the formula, you should always bet in each transaction x on the size of your capital. That is, if x = 0.1, then for each transaction you need to put 10% of your capital. The above formula will be referred to below as the “simple” Kelly criterion.

If TAKE PROFIT = STOP LOSS, i.e. W = 1, the formula simplifies to: F = P (W) - P (L).
Thus, if the probability of winning is 60%, then F = 20%.

Let's try to apply the Kelly criterion, calculated according to this formula, to a system with a stop, three take profit levels, breakeven, two different types of trailing stop and exit according to stochastic:

The system has 78.06% of profitable transactions with an average profit of $ 9.59 and an average loss of -25.23 $.

Let's transfer the statistics to Excel to continue our calculations. We plot the growth of the deposit fixed lot 0.1:

Now we calculate the Kelly criterion for our system by the formula X = p - q / w:

X = 78.06 - 21.94 / (9.59 / 25.23) = 20.32%.

Corresponding schedule:

Our deposit showed a peak at around 1,724,000, and then we got into a series of unsuccessful transactions, which reduced our balance sheet to 997,000.

Kelly criterion optimality

The relative capital growth rate depending on the leverage chosen will be proportional to k-0.5 * k ^ 2, where k is the Kelly criterion. The first term is understandable - in a first approximation, the speed should be proportional to the shoulder, as it seems to follow from common sense. The second term describes the conversion loss, which, with small leverage, is almost invisible, but increases rapidly with leverage and after Kelly severely kills the yield to zero - the territory of large criteria ends with a “hole for especially greedy” ones.

With increasing leverage, profit grows linearly, and the loss of translation, as can be seen from the formula, grows quadratically. This leads to the fact that with an increase in leverage, the total profitability of trade grows less and less, and after reaching some optimum it starts to fall and soon goes into minus. It turns out a strange thing - we have, for example, a pretty good strategy with a lot of profitable deals, we make the decision to raise our leverage to the maximum in order to squeeze more income, and as a result we unexpectedly get a complete loss of the account.

The growth rate reaches an optimum at a shoulder value of Nkaccording to Kelly’s criterion, and with a further increase in the shoulder, it begins to decline, quickly reaching zero and going into the negative zone for excessively large shoulders (“pit for greedy”). Now it should be clear that there is an optimal player, on which we have maximum profitability, and above which the loss of translation starts to kill profits. With increasing leverage above optimal, despite the growing volatility of the account, the total profit is becoming less and less.

It turns out that you can not raise the shoulder without knowing in advance its optimal Kelly level for the strategy used. The results can be unpleasantly surprising. Above Kelly’s criterion, there should be a drop in yield; That is why it is not worth using the obtained criterion without artificial reduction.

Limitations of the Standard Formula

Almost anywhere it is not written that in this formulation, the Kelly criterion assumes that only results can be in the trading system:

-1x Bet (that is, the trader loses at x = 0.1 exactly 10% of the deposit);

+ wx Bet (that is, either winning w, or losing -1).

This option, as you can see, is a rather special case in which there can be only two outcomes for a transaction - either stop loss or take profit. But a more generalized option, where a large number of different results of each transaction is possible (for example, in systems using breakeven, trailing stop and exit on the system), this calculation option will not work.

Therefore, it is necessary to generalize the formula for calculating the Kelly criterion. Omitting theoretical calculations, proofs and formulations, I will give only the final result.

Generalized Kelly Test Formula

Suppose we have a trading system that gave the following results {ai, ki} for i = 0 ... n, where k is the number of transactions with one result, a is their result, i is the number of transactions. To make it clearer: we made a bunch of deals on the system and broke these deals up by results. It turned out for us, for example, 10 transactions with bu (0%), 30 transactions with a profit of 2%, 20 transactions with a loss of -3% and so on. We can have as many options as you like, there are i of them. In each such set, we have the number of transactions with one result (k) and the result itself (a). If a> 0, then the transaction or transactions closed with a profit, if a <0, then with a loss.

Transactions with a zero result can be discarded; they do not affect the final result of the system. Now we assume that all deals (or heaps of deals with the same results) are ordered in ascending order, while we have at least one bunch of losing trades, i.e. a1<>

A trading system with outcomes {ai, ki} for i = 0 ... n will give an income only if the sum of all aiki> 0. And it happens when the mathematical expectation of the system is positive. If the sum of all aiki is less than or equal to zero, the system is doomed to drain and no money management system will help here.

We introduce the function:

It is known that there exists only 0

The maximum risk in one trade is | ai | x0.

The average amount of capital after i transactions, assuming that the initial capital is 1, at a rate of x, can be determined by the formula:

If the bet x satisfies the condition G (x, 1)> 1, then by placing x, the trader is successful.

And the last point, more likely comparing the two systems. Suppose we have two systems {a1i, k1i} and {a2i, k2i} with a positive expectation, which were tested on the same time interval. The first system made i1 deals, the second i2 deals, the trader set x1 in the first system, in the second x2. Then the first system will be more effective than the second if G1 (x1, i1)> G2 (x2, i2).

As a result, when solving the equation from paragraph 2, we obtain the Kelly criterion. It is best to solve this equation with the help of specialized mathematical programs, for example, MathCAD. You can also use Excel and the Solution Search tool. The fourth and fifth points are used to assess the effectiveness of the trading system and allow you to estimate the average capital gain. Calculated using this formula, the Kelly criterion will have all the advantages listed above - zero ruin probability and optimal capital growth rate.

Practical application

Most likely, if you read to this place, you still did not understand how to calculate the Kelly criterion. Let's look at a simple example. So, we have a trending system that made 100 deals, 10 of which yielded + 20%, another 30 yielded + 40%, the rest were losing - twenty at -30% and forty at -10%. Let me remind you: income and loss are considered as a percentage of the amount of capital before the transaction. The system makes only 30 transactions a year - the trend system, say, on the daily chart, works on one currency pair. So, we have 4 different outcomes +0.2, +0.4, -0.3, -0.1, and they repeated 10, 30, 20 and 40 times, that is, we have a1 ... a4 and k1 ... k4. First, let's verify that the mathematical expectation is positive, otherwise it does not make sense to apply the Kelly criterion. We substitute in the formula from 1 point: 0.2 * 10 + 0.4 * 30-0.3 * 20-0.1 * 40 = 2 + 12-6-4 = 4> 0, everything is fine, the system can make a profit. We compose the equation from paragraph 2:

E (x) = 0.2 * 10 / (1 + 0.2x) + 0.4 * 30 / (1 + 0.4x) - 0.3 * 30 / (1-0.3x) - 0.1 * 40 / (1-0.1x) = 2 /(1+0.2х)+12/(1+0.4х)-6/(1-0.3х)-4/(1-0.1х) and E (x) = 0. We also have a criterion - for E (f) = 0 we have the only root of equation 0

Our formula will be the target cell, which needs to be equated to zero by changing the cell with X. You probably know how to use this tool, and if not, look at the Excel Trader course. Here's what I got as a result of enumeration:

This is almost zero, but still we round up a little X in a smaller direction, to 0.58. That is, the optimal rate in our case is 0.58% of capital. If you used leverage in trading, you need to bring the results to leverage 1: 1. That is, without changes, you can take tests of trading systems with a lot of 0.1 with a deposit of $ 10,000. Otherwise, you need to bring the results of each transaction in the appropriate form.

More complex example

A little higher, I gave statistics on a real system. Now we will calculate the Kelly criterion for this trading system using Excel.

We prepare data for building a histogram:

Take 10 pockets:

We build a histogram of the distribution of transaction results and remove zero results:

Define the minimum and maximum f: 0

Next, we introduce our long formula:

Then we’ll use the “Solution Search” tool and find the Kelly criterion:

In this case, it is 47.6%:

As you can see, the growth of the deposit is even more significant, which means our rate is more optimal. In this case, the deposit dropped to $ 2000. Now let's apply the slightly increased Kelly criterion:

As you can see, the maximum deposit growth has reached astronomical values, but as soon as a series of failures began, we quickly left almost to where we started. In this case, before reaching the maximum, we dropped to $ 250 on deposit.

And indeed, it turns out the fastest possible growth of the deposit. But the drawdown is extremely high - about 80%. That is why I talked about overclocking. If you don’t make a mistake with testing and calculations, the Kelly criterion will tell you exactly what percentage of the deposit you need to risk in order to get the maximum profitability. But such a trade will, of course, be on the brink.

Kelly test function for advisors

Well, here's what the function looks like for calculating a simple Kelly criterion for advisors:

The only thing worth remembering using the Kelly criterion in your algorithms is that the number of transactions in history should be quite large. You must be sure that your system has managed to visit various market conditions, otherwise, as soon as such conditions are reached, you will enter them with excessively high risks and lose the deposit or most of it. Here is a visual demonstration of the Kelly criterion in the work:

800 transactions were used, after which the lot was calculated according to the Kelly criterion. The chart has very high volatility, to put it mildly, it decently "storms". Nevertheless, we can lose a deposit only if we do not have enough transactions in history, and the entire calculation is aimed specifically at maximizing profits, no matter what.

Advantages of the Kelly criterion

The main advantage of the Kelly criterion is the exceptional security of the deposit. The probability of going bankrupt, playing according to the algorithm proposed by Kelly, is practically zero. Even in the event of a terrifying setback, your capital will decrease by a perfectly tolerable amount. For example, if, having a deposit of 1000 euros, we lose eight transactions in the amount of 6.67% of the deposit, then we will have 574.19 dollars on our account. Given the long “black stripe,” an acceptable result, isn't it?

Disadvantages of the Kelly criterion

Despite the obvious advantages that the Kelly criterion provides as a money management system, this approach has certain disadvantages.

  • Firstly, to calculate the criterion, you need a ready-made transaction history. The more there will be, the more accurate the calculation will be. If you use insufficient data to calculate, you risk taking too high risks and losing a deposit;
  • Secondly, the Kelly criterion is calculated for a particular next bet. Next time, the criterion will have to be recounted again. Of course, with each new transaction, the changes are not critical, but, say, once every 5-10 transactions, the criterion will have to be recalculated. In general, it is not at all difficult to apply the special case of the criterion described at the beginning of the article, but it is, strictly speaking, not suitable everywhere;
  • Thirdly, the complexity of the calculations also limits its use for manual traders trading intraday;
  • Fourthly, this method of calculation still makes the deposit schedule too volatile.Yes, in theory, we know that we cannot lose a deposit. But in practice, trading with such risks will easily add gray hair to you;
  • Fifthly, the simple Kelly criterion generally does not take into account the maximum losses in one transaction. Meanwhile, trading with the risk calculated by Kelly, say, at 40% of the deposit and getting one loss above the average of two times (by and large it’s a common thing, when you do not use the same fixed stop in every trade), you will get Margin call on hand. The more complex formula given above will partially save us from this drawback - it just takes into account the results, including the loss-making transaction itself. But do not forget that there is no guarantee that you will not have an even more serious maximum loss in the future.
  • Sixthly, none of the formulas of the Kelly criterion takes into account the unevenness of obtaining profitable and unprofitable transactions. In other words, it does not take into account the real possibility of receiving a long series of losses. Such a series will not empty your account, but most likely you will lose all the profits.


In fact, the Kelly criterion is a rather extensive field of knowledge, which cannot be described in the framework of one article. Moreover, all this would require not the weakest mathematical training. But for those who are not afraid of difficulties, the criterion makes it possible to calculate:

  • the probability of achieving the set goal in n attempts;
  • the probability that capital will ever decrease to a fraction of x of the initial value;
  • the probability of falling into or above a specified value at the end of a certain number of attempts;
  • continuous approximation of the time expected to achieve the goal;
  • the likelihood that one strategy will be ahead of another after n attempts;
  • and also quite a few interesting features.

Watch the video: How to find the right position size in your trading. Trading Spotlight (April 2020).

Leave Your Comment