-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathKellyC.html
111 lines (104 loc) · 5.84 KB
/
KellyC.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<head>
<body>
<script type="text/javascript">
function kellyBet(form) {
// Convert Input Variables to Numeric Values
PROB = eval(form.PROB0.value); // Probability
ODDS = eval(form.ODDS1.value); // Odds
BANK = eval(form.BANK2.value); // Bankroll
HK = eval(form.HK3.value); // Adjusted Kelly
// Calculate values
KC = ((PROB*(ODDS+1)-1)/ODDS)*HK; // Kelly Criterion (Adjusted)
F = KC*BANK; // Bet This Much (Adjusted)
// Output Calculated Values to Form
form.KC.value = decimalFP(KC, 4);
form.F.value = decimalFP(F, 2);
} // End kellyBet function.
function decimalFP(fpNum,d) {
// This function will format a float to show desired number of decimal places.
fpNum = Math.round(fpNum*Math.pow(10,d))/Math.pow(10,d);
str = fpNum.toString();
i = str.indexOf(".");
if (i>-1) {
dif = str.length - i;
while (dif<(d+1)) {
str += "0";
dif = str.length - i;
}
} else {
str += ".";
for (k=0;k<d;k++) {
str += "0";
}
}
return str;
} // End decimalFP function.
</script>
<style>
input[type=button], input[type=reset] {
padding: 5px;
margin-left: 10px;
margin-right: 10px;
font-size: 35px;
}
</style>
<form name="If you're reading this, Hi there -MKultra">
<table style="border: 7px solid #000000; margin-left: auto; margin-right: auto; width: 100%;" cellspacing="3">
<tbody>
<tr style="background: #afeaee;">
<th style="text-align: center; vertical-align: center; font-size: 1.8em; color: #000000; padding: 4px;" colspan="2">Kelly Criterion, "Optimal" Bet Calculator</th>
</tr>
<tr style="background: #a8d1db;">
<th style="text-align: left; vertical-align: center; font-size: x-large; font-weight: bold; padding: 4px;">Input Data</th>
<th style="text-align: right; vertical-align: center; font-size: x-large; font-weight: bold; padding: 4px;">Values</th>
</tr>
<tr style="background: #f8fadb;">
<th style="text-align: left; vertical-align: center; font-weight: bold; padding: 4px;">Probability: Ex: coin flip is .5 </th>
<td style="text-align: right; vertical-align: center; font-weight: bold; padding: 4px;"><input style="text-align: right; vertical-align: center;" name="PROB0" size="15" type="text" value=".5" /></td>
</tr>
<tr style="background: #b3d6ae;">
<th style="text-align: left; vertical-align: center; font-weight: bold; padding: 4px;">Odds: Reward or Payout/ Initial Bet Size (R-Multiple).</th>
<td style="text-align: right; vertical-align: center; font-weight: bold; padding: 4px;"><input style="text-align: right; vertical-align: center;" name="ODDS1" size="15" type="text" value="2" /></td>
</tr>
<tr style="background: #f8fadb;">
<th style="text-align: left; vertical-align: center; font-weight: bold; padding: 4px;">Bankroll: Total potential allocated capital . (USD)</th>
<td style="text-align: right; vertical-align: center; font-weight: bold; padding: 4px;"><input style="text-align: right; vertical-align: center;" name="BANK2" size="15" type="text" value="1000" /></td>
</tr>
<tr style="background: #b3d6ae;">
<th style="text-align: left; vertical-align: center; font-weight: bold; padding: 4px;">Adjusted Kelly: Depending on risk appetite and bankroll, you may want to reduce volitility by choosing 1, .5, .25.</th>
<td style="text-align: right; vertical-align: center; font-weight: bold; padding: 4px;"><input style="text-align: right; vertical-align: center;" name="HK3" size="15" type="text" value="1" /></td>
</tr>
</tbody>
</table>
</br /></br />
<table style="border: none; margin-left: auto; margin-right: auto; width: 100%;" cellspacing="0">
<tbody>
<tr>
<th style="text-align: center; vertical-align: center;"><input type="button" value="Calculate" onclick="kellyBet(this.form);" /><input type="reset" /></th>
</tr>
</tbody>
</table>
</br /></br />
<table style="border: 7px solid #333333;">
<tbody>
<tr style="background: #3B3A4A;">
<th style="text-align: center; vertical-align: center; font-size: larger; font-weight: bold; color: #f8fadb; padding: 4px;" colspan="2">Kelly Criterion Calculation Results</th>
</tr>
<tr style="background: #f8fadb; border: 7px solid #000000;">
<th style="text-align: left; vertical-align: center; font-size: x-large; font-weight: bold; padding: 4px;">Calculated Results</th>
<th style="text-align: right; vertical-align: center; font-size: xx-large; color: #000000; font-weight: bold; padding: 4px;">Values</th>
</tr>
<tr style="background: #f8fadb;">
<th style="text-align: left; vertical-align: center; font-weight: bold; padding: 4px;">Kelly Criterion (Adjusted)</th>
<td style="text-align: right; vertical-align: center; padding: 8px;"><input style="text-align: right; vertical-align: center;" name="KC" size="15" type="text" /></td>
</tr>
<tr style="background: #f8fadb;">
<th style="text-align: left; vertical-align: center; font-weight: bold; padding: 4px;">Bet This Much (Adjusted)</th>
<td style="text-align: right; vertical-align: center; padding: 4px;"><input style="text-align: right; vertical-align: center;" name="F" size="15" type="text" /></td>
</tr>
</tbody>
</table>
<span style="text-align: right; font-size: medium; color: #6511c4; font-style: bold;">Always remember the 2% rule associated with <a href="https://en.wikipedia.org/wiki/Gambler%27s_ruin" target="_blank">Gambler's Ruin </a></span>
</form>
<script src="/static/js/iframe-resizer/iframeResizer.contentWindow.min.js"></script>
</body>