# The Kelly Criterion - Laying

### Description

This staking plan is based on the Kelly Criterion - a method of calculating your stake size based on the size of the bank, the current price and the projected strike rate of the selection with the chosen rank.

While the classic Kelly staking plan is described for backing, this trigger example focuses on laying.

The Kelly Criterion allows you to calculate the fraction of your bank that you are supposed to lay on the selection with the given rank. The formula is below:

`bet_size = (1 - strike_rate)*(1 - commission) - strike_rate*(price - 1)/((price-1)*(1 - commission)`

Where

• `bet_size` if the fraction of your bank that you are advised to lay on the selection;
• `strike_rate` is the perceived or real probability for the chosen favourite rank to win in an event;
• `price` is the current digital price (odds) of the chosen favourite;
• `commission` is the exchange commission divided by 100, e.g. 0.05 for a 5% commission.

If the price and/or the strike rate are too high, meaning that your liability will be disproportionate to the number of times you'll be losing, the bet will not be placed, as the Kelly criterion will be negative.

### Triggers

You can adjust the trigger settings using the following constants in the file:

 divisor Divisor (number by which the bet size is divided). Use this constant to reduce the size of each bet (with divisor > 1) or increase it (with divisor < 1). avg_odds Initial average odds (based on your own estimation) s_rate Initial strike rate (based on your own estimation) fav_rank Rank of the favourite to lay on. The triggers can be easily converted to lay on a selection with the predefined index rather than rank. To that end, check `Selection's Index` instead of `Selection's Rank` in the trigger conditions. mins_before_start When to place the bet (minutes before the off) track_wl 1 - track wins and losses and adjust average odds and strike rate, 0 - do not keep track, always use the initial values. min_depth Min. win/lose history depth to start adjusting average odds and strike rate. Use this to prevent an unnecessary statistical error in the calculation of the strike rate and average odds, where their values are based on a handful of events. max_deviation Maximum deviation from average odds, %. The triggers will not lay if the selection's price is too different from the average odds.

### How this works

At the beginning, you must key in a projected strike rate of the chosen favourite. You may get this rate by simply counting the number of times that favourite has won in a given number of events, for example, if the 3rd favourite has won twice in the recent 25 events, its strike rate is 8%. You can also get this number from statistics websites, forums, tipsters, etc.

The triggers then keep track of your winnings automatically, adjusting the average odds of this favourite and its strike rate as you go forward. Note: if you restart the triggers or the program, this history will be reset.

If the current price and strike rate suggest that it makes sense to lay on that selection, the triggers do so, with an automatically calculated stake size.

Below is an account statement from testing the triggers on horse racing markets in Time Machine, with `divisor` = 5, starting bank = £1,000, `fav_rank` = 3, `avg_odds` = 8.5, `s_rate` = 4.

If you have not heard of BetFair yet or do not have an account, register today and get £20 free. Use the link below:
New customers only, bet up to €/£20 on the Exchange and if your first bet loses, we’ll refund you €/£20 in Cash. Bet must be placed in first 7 days of account opening. T&Cs apply.
Gamble responsibly! Always be aware that betting is NOT risk-free. You must be 18+ years old before you try gambling, but even as an adult, withhold from spending money in an ill-judged manner. Our company does not encourage you to prefer gambling over other meaningful activities. If gambling is affecting your life or the lives of people close to you, please contact GamCare