Transaction

ef47dcc7d7c42e88431635ff436ad6c689ac62d1a095e5a22b08eb09e858105c
2023-12-12 05:33:06
0.00004634 BSV
(
0.99900432 BSV
-
0.99895798 BSV
)
881.9 sat/KB
1
85,611
5,254 B

2 Outputs

Total Output:
0.99895798 BSV
  • v© ‡t²}®k/“En<Ë̱Aˆ¬cordQ text/htmlM<!DOCTYPE html> <html lang="en"> <head> <title>Kelly Criterion Calculator</title> <style> body { font-family: Arial, Helvetica, sans-serif; text-align: center; margin-left: 25%; margin-right: 25%; } h1 { text-align: center; } h2 { text-align: center; } #visualization { margin: 0 auto; width: 400px; height: 200px; } </style> </head> <body> <h1>Kelly Criterion Calculator</h1> <p>The Kelly Criterion formula helps determine the optimal amount to bet based on your chance of winning and the odds. It maximizes the expected logarithm of wealth (long-term growth of capital).</p> <p>Enter your values. For example, if you have a 60% chance of winning (p = 0.6) and the odds are 2.0 (you win double your bet), the formula calculates the fraction of your bankroll you should wager.</p> <label for="probabilityWin">Probability of Win (p):</label> <input type="number" id="probabilityWin" min="0" max="1" step="0.01" placeholder="e.g., 0.6"><br><br> <label for="odds">Odds (b):</label> <input type="number" id="odds" min="1" step="0.01" placeholder="e.g., 2.0"><br><br> <button id="calculateButton">Calculate</button> <div id="visualization"></div> <h2>Result:</h2> <p id="result"></p> <p id="bankrollExample"></p> <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script> <script> let points = []; // Array to store the points to be plotted function setup() { let canvas = createCanvas(400, 200); canvas.parent('visualization'); noLoop(); // Ensure that the draw loop does not continuously execute background(255); drawAxesAndCurve(); // Draw the axes and base curve } // Function to draw the axes and the base curve function drawAxesAndCurve() { // Draw the axes stroke(0); line(20, 180, 380, 180); // x-axis line(20, 180, 20, 20); // y-axis textAlign(CENTER, CENTER); textSize(12); text('Amount Gained with a Win', 200, 195); // x-axis label text('Fraction of Portfolio to Bet', 10, 10); // y-axis label // Draw the base curve for the Kelly Criterion drawKellyCurve(); } // Function to draw the base Kelly Criterion curve function drawKellyCurve() { noFill(); stroke(255, 0, 0); // Red color for the curve beginShape(); for (let i = 1; i <= 4; i += 0.05) { // Example range for b let x = map(i, 1, 4, 20, 380); // x position based on b let p = 0.5; // Example probability let q = 1 - p; let fStar = p - (q / i); // Calculate fStar for each point on the curve let y = map(fStar, -1, 1, 180, 20); // y position based on fStar vertex(x, y); } endShape(); } // Function to calculate Kelly Criterion and plot the point function calculateAndPlotKellyCriterion() { let p = parseFloat(document.getElementById('probabilityWin').value); let b = parseFloat(document.getElementById('odds').value); let q = 1 - p; let fStar = p - (q / b); // Add point to the array points.push({ b, fStar }); // Update the result display document.getElementById('result').innerText = `With a ${p * 100}% chance of winning and odds of ${b} to 1, optimal fraction to bet: ${fStar.toFixed(2)}`; document.getElementById('bankrollExample').innerText = `For a $1000 bankroll, bet $${(fStar * 1000).toFixed(2)}`; redraw(); // Redraw the canvas to show the new point } // p5.js draw function function draw() { // Redraw the base graph and all the points background(255); drawAxesAndCurve(); drawPoints(); } // Function to draw all points function drawPoints() { for (let point of points) { let x = map(point.b, 1, 4, 20, 380); let y = map(point.fStar, -1, 1, 180, 20); // Plot the calculated point fill(0, 0, 255); // Blue color for the calculated point ellipse(x, y, 10, 10); // Label the point fill(255, 0, 0); noStroke(); textSize(10); text(`(${point.b.toFixed(2)}, ${point.fStar.toFixed(2)})`, x + 10, y - 10); } } // HTML button event listener document.getElementById('calculateButton').addEventListener('click', calculateAndPlotKellyCriterion); </script> </body> </html>h
    https://whatsonchain.com/tx/ef47dcc7d7c42e88431635ff436ad6c689ac62d1a095e5a22b08eb09e858105c