# Kelly Strategy vs All-In Strategy

## Objective

Repeated gambles on a favourable bet have the features that:
* Feature 1: The all-in strategy achieves the maximal expected value for a given number of plays.
* Feature 2: The Kelly strategy achieves higher value than any other strategy a.e.

My intuitive reaction is that these are in contradiction. The goal of this lab is to build a better intuition of the distinction.


## Background

### Setup

This follows the presentation of \[Thorp, 1969\].

In particular, we assume binary bets offered at evens and take:

* Times: $i \in {1, 2, ...}$
* Trials: $T_i \in {-1, 1}$, with $P(T_i = 1) = p = 1 - q$
* Bet size: $B_i$, such that our earning for the $n$th bet is $B_n T_n$

Our wealth after the result of the $n$th bet is: $X_n = X_0 + \displaystyle\sum_{i=1}^n B_i T_i$

We further assume:
* $0 \leq B_i \leq X_{i-1}$ (roughly: this is one-sided market with no leverage)
* $X_i = 0 => X_j = 0 \, \forall \, j > i$ (roughly: we have fixed capital)
* $p > \frac{1}{2}$ (we are only interested in favourable bets)

### Feature 1: Maximal Expectation

The strategy maximizing the expectation of Wealth to step $n$ (for any $n$) is that of betting your entire wealth at each stage ($B_i = X_{i-1}$).

To see this, let $B_i := f_i X_{i-1}$ for some $0 \leq f_i \leq 1$ and condition on $X_{n-1}$:

$$
\begin{align}
\mathbb{E}[X_n] &= \mathbb{E}[X_{n-1}] + \mathbb{E}[B_n T_n] \\
    &= \mathbb{E}[X_{n-1}] + \mathbb{E}[B_n] \mathbb{E}[T_n] \\
    &= \mathbb{E}[X_{n-1}] + (p-q) \mathbb{E}[B_n] \\
    &= \mathbb{E}[X_{n-1}] + (p-q) \mathbb{E}[f_n X_{n-1}] \\
    &= \mathbb{E}\big[X_{n-1} \big(1 + (p-q) f_n \big) \big] \\
    &= \mathbb{E}\big[X_{n-1} \mathbb{E}[1 + (p-q) f_n | X_{n-1}] \big] \\
    &= \mathbb{E}\big[X_{n-1} \big(1 + (p-q)\mathbb{E}[f_n | X_{n-1}]\big) \big]
\end{align}
$$

From this, the optimal $f_n = 1$ (or $B_n = X_{n-1}$). That is, bet all-in. And similarly, by induction, $B_i = X_{i-1}$.

For a given $n$, this strategy is worth

$$
X_n = \left\{
     \begin{array}{11}
         2^n & \mbox{with probability }p^n \\
         0   & \mbox{otherwise}
     \end{array}
\right.
$$

giving an expected value $\mathbb{E}[X_n] = (2p)^n \to \infty$, but ruin probability $1-p^n \to 1$

### Feature 2: Kelly Criterion

The Kelly Criterion maximizes $\mathbb{E}[\log(\frac{X_n}{X_{n-1}})] = \mathbb{E}[\log(1+f_n T_n)] = p \log(1+f_n) + q \log(1-f_n)$.

Letting $G(f) := p \log(1+f) + q \log(1-f)$, we see that $G$ maximized at $f^* = p-q$. So the Kelly Criterion bets a constant fraction $p-q$ on each trial.

Intuitively, this maximizes the rate of growth. But more formally, this satisfies:

* $\mathbb{P}(\lim \inf X^*_n > M) = 1 \, \forall M$ \[Thorp, 1969\] 
* $\mathbb{P}(X^*_n/X'_n \to \infty) = 1$ where $X'$ follows an "essentially different" strategy \[Brieman, 1961\]
* $\lim_{x \to \infty} (\mathbb{E}[T(x)] - \mathbb{E}[T^*(x)]) > 0$ where $T(x)$ is the first hitting time of $X_n = x$ \[Brieman, 1961\]

## Discussion

On explicating the nature of the maximal expectation strategy, it's now clear that the apparent contradiction between (Feature 1) and (Feature 2) is not a contradiction at all. And in fact that the maximal expectation strategy really isn't of any interest. The maximal expectation strategy exceeds the Kelly strategy only on the event of all successful trials up to $n$. This even has probability $p^n \to 0$. But the value on this event grows quickly enough in $n$ such that the expectation of this strategy exceeds all others. Like the St Petersburg paradox, this only works with unbounded (and indeed almost immediately infeasibly large) capital. 

Noting that both strategies are fixed fractional strategies, we can consider $X_n = X_n(f)$ as a function of that fraction $f$:

$$
\begin{align}
    X_n(f) &= X_{n-1} + f X_{n-1} * T_n \\
        &= X_{n-1} (1 + f T_n) \\
        &= \ldots \\
        &= X_0 \displaystyle\prod_{i=1}^n(1 + f T_i) \\
\end{align}
$$

From which:

$$
\begin{align}
    \mathbb{E}[X_n(f)] &= X_0 \big( 1+(p-q)f \big)^n \\
    Var\big( X_n(f) \big) &= X_0^2 \Big( \big( 1 + (p-q)f + f^2 \big)^n - \big( 1 + (p-q)f \big)^n \Big)
\end{align}
$$

More interesting, and again pointing to the importance of the log expectation, is the tricotomy shown in \[Thorp 1969\] for $G(f) := \mathbb{E}\big[ \log \big( \frac{X_n(f)}{X_{n-1}(f)} \big) \big] = \mathbb{E}\Big[ \log \Big( \big( \frac{X_n(f)}{X_0(f)} \big)^\frac{1}{n} \Big) \Big]$. He shows that there is a unique $f_c$ with $0 < f^* < f_c < 1$ such that:

$$
G(f) \left\{
    \begin{array}{11}
        > 0  & \mbox{  if } 0 \leq f < f_c \\
        = 0  & \mbox{  if } f = f_c \\
        < 0  & \mbox{  if } f_c < f \leq 1 \\
    \end{array}
\right.
$$

which drives:

$$
\left\{
    \begin{array}{11}
        X_n(f) \to \infty & \mbox{  if } G(f) > 0 \\
        \lim \sup X_n(f) = \infty, \lim \inf X_n(f) = 0  & \mbox{  if } G(f) = 0 \\
        X_n(f) \to 0 & \mbox{  if } G(f) < 0 \\
    \end{array}
\right.
$$

We can see $G(f)$ here:


```python
import altair as alt
import numpy as np
import pandas as pd

pgrid = np.linspace(0.5, 1, num=10)
fgrid = np.linspace(0, 1, num=1000, endpoint=False)
p, f = np.meshgrid(pgrid, fgrid)
G = p*np.log(1+f)+(1-p)*np.log(1-f)

alt.data_transformers.disable_max_rows()

(
    alt
    .Chart(
        pd.DataFrame(
            data=np.array([p, f, G]).reshape(3, -1).T,
            columns=["p", "f", "G"]
        )
    )
    .mark_line()
    .encode(
        x="f",
        y="G",
        color="p"
    )
)

```





<div id="altair-viz-ff728f7994b949eba9e990e3de83aede"></div>




## References

[\[Brieman, 1961\]](https://digitalassets.lib.berkeley.edu/math/ucb/text/math_s4_v1_article-05.pdf) Breiman, L. Optimal Gambling Systems for Favorable Games. Proceedings of the Fourth Berkeley Symposium on Mathematical Statistics and Probability, Volume 1: Contributions to the Theory of Statistics, 65--78, University of California Press, Berkeley, Calif., 1961. https://projecteuclid.org/euclid.bsmsp/1200512159

[\[Thorp, 1969\]](https://www.jstor.org/stable/1402118) Thorp, E. O. "Optimal Gambling Systems for Favorable Games." Revue De L'Institut International De Statistique / Review of the International Statistical Institute 37, no. 3 (1969): 273-93. Accessed November 28, 2020. doi:10.2307/1402118.

c27f8aa28a2cf6131f53a82eef64e42060b0a726
ipynb
Jupyter Notebook
notebooks/1. Kelly Strategy vs All-In Strategy.ipynb
mgh35/lab-kelly_criterion
7b3deb7ce981bbf7f946d6b1c2806771c5c4b604
MIT
notebooks/1. Kelly Strategy vs All-In Strategy.ipynb
mgh35/lab-kelly_criterion
7b3deb7ce981bbf7f946d6b1c2806771c5c4b604
MIT
notebooks/1. Kelly Strategy vs All-In Strategy.ipynb
mgh35/lab-kelly_criterion
7b3deb7ce981bbf7f946d6b1c2806771c5c4b604
MIT
2021-02-28T11:56:47.000Z
2021-02-28T11:56:47.000Z
Qwen/Qwen-72B
1. YES
2. YES