I think there must be something wrong with your program. I wrote a python script to try to duplicate your results, and $20\%$ consistently comes out best. Here's my script:
from random import random, seed
seed()
frac = [k/10 for k in range(11)]
bankrolls = 11*[25]
wins = 0
for _ in range(300):
bets = [f*b for (f,b) in zip(frac, bankrolls)]
win = random() <= .6
if win:
wins += 1
bankrolls = [r+b for (r,b) in zip(bankrolls, bets)]
else:
bankrolls = [r-b for (r,b) in zip(bankrolls, bets)]
print(wins, "wins")
for idx, b in enumerate(bankrolls):
print(idx, b)
Here is sample output:
178 wins
0 25.0
1 1525.5418231115136
2 4668.530690514337
3 605.0866915333761
4 2.2038544365635504
5 0.00010387825597102039
6 1.5227053142812533e-11
7 4.2329300312072035e-22
8 3.648424706789544e-39
9 1.0377218907500444e-71
10 0.0
EDIT
I can't find an error in your code, but both our scripts are rather silly. If you start with a bankroll of $B,$ win $W$ times and lose $L$ times, then your bankroll at the end is $B(1+r)^W(1-r)^L$ where $r$ is the percentage you bet each hand. There is no need to do simulations.
You can experiment and see that the ending bankroll is highly sensitive to $W$. With $r=.2,$ an initial bankroll of 25, and $300$ total bets, $W=170$ gives an ending bankroll of $182.16,$ and $W=190$ gives an ending bankroll of $605724.76.$ (Note that the standard deviation of the number of wins is $\sqrt{72}\approx8.5$ so these are not outlandish outcomes.)
I think the flaw in your program is that you are running different simulations for each betting rate. Since the number of wins is not the same for the various regimes, the outcome aren't comparable.
It would be more informative to simply make a table comparing the ending bankroll for different betting ratios and numbers of wins.
Thank you for posting this question. I'd never heard of the Kelly bet before. I'd be interested to know if there are studies taking the probability of ruin into account. For example, if the bettor is a bank or an insurance company say, and it has a string of losses, its reserves will fall below the statutory minimum long before it loses all it capital, and the appropriate regulatory authority will shut it down. How should this be reflected in choosing the optimum bet? For an individual gambler, it's easy to say, "When you've lost all can afford to, go home," but a financial institution can't do that.
$2^{300} \cdot 25 \approx 5 \cdot 10^{91}$ You are correct that betting it all every time gives you the highest expected value, but the chance you get anything is tiny. In fact, nobody can pay you anywhere near that much money. By reducing your betting fraction your can massively increase the chance you wind up with a large number.
If I bet a fraction $f$ of my money and get $H$ heads out of $300$ tosses, I finish with $25(1+f)^H(1-f)^{300-H}$. If I set a target I can choose $f$ to maximize the probability that I end with my target or more. I validated the $f=0.2$ result roughly as that results in the maximum outcome when $180$ heads come up, about $10,504$
Best Answer
The point of the Kelly Criterion is to maximize the expected geometric growth rate -- not the expected arithmetic return and not the expected terminal wealth. Your reasoning about computing expected values is not incorrect, but it is not what is used in deriving the Kelly Criterion.
With fractional betting, the wealth $W_n$ after $n$ rounds is
$$W_n = W_{n-1}(1+fX_n),$$
where $f$ is the fixed deterministic fraction and $X_n$ is a binary random variable such that $p =\mathbb{P}(X_n = +1)$ and $q= 1-p = \mathbb{P}(X_n = -1)$.
The expected wealth after $n$ rounds conditional on the wealth after $n-1$ rounds, $W_{n-1}$, is
$$\mathbb{E}(W_n\,| W_{n-1}) = W_{n-1}\left[p(1+f)-q(1-f) \right],$$
and for $f = 20\%$, $p = 60\%$ and $q = 40\%$ we obtain
$$\mathbb{E}(W_n\,| W_{n-1}) = W_{n-1}[0.6(1+0.2) +0.4(1-0.2)]= 1.04W_{n-1}$$
This is similar to what you derivived as far as it goes.
Derivation of the Kelly Criterion
The Kelly Criterion is derived by maximizing the expected geometric growth rate
$$\tag{*}\mathbb{E}\left[\frac{1}{n}\log \frac{W_n}{W_0}\right],$$
which is not the same as
$$\frac{1}{n} \log \frac{\mathbb{E}(W_n)}{W_0}$$
The terminal wealth after $n$ rounds is
$$W_n = W_0\prod_{k=1}^n (1+fX_k)$$
Taking the logarithm of both sides we get
$$\log W_n = \log W_0 + \sum_{k=1}^n \log(1+fX_k)$$
Whence, for independent and identically distributed $X_k$,
$$\mathbb{E} \left[\frac{1}{n}\log \frac{W_n}{W_0}\right] = \frac{1}{n} \sum_{k=1}^n \mathbb{E}[\log(1+fX_1)]= \mathbb{E}[\log(1+fX_1)]\\ = p\log (1+f) +q\log(1-f)$$
To find the maximum, take the derivative with respect to $f$ and equate to $0$. The Kelly optimal fraction will be $f^* = p-q$.
Resolution
With a fractional betting strategy we always have
$$\mathbb{E} \left(\frac{W_n}{W_0}\right) = \mathbb{E}\left[\prod_{k=1}^n (1+f X_k)\right]= \prod_{k=1}^n \mathbb{E}(1+fX_1) = (1 + (p-q)f)^n$$
and, hence,
$$\tag{1}\left[\mathbb{E} \left(\frac{W_n}{W_0}\right)\right]^{1/n} = 1 + (p-q)f$$
To maximize (1) we would choose $f=1$ (betting all accumulated wealth on each round) and we would get $\mathbb{E}(W_n) = W_0(1+p-q))^n$. However, there would be a minuscule probability of attaining this wealth as the probability of ruin is $P_{\text{ruin}} = 1 - p^n$ which approaches $1$ rapidly as $n$ is increased.
However, (1) is not the expected growth rate that is maximized by Kelly Criterion. That would be
$$g(f) = \mathbb{E}\left[\log \left(\frac{W_n}{W_0}\right)^{1/n}\right], $$
which is maximized with $\text{argmax }\, g(f)=f^*=p-q$ and
$$\mathbb{E}\left[\log \left(\frac{W_n}{W_0}\right)^{1/n}\right] = g(f^*) = p\log(1+f^*) + q\log(1- f^*)$$
It is true that with the optimal betting fraction,
$$\exp\left(\mathbb{E}\left[\log \left(\frac{W_n}{W_0}\right)^{1/n}\right] \right)= (1+f^*)^p(1-f^*)^q,$$
but this does not mean $\mathbb{E}(W_n) = W_0[1+g(f^*)]^n$.