Problem statement
- $\mathbf{M_t}$: the amount of money $M_t$ the gambler has at time $t$
- $\mathbf{Y_t}$: Let $Y_t = \log_{10}(M_t)$ be the logarithm of $M_t$.
- $\mathbf{Y_0}$: Let $Y_0 = 1$ be the amount of money that the gambler starts with (ten dollars).
- $\mathbf{Y_L}$: Let $Y_L=-2$ be the amount of money where the gambler goes bankrupt (below 1 cent).
- $\mathbf{Y_W}$: For simplicity we add a rule that the gambler stops gambling when he has passed some amount of money $Y_W$ (we can later lift this rule by taking the limit $Y_W \to \infty$).
- $\mathbf{q}$: Let $q$ be the fraction of money that the gambler is betting.
- $\mathbf{b}$: Let $b$ be the ratio of payout for a win and a loss. In this case, a win is twice the gamble $q$ and a loss is once the gamble $q$, so $b = 2$.
- $\mathbf{X_i}$: The change of the logarithm of the amount of money in the $i$-th gamble. $X_i = Y_t-Y_{t-1}$
- $\mathbf{a_w}$: $X$ for a win.
- $\mathbf{a_l}$: $X$ for a loss.
Random walk
You can see the growth and decline of the money as an asymmetric random walk. That is you can describe $Y_t$ as:
$$Y_t = Y_0 + \sum_{i=1}^t X_i$$
where
$$\mathbb{P}[X_i= a_w =\log(1+2q)] = \mathbb{P}[X_i= a_l =\log(1-q)] = \frac{1}{2}$$
Probability of bankruptcy
Martingale
The expression
$$Z_t = c^{Y_t}$$
is a martingale when we choose $c$ such that.
$$c^{a_w}+ c^{a_l} = 2$$ (where $c<1$ if $q<0.5$). Since in that case
$$E[Z_{t+1}] = E[Z_t] \frac{1}{2} c^{a_w} + E[Z_t] \frac{1}{2} c^{a_l} = E[Z_t]$$
Probability to end up bankrupt
The stopping time (losing/bankruptcy $Y_t < Y_L$ or winning $Y_t>Y_W$) is almost surely finite since it requires in the worst case a winning streak (or losing streak) of a certain finite length, $\frac{Y_W-Y_L}{a_w}$, which is almost surely gonna happen.
Then, we can use the optional stopping theorem to say $E[Z_\tau]$ at the stopping time $\tau$ equals the expected value $E[Z_0]$ at time zero.
Thus
$$c^{Y_0} = E[Z_0] = E[Z_\tau] \approx \mathbb{P}[Y_\tau<L] c^{Y_L} + (1-\mathbb{P}[Y_\tau<L]) c^{Y_W}$$
and
$$ \mathbb{P}[Y_\tau<Y_L] \approx \frac{c^{Y_0}-c^{Y_W}}{c^{Y_L}-c^{Y_W}}$$
and the limit $Y_W \to \infty$
$$ \mathbb{P}[Y_\tau<Y_L] \approx c^{Y_0-Y_L}$$
Conclusions
Is there an optimal percentage of your cash you can offer without losing it all?
Whichever is the optimal percentage will depend on how you value different profits. However, we can say something about the probability to lose it all.
Only when the gambler is betting zero fraction of his money then he will certainly not go bankrupt.
With increasing $q$ the probability to go bankrupt will increase up to some point where the gambler will almost surely go bankrupt within a finite time (the gambler's ruin mentioned by Robert Long in the comments). This point, $q_{\text{gambler's ruin}}$, is at $$q_{\text{gambler's ruin}} = 1-1/b$$ This is the point where there is no solution for $c$ below one. This is also the point where the increasing steps $a_w$ are smaller than the decreasing steps $a_l$.
Thus, for $b=2$, as long as the gambler bets less than half the money then the gambler will not certainly go bankrupt.
do the odds of losing all your money decrease or increase over time?
The probability to go bankrupt is dependent on the distance from the amount of money where the gambler goes bankrupt. When $q<q_{\text{gambler's ruin}}$ the gambler's money will, on average increase, and the probability to go bankrupt will, on average, decrease.
Bankruptcy probability when using the Kelly criterion.
When you use the Kelly criterion mentioned in Dave Harris answer, $q = 0.5(1-1/b)$, for $b$ being the ratio between loss and profit in a single bet, then independent from $b$ the value of $c$ will be equal to $0.1$ and the probability to go bankrupt will be $0.1^{Y_0-Y_L}$....
Derivation: if $c=0.1$, with $a_w = \log_{10}(1+bq)$ and $a_l = \log_{10}(1-q)$, then $$c^{a_w}+c^{a_l} = 0.1^{\log(1+bq)}+0.1^{\log(1-q)} = \frac{1}{1+bq} + \frac{1}{1-q} $$ which equals 2 when we fill in $q=0.5\frac{b-1}{b}$.
...That is, independent from the assymetry parameter $b$ of the magic tree, the probability to go bankrupt, when using the Kelly criterion, is equal to the ratio of the amount of money where the gambler goes bankrupt and the amount of money that the gambler starts with. For ten dollars and 1 cent this is a 1:1000 probability to go bankrupt, when using the Kelly criterion.
Simulations
The simulations below show different simulated trajectories for different gambling strategies. The red trajectories are ones that ended up bankrupt (hit the line $Y_t=-2$).
Distribution of profits after time $t$
To further illustrate the possible outcomes of gambling with the money tree, you can model the distribution of $Y_t$ as a one dimensional diffusion process in a homogeneous force field and with an absorbing boundary (where the gambler get's bankrupt). The solution for this situation has been given by Smoluchowski
Smoluchowski, Marian V. "Über Brownsche Molekularbewegung unter Einwirkung äußerer Kräfte und deren Zusammenhang mit der verallgemeinerten Diffusionsgleichung." Annalen der Physik 353.24 (1916): 1103-1112. (online available via: https://www.physik.uni-augsburg.de/theo1/hanggi/History/BM-History.html)
Equation 8:
$$ W(x_0,x,t) = \frac{e^{-\frac{c(x-x_0)}{2D} - \frac{c^2 t}{4D}}}{2 \sqrt{\pi D t}} \left[ e^{-\frac{(x-x_0)^2}{4Dt}} - e^{-\frac{(x+x_0)^2}{4Dt}} \right]$$
This diffusion equation relates to the tree problem when we set the speed $c$ equal to the expected increase $E[Y_t]$, we set $D$ equal to the variance of the change in a single steps $\text{Var}(X_t)$, $x_0$ is the initial amount of money, and $t$ is the number of steps.
The image and code below demonstrate the equation:
The histogram shows the result from a simulation.
The dotted line shows a model when we use a naive normal distribution to approximate the distribution (this corresponds to the absence of the absorbing 'bankruptcy' barrier). This is wrong because some of the results above the bankruptcy level involve trajectories that have passed the bankruptcy level at an earlier time.
The continuous line is the approximation using the formula by Smoluchowski.
Codes
#
## Simulations of random walks and bankruptcy:
#
# functions to compute c
cx = function(c,x) {
c^log(1-x,10)+c^log(1+2*x,10) - 2
}
findc = function(x) {
r <- uniroot(cx, c(0,1-0.1^10),x=x,tol=10^-130)
r$root
}
# settings
set.seed(1)
n <- 100000
n2 <- 1000
q <- 0.45
# repeating different betting strategies
for (q in c(0.35,0.4,0.45)) {
# plot empty canvas
plot(1,-1000,
xlim=c(0,n2),ylim=c(-2,50),
type="l",
xlab = "time step", ylab = expression(log[10](M[t])) )
# steps in the logarithm of the money
steps <- c(log(1+2*q,10),log(1-q,10))
# counter for number of bankrupts
bank <- 0
# computing 1000 times
for (i in 1:1000) {
# sampling wins or looses
X_t <- sample(steps, n, replace = TRUE)
# compute log of money
Y_t <- 1+cumsum(X_t)
# compute money
M_t <- 10^Y_t
# optional stopping (bankruptcy)
tau <- min(c(n,which(-2 > Y_t)))
if (tau<n) {
bank <- bank+1
}
# plot only 100 to prevent clutter
if (i<=100) {
col=rgb(tau<n,0,0,0.5)
lines(1:tau,Y_t[1:tau],col=col)
}
}
text(0,45,paste0(bank, " bankruptcies out of 1000 \n", "theoretic bankruptcy rate is ", round(findc(q)^3,4)),cex=1,pos=4)
title(paste0("betting a fraction ", round(q,2)))
}
#
## Simulation of histogram of profits/results
#
# settings
set.seed(1)
rep <- 10000 # repetitions for histogram
n <- 5000 # time steps
q <- 0.45 # betting fraction
b <- 2 # betting ratio loss/profit
x0 <- 3 # starting money
# steps in the logarithm of the money
steps <- c(log(1+b*q,10),log(1-q,10))
# to prevent Moiré pattern in
# set binsize to discrete differences in results
binsize <- 2*(steps[1]-steps[2])
for (n in c(200,500,1000)) {
# computing several trials
pays <- rep(0,rep)
for (i in 1:rep) {
# sampling wins or looses
X_t <- sample(steps, n, replace = TRUE)
# you could also make steps according to a normal distribution
# this will give a smoother histogram
# to do this uncomment the line below
# X_t <- rnorm(n,mean(steps),sqrt(0.25*(steps[1]-steps[2])^2))
# compute log of money
Y_t <- x0+cumsum(X_t)
# compute money
M_t <- 10^Y_t
# optional stopping (bankruptcy)
tau <- min(c(n,which(Y_t < 0)))
if (tau<n) {
Y_t[n] <- 0
M_t[n] <- 0
}
pays[i] <- Y_t[n]
}
# histogram
h <- hist(pays[pays>0],
breaks = seq(0,round(2+max(pays)),binsize),
col=rgb(0,0,0,0.5),
ylim=c(0,1200),
xlab = "log(result)", ylab = "counts",
main = "")
title(paste0("after ", n ," steps"),line = 0)
# regular diffusion in a force field (shifted normal distribution)
x <- h$mids
mu <- x0+n*mean(steps)
sig <- sqrt(n*0.25*(steps[1]-steps[2])^2)
lines(x,rep*binsize*(dnorm(x,mu,sig)), lty=2)
# diffusion using the solution by Smoluchowski
# which accounts for absorption
lines(x,rep*binsize*Smoluchowski(x,x0,0.25*(steps[1]-steps[2])^2,mean(steps),n))
}