[HN Gopher] Kelly Criterion - how to calculate optimal bet sizes
       ___________________________________________________________________
        
       Kelly Criterion - how to calculate optimal bet sizes
        
       Author : fernandohur
       Score  : 132 points
       Date   : 2021-06-08 07:37 UTC (1 days ago)
        
 (HTM) web link (fhur.github.io)
 (TXT) w3m dump (fhur.github.io)
        
       | YossarianFrPrez wrote:
       | It's well worth implementing and testing out the Kelly Criterion.
       | It's super simple to code up in a Jupyter Notebook so that you
       | get to enter an amount to bet each time. When I tried it, I found
       | my own psychology changing as the bets continued, even when I
       | knew the coin's bias. It's a really great demonstration of the
       | difference between a) intellectually knowing the optimal
       | strategy, and b) what actually happens.
       | 
       | A bet on a biased coin paradigm was actually tried in the real
       | world with finance professionals, with a cap on the maximum
       | payout. The results are described here:
       | https://arxiv.org/pdf/1701.01427.pdf It's pretty interesting.
       | (Note though that the "average returns" reported hide a lot of
       | variation.)
        
       | bugzz wrote:
       | A great investing blog I follow is
       | https://breakingthemarket.com/. He talks about the Kelly
       | Criterion and extending it to making correlated bets
       | (investments).
        
       | piyh wrote:
       | There's a loose vs lose typo in the second paragraph. It's like
       | school teachers whipped they're, their, there into our heads and
       | where one typo door closes another opens.
        
         | mwcremer wrote:
         | Its definately a loosing battle.
        
       | epapsiou wrote:
       | This is so timely. I made this with a buddy of mine to help us
       | figure out optimal allocation for stocks in a portfolio using
       | Kelly. https://engine.oracled.com/
        
         | tel wrote:
         | Be careful using this formula too naively. Predicting
         | tomorrow's expected return is quite difficult, though
         | predicting tomorrow's expected volatility is doable.
        
         | nostromo wrote:
         | It's telling me I should short SPY and go long GameStop and
         | AMC... Sounds suicidal to me.
        
           | allyourhorses wrote:
           | This is beta hedging, it works on the assumption that when
           | SPY performs positively, your risky basket will outperform
           | SPY, but if there is some systemic risk-off event, your SPY
           | short will at least dampen if not fully cover any losses made
           | in your risky basket
           | 
           | Good day, you lose -0.5% on SPY but gain +2% on AMC
           | 
           | Bad day, you maybe gain 0.5-1%% on SPY and lose -2% on AMC
        
         | behrlich wrote:
         | Another word of caution. The Kelly Criterion depends on each
         | event being independent. Lets say I'm told to allocate 50% to
         | QQQ and 50% to SPY. Those may independently be correct, but
         | since the NASDAQ and S&P are highly correlated, this wouldn't
         | be the correct allocation. You've essentially allocated 100% of
         | your portfolio to one probability, rather than 50% to two
         | independent probabilities.
         | 
         | This is an obvious example. But really all stocks (or at least
         | sectors) are correlated just like this. So other examples
         | wouldn't be so obvious.
        
         | hatsunearu wrote:
         | I have no idea how this website works, could you explain?
        
         | deertick1 wrote:
         | How does kelly criterion apply to sizing portfolio positions?
         | From what I understand trying to use it in the stock market is
         | a fools errand.
        
         | Etheryte wrote:
         | Some estimates end up being negative, is that intentional? E.g
         | AAPL.
        
       | jyriand wrote:
       | How you will go bust in favorable bet by N N Taleb -
       | https://youtu.be/91IOwS0gf3g
        
         | titanomachy wrote:
         | Am I missing something? It doesn't seem counterintuitive to me
         | that repeatedly making an all-or-nothing bet with a non-zero
         | chance of losing will eventually cause my expected value of
         | capital to go to zero.
         | 
         | I like the presentation style though, and the allusion to
         | Shannon's theorem although I didn't quite grasp the connection.
        
           | oarabbus_ wrote:
           | Right, I don't think that's the part that's counterintuitive.
           | It's the claim he makes "if someone offers you a bet 70%
           | chance to win a dollar, 30% loss, it's better not to take it
           | in some cases" is what is counterintuitive to people.
        
           | tel wrote:
           | I forget what he said in the video, but generally this thing
           | can be a little surprising because even a pretty decent
           | looking bet can blow you up with high probability if you size
           | it wrong.
           | 
           | The other side of this is Shannon's Demon: a sort of crappy
           | game can be made into a profitable one by sizing it properly
           | (and rebalancing).
        
         | [deleted]
        
       | murbard2 wrote:
       | The Kelly criterion is to financial math as the Fibonacci
       | sequence is to mathematics. Yes it's neat, no it's not special,
       | please stop bringing it up all the time.
        
         | ltbarcly3 wrote:
         | This so much. Like anything that is 'optimal' it is optimal
         | with respect to some criterion. For the Kelly Criterion it is
         | to maximize the logarithm of the weighted sum of the expected
         | value across all outcomes.
         | 
         | This is probably not what you actually want in almost any
         | situation.
         | 
         | The one time it actually makes sense to bring it in is if you
         | are forced to make a certain number of wagers in some game AND
         | you have good-enough knowledge of the odds of the game AND your
         | payout is proportional to how much money you have left at the
         | end of the game, AND the wager size does not effect the outcome
         | of the game in any way. This scenario never happens.
         | 
         | Even when you meet many of the necessary prerequisites to use
         | Kelly, it still doesn't make sense at all. For example,
         | Blackjack tournaments. You are given a set amount of starting
         | money, you play for a set number of hands (or time), and you
         | know the odds perfectly. However, the payout structure isn't
         | proportional to your final amount of money, so using Kelly has
         | more or less no chance of winning any money in the tournament.
         | They usually pay for the top N results, which means you have to
         | go with a very high variance strategy AND win consistently to
         | place.
         | 
         | Poker: Nope, not even close, bet size is a direct input into
         | the dynamics of the game. Predictable betting of any kind is a
         | maximally bad strategy.
         | 
         | Stock Market: utility of money isn't logarithmic, so it is not
         | worth maximizing, even if you knew probabilities and were
         | forced to make wagers, which you don't and aren't. If you could
         | even approximate probabilities you could use that power to
         | basically print money on derivatives, so even if Kelly applied,
         | the prerequisites are too strong and would make far far better
         | strategies available.
         | 
         | The only valid use case for bringing in the Kelly Criteria is
         | for gamblers to feel better about burning money at the tables
         | by improperly applying it.
        
           | wizzwizz4 wrote:
           | > _For the Kelly Criterion it is to maximize the logarithm of
           | the weighted sum of the expected value across all outcomes._
           | 
           | It's actually to maximise the expected logarithm of the
           | monetary amount, and it's a pretty good heuristic (in most
           | circumstances) given that most opportunities are exponential.
           | (It usually takes a given amount of effort to double your
           | money.)
        
           | concreteblock wrote:
           | You obviously wouldn't use Kelly criterion during a poker
           | game because the assumptions don't fit. But on a larger scale
           | it can be used for 'bankroll management' - what proportion of
           | your wealth should you use on a tournament entry fee. Of
           | course you don't have the exact parameter p but you can use
           | an estimate to make sure you are not making a grossly
           | over/under-sized bet.
        
           | arthurcolle wrote:
           | Kelly must be the name of the wife in the WSB "wife's
           | boyfriend" memes.
           | 
           | More seriously, great analysis. Couldn't have said it better
           | myself.
        
           | concreteblock wrote:
           | The first sentence of your post, while technically true,
           | misses the point. This misunderstanding undermines many of
           | your other points.
           | 
           | The kelly criterion happens to be optimal with respect to log
           | wealth but that's not the main reason why it's interesting.
           | Many explanations, including the original post, make this
           | mistake. Maybe because 'maximizing expected utility' is a
           | more common idea.
           | 
           | The first sentence of the wikipedia article:
           | 
           | "In probability theory and intertemporal portfolio choice,
           | the Kelly criterion (or Kelly strategy or Kelly bet), also
           | known as the scientific gambling method, is a formula for bet
           | sizing that leads almost surely (under the assumption of
           | known expected returns) to higher wealth compared to any
           | other strategy in the long run".
           | 
           | In other words, pick a strategy. I'll pick the kelly
           | strategy. There will be some point in time, after which I
           | will have more money than you, and you will never overtake
           | me. No logarithms involved. This is something you can easily
           | check by simulation, but requires some heavier math to
           | formulate precisely and prove.
           | 
           | See also posts by spekcular and rssoconnor elsewhere in this
           | thread.
        
           | thenaturalist wrote:
           | Hi there, you seem to know a good deal about the intricacies
           | of where the Kelly Criterion lies within the range of
           | possible options to calculate outcomes.
           | 
           | Could you point me to any good resource you know of to learn
           | more about the range itself and other options?
        
         | lordnacho wrote:
         | When I was a young guy who happened to be partner in a hedge
         | fund, I used to ask candidates about this.
         | 
         | I kinda regret it now. I'm not sure what I was trying to find
         | out from people. I guess in some way it's a cultural question
         | masquerading as a technical question, because it reveals
         | whether you've heard of it and whether you have heard of the
         | standard stuff that's said about it:
         | 
         | - Don't do full Kelly because if you're on the wrong side (too
         | big bets) that's definitely bad.
         | 
         | - Depends on the probabilities being static.
         | 
         | - You can find a continuous form of it. You can also find the
         | implied leverage from the Sharpe ratio.
         | 
         | I wonder if my memory is even correct on these. But the point
         | remains that it's not terribly useful as a thing to evaluate
         | people with. I guess the question "How do you size your
         | positions?" needs to start somewhere.
        
         | bobbylarrybobby wrote:
         | The Fibonacci sequence is not special because it is just one
         | element of the family of linear recurrences. Is there a larger
         | family to which the Kelly criterion belongs? (Not being snide
         | -- I'm genuinely asking)
        
           | paulpauper wrote:
           | the entire field of martingale pricing
        
             | arthurcolle wrote:
             | I can hear your sigh in answering this all the way from
             | here :D
        
           | murbard2 wrote:
           | Yes, any utility function will give you a Kelly-like
           | criterion. Kelly is log utility.
        
             | spekcular wrote:
             | Kelly is special though, it's not just log utility. In
             | fact, viewing it as maximizing log utility is ahistorical;
             | the original derivation was in terms of information theory.
             | (The paper's title is "A new interpretation of information
             | rate" [0].) Further, and most importantly, Kelly betting
             | has certain favorable asymptotic properties that betting
             | strategies motivated by other utility functions don't have.
             | See Breiman's "Optimal gambling systems for favorable
             | games" [1].
             | 
             | This point is well known in the literature, for instance
             | see [2]:
             | 
             | > Perhaps one reason is that maximizing E log S suggests
             | that the investor has a logarithmic utility for money.
             | However, the criticism of the choice of utility functions
             | ignores the fact that maximizing E log S is a consequence
             | of the goals represented by properties P1 and P2, and has
             | nothing to do with utility theory.
             | 
             | [0]
             | https://www.princeton.edu/~wbialek/rome/refs/kelly_56.pdf
             | 
             | [1] http://www-
             | stat.wharton.upenn.edu/~steele/Resources/FTSResou...
             | 
             | [2]
             | https://pubsonline.informs.org/doi/abs/10.1287/moor.5.2.161
        
               | rssoconnor wrote:
               | Exactly. The Kelly strategy is the strategy that, with
               | probability 1, eventually and permanently beats any other
               | strategy. This isn't true for any other strategy and this
               | criterion has nothing to do with utility.
        
             | LudwigNagasena wrote:
             | That's wrong. The assumptions behind the Kelly criterion
             | lead to the log utility only in a particular case.
             | 
             | What if each week you can bet $1 that in 50% of cases will
             | triple your bet and in 50% of cases will give you $0?
             | According to the log utility whether you should bet depends
             | on your current wealth. According to the assumptions behind
             | the Kelly criterion you should take the bet every week.
        
             | jsw97 wrote:
             | Paul Samuelson wrote an article in 1979 on this. It
             | contains only one-syllable words, except for the last word,
             | which is "syllable". Title: "Why We Should Not Make Mean
             | Log of Wealth Big though Years to Act Are Long."
             | 
             | His 1971 paper, "The 'Fallacy' of Maximizing the Geometric
             | Mean in Long Sequences of Investing or Gambling" is more
             | readable.
        
         | ArtWomb wrote:
         | I believe it's come into fashion again with the rise of legal
         | sportsbook in the US (DraftKings, etc). Particulaly, with the
         | fascination over long shot "parlays" or chain bets that can
         | achieve very high payouts with very little outlays. Better odds
         | than buying a lottery ticket by far, or so it is perceived.
         | 
         | I think you have to have a few jokers short of a full deck to
         | get into sports gaming and expect any outcome other than ruin.
         | But the parlays are interesting. And the simplicity one could
         | devise a winning strategy is enticing.
         | 
         | Consider a typical NBA season: 120 game nights, about 8 games
         | per night. Let's say you constructed a parlay strategy in which
         | you pick the under to hit on every game played that night. If
         | the payout is large, say $1000 for a $3 bet. That's $360 for
         | the season risk. And a high probability that eventually it'll
         | cash ;)
        
           | confidantlake wrote:
           | If the odds of an under happening is 50% then that is indeed
           | a great bet! The odds of winning would be (0.5)^8 or 1 in
           | 256. So the EV of the bet would be
           | 
           | E(x) = (1/256 * 1000) - (255/256 * 3)
           | 
           | E(x) = .91796875
           | 
           | So you are expected to make nearly 92 cents on every 3
           | dollars bet. Over a 30% return! Any bookie offering these
           | odds would quickly go broke.
        
         | pradn wrote:
         | Bloom filters are the equivalent in computer science. Just
         | beyond the basics, but ubiquitous enough to be annoying when
         | it's on the front page every other week.
        
       | aborsy wrote:
       | But how much is it actually used in trading?
        
         | fighterpilot wrote:
         | It's not practical when the outcome is distributed in a very
         | weird and unknown way and each bet isn't really iid.
         | 
         | Moreover you can find the same result with a simple grid search
         | over bet sizes, obviating the need to estimate any parameters
         | of the outcome distribution.
         | 
         | It would be more useful in professional gambling where outcome
         | distributions are more knowable.
        
         | evo wrote:
         | It's useful as an upper limit--if you're leveraging past what
         | Kelly suggests you're almost certainly overleveraged.
         | 
         | In theory, Kelly is optimal--if you knew the exact probability
         | density function of your returns, it would give you the right
         | leverage to take.
         | 
         | In practice, you're always playing with risks, some you're
         | factoring into your models, some you're choosing not to because
         | they're intractable, some you're not even aware of until they
         | occur. The most basic premise--today's returns will be a
         | function of hypotheses that I've derived from looking at past
         | observations--is an approximation at best.
         | 
         | This mismatch between model and reality can lead to expensive
         | lessons learned when using the full Kelly model, so often
         | traders will "half-kelly" or something like that, to
         | incorporate the basic idea of risk scaling proposed by the
         | Kelly model but with more safety margin.
        
           | 6gvONxR4sf7o wrote:
           | > In theory, Kelly is optimal...
           | 
           | It's optimal for one utility function (log of future $), but
           | that doesn't make it necessarily optimal for everything,
           | right?
        
             | evo wrote:
             | That's a great callout as well: it's optimal for maximizing
             | your expected growth in the long term, but does carry
             | significant volatility. That's fine for an emotionless
             | immortal robot investor, but as we're human.
             | 
             | If we're close to an investment goal, like saving a house
             | downpayment or retiring, the calculus is quite different.
             | Even outside that, loss aversion is a real thing and we're
             | likely happier trading some upside for being able to sleep
             | at night.
        
         | rezahussain wrote:
         | I used it in live trading last year, I couldn't really make it
         | work.
         | 
         | I precalc my stoplosses + stopgains then use a simulation to
         | get the win/loss probabilities on training data.
         | 
         | What I observed is the kelly formula really prefers the tiny
         | stoplosses, so when you sort your predictions by kelly score it
         | will pick the ones with tiny stoplosses.
         | 
         | What happened to me in the live test is the tiny stoplosses
         | triggered, when a stopgain would have triggered later.
         | 
         | I know someone is going to say "thats a problem with your
         | stoplosses+stopgains OOS performance" and they are right, but
         | OOS stoploss+stopgain calculation isn't trivial for me to
         | calculate :\
        
           | aborsy wrote:
           | Where did you get the distribution of the real data from?
        
             | rezahussain wrote:
             | Yes, model predictions on volume+price data from 2019+2020
        
         | paulpauper wrote:
         | I am sure it is used but the challenge is calculating the
         | necessary parameters
        
         | SatvikBeri wrote:
         | Almost no one uses it directly - in practice, Kelly is too
         | aggressive - but variations of it are quite common.
        
           | syntaxing wrote:
           | Would love to hear about the variations!
        
             | paulpauper wrote:
             | bet less than the formula recommends. depends on personal
             | preferences
        
         | dcolkitt wrote:
         | Kelly criterion is just the square of Sharpe ratio. Sharpe is
         | used pretty extensively from a strategy selection and risk
         | management perspective.
        
           | arthurcolle wrote:
           | Please share this calculation, dying to know what kind of
           | inter-universal Teichmuller space theoretic math you're using
           | to come up with this.
        
             | afryer wrote:
             | https://news.ycombinator.com/item?id=27453365
             | 
             | Edward Thorpe and Ralph Vince both conclude that the Kelly
             | Criterion in the continuous case is excess returns divided
             | by variance, which is pretty close to the Sharpe Ratio,
             | correct?
             | 
             | Asking to understand better, not to be combative. Your
             | comment made it seem like that formula is way off.
        
           | SpicyP wrote:
           | This is not correct. Kelly criterion is not the square of the
           | sharpe ratio
        
             | afryer wrote:
             | https://ifta.org/public/files/journal/d_ifta_journal_11.pdf
             | 
             | Page 27: Vince(vi) and independently Thorpv(ii) provide a
             | solution that satisfies the Kelly Criterion for the
             | continuous finance case, often quoted in the financial
             | community to the effect that "f should equal the expected
             | excess return of the strategy divided by the expected
             | variance of the excess return:"
             | 
             | f = (m-r) / s^2
             | 
             | so it's Sharpe with variance instead of standard deviation
             | in the denominator, correct?
        
               | dcolkitt wrote:
               | Yes, that's correct.
               | 
               | An intuitive way to think about this is that Sharpe
               | depends on the specific horizon you're using. E.g.
               | annualized Sharpe will be sqrt(252) larger than daily
               | Sharpe. It would not make sense to change the Kelly
               | criterion based on a substitution of variables. In
               | contrast variance, like returns, scales linearly with
               | time horizon. Therefore the variance ratio is invariant
               | to the time horizon.
        
         | Solstinox wrote:
         | Knowingly? Not often. You don't find long-run successful
         | traders who don't knowingly/unknowingly use it or some
         | variation of it.
        
       | mywacaday wrote:
       | Does anyone know of any formulas that would accommodate p
       | changing on every bet?
        
         | hervature wrote:
         | Well, Kelly is infinite horizon, so any derivation is going to
         | depend on the exact payouts. If it is not infinite horizon, you
         | can do dynamic programming to figure it out but you will have
         | to be careful with myopic reasoning (betting it all in the last
         | stage). In practice, just plug your changing payoff into the
         | formula. The rationale being every bet is growth optimal in the
         | long run even if you only bet it once.
        
         | dcolkitt wrote:
         | If the distribution of p is ergodic, then Kelly criterion (re-
         | sized at every p) still maximizes expected growth rate.
        
       | pge wrote:
       | Fortune's Formula by William Poundstone is a fun read on the
       | origin of the Kelly criterion, as well as the role of gangsters
       | and bookies in the funding of the early communications
       | infrastructure in the US.
        
         | ArtWomb wrote:
         | Thanks! I'm looking for "history of probability" mass market
         | books and this looks spot on ;)
        
       | sigmaskipper wrote:
       | Used an abbreviated version to of the kelly criterion along with
       | Markowitz portfolio optimization and applied it to sports
       | betting. All I can say is that past results do not indicate
       | future returns
        
         | windsignaling wrote:
         | The part that all these nice theories miss is that you actually
         | do not know the distribution p(win) (in the case of Kelly) or
         | the expected return and covariance (in the case of Markowitz).
        
           | contravariant wrote:
           | Well 'knowing' the 'true probability' is a philosophical can
           | of worms anyway.
           | 
           | The good news is that you don't need to know it exactly, you
           | just need to make a better guess than the bookies (w.r.t. the
           | Kullback Leibler divergence or cross-entropy, whichever takes
           | your fancy).
        
           | zorked wrote:
           | I know I would never be a writer of seminal papers because I
           | would never publish a formula that includes unknowable
           | parameters.
           | 
           | Same goes for Black-Scholes which includes _future_
           | volatility.
        
             | LeegleechN wrote:
             | The fact that Black-Scholes has only one unknowable
             | parameter makes it quite usable, more so than more
             | complicated option pricing models. You can work backwards
             | from the market price to solve for the implied volatility,
             | treating it as a generalized 'price' for the option after
             | factoring out things that are easily adjusted for. You can
             | also abuse the implied volatility (adjusting it up or down)
             | to account for factors outside of the idealized model.
        
             | tel wrote:
             | That's something of a moot argument, though, since BSM
             | computes prices in terms of the future volatility. Since we
             | have the actual price, the volatility is actually what we
             | solve for with BSM.
             | 
             | Even if we had neither price nor volatility, we can still
             | talk about the surface of possible (price, volatility)
             | pairs which are compatible with the model.
        
               | hgibbs wrote:
               | But how do we get the prices? If I tell you the at-the-
               | money front-month call is $1000 will you tell me the vol
               | is 100pa?
        
               | tel wrote:
               | Yeah, basically. Also need the strike, spot, an estimate
               | of the risk free rate (probably not today).
               | 
               | The implied vol is a useful way to make sense of the
               | actual market prices of options. We also might have some
               | predictions about the market's implied vol changing going
               | forward and we can reverse those errors back into
               | expected price changes (and maybe trade on them).
        
             | arthurcolle wrote:
             | It's a real concern, but more realistically you can just
             | compute many potential outcomes and at least get a sense of
             | the structure of the surface
        
       | zucker42 wrote:
       | I wonder how professional gamblers approach bet sizing. It seems
       | to me that for most applications the Kelly Criterion is not the
       | right choice. The utility of money is asymmetric; gaining $25000
       | is worse than not losing $25000. Relatedly, most actual gamblers
       | want to ensure good returns while not going broke, so minimizing
       | risk of ruin is often more important than maximizing return rate.
       | Further complicating the matter is that in real life you don't
       | know your actual probability of success, but you may have an
       | estimation. And finally, though this is less commonly
       | significant, your rate of return in a given game might depend on
       | your the amount you bet.
       | 
       | From what I've seen in the poker community, no one has really
       | approached this type of bet sizing from a rigorous perspective
       | beyond the relatively simple Kelly Criterion.
        
       | mewse-hn wrote:
       | I read about this on HN and then lost it for months when I wanted
       | to apply it to a crappy game on a random discord server.
       | 
       | The game lets you bet on chicken fights and tells you the
       | probability your chicken will win (starts at like 62% chance to
       | win), so this kelly criterion is perfect. It's a bit incredible
       | how reliable it is.
        
       | sigstoat wrote:
       | read the original paper. the gambler's formulation is garbage,
       | which obscures all insight.
        
       | awaythrowact wrote:
       | https://news.ycombinator.com/item?id=26834333
        
       | fairity wrote:
       | Perhaps I'm misunderstanding, but the post says that the optimal
       | bet size f = 1-2p (where p is the probability of winning). But,
       | this seems backwards. As p goes up, you should be betting more.
       | 
       | Shouldn't the optimal bet size, f, be 2p-1?
        
         | mgraczyk wrote:
         | Yes, looks like a typo. The plots show the correct direction
         | though (f* is an increasing function of p)
        
       ___________________________________________________________________
       (page generated 2021-06-09 23:00 UTC)