Kelly Criterion (House of the Rising Sum)
https://en.wikipedia.org/wiki/Kelly_criterion
There is a criterion in Mathematics
They call the Rising Sum
And it's been the ruin of many a poor investors
Dear God, I know I was one
My mother was a Mathematician
She bought me new shiny HP48SX
And my father was a gamblin' man
Way down in New Orleans
And the only thing a investor needs
Is a suitcase or a trunk of cash
And the only time he's satisfied
Is when he's a drunk
Oh, mother, tell your children
Not to do what I have done
To spend your lives in sums and misery
In the house of the rising sum
The best way to understand Kelly Criterion is to imagine that
you have a choice to buy a lottery ticket
1. The cost of the lottery ticket is "cost of ticket" which is usually $1
2. The chance that the ticket will win is p
3. If the ticket wins, you get back "cost of ticket" plus "profit"
4. Thus the gain of the ticket is "profit"/"cost of ticket"
Kelly says
To get the Maximum Rate of Return
1. you need a bankroll (or a trunk of cash)
2. you should invest a fraction f of your bankroll each time
specifically
gain = profit_per_ticket/cost_of_ticket
f = p - (1-p)/gain
or as wikipedia puts it
If you ask the investors what they want, they would say they
absolutely want to avoid a loss
So Here is the source to find the chances/probability of making a loss
But Beware because this is where almost ALL Real World Investors trip up:
The real problem with Kelly Criterion in the Real World is that it expects that you know the TRUE probability of winning. But you do not. You will NEVER know the TRUE probability. You can only estimate the probability of winning based on the data you have. So your estimate of the TRUE probability of winning has a degree of uncertainty. See the wikipedia article of estimating the probability of a coin toss.
Another problem is that the TRUE probability of winning could be changing over time in the real world as the real world environment changes. Ohanian (talk) 06:02, 18 May 2024 (UTC)
using StableRNGs,Printf
rng = StableRNG(1234)
mypath = "/Users/ssiew/juliascript/KellyConstrain"
function calculate_loss(f,p,g;numtimes=10)
times = numtimes
losses = 0
while times > 0
times -= 1
# Actual loop
games = 100
bankroll = 1.0
while games > 0
games -= 1
# actual loop
stake = f * bankroll
if rand(rng) > p
bankroll -= stake
else
bankroll += g * stake
end
end
if bankroll < 1.0
losses += 1
end
end
return losses/numtimes
end
function output_gain_table(a_profit_per_ticket,a_cost_of_ticket;numtimes=1_000_000)
global mypath
println("Start of result")
cost_of_ticket = a_cost_of_ticket
profit_per_ticket = a_profit_per_ticket
gain = profit_per_ticket/cost_of_ticket
rounded_gain = round(gain,digits=1)
str_rounded_gain = string(rounded_gain)
fid = open("$(mypath)/perfectinfo_gain_$(str_rounded_gain).txt","w")
for percentage = 0:99
# Calculate f for Kelly Criterion
p = percentage/100.0
cost_of_ticket = a_cost_of_ticket
profit_per_ticket = a_profit_per_ticket
gain = profit_per_ticket/cost_of_ticket
f = p - (1-p)/gain
# Check if f is negative
if f < 0
prob_loss = 0.0
# set f to zero
f = 0.0
else
prob_loss=calculate_loss(f,p,gain,numtimes=numtimes)
end
rounded_f = round(f,sigdigits=4)
rounded_prob_loss = round(prob_loss,sigdigits=4)
# println(p,",",rounded_f,",",rounded_prob_loss)
@printf("%-4.2f,%-6.4f,%-6.4f\n",p,rounded_f,rounded_prob_loss)
@printf(fid,"%-4.2f,%-6.4f,%-6.4f\n",p,rounded_f,rounded_prob_loss)
flush(fid)
end
close(fid)
end
println("profit per ticket = 3.0 cost of ticket = 1.0")
println("p,f,probability_of_loss")
output_gain_table(3.0,1.0)