Skip to content

Instantly share code, notes, and snippets.

@st1vms
Created September 7, 2025 15:07
Show Gist options
  • Save st1vms/2d6cc9817c55608d1f9d822e939e4767 to your computer and use it in GitHub Desktop.
Save st1vms/2d6cc9817c55608d1f9d822e939e4767 to your computer and use it in GitHub Desktop.
Sports Betting Arbitrage Calculator (JS)
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<title>Arbitrage Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
label {
display: block;
margin-top: 10px;
}
input {
margin-top: 5px;
padding: 5px;
width: 100px;
}
button {
margin-top: 15px;
padding: 10px 20px;
}
#result {
margin-top: 20px;
padding: 10px;
white-space: pre-line;
}
</style>
</head>
<body>
<h1>Arbitrage Calculator</h1>
<label>Bankroll (EUR):
<input type="number" id="bankroll" value="10" step="0.01">
</label>
<label>Quote 1:
<input type="number" id="odds1" value="0" step="0.01">
</label>
<label>Quote 2:
<input type="number" id="odds2" value="0" step="0.01">
</label>
<label>Quote 3 (optional, leave 0 for 2-way arbitrage):
<input type="number" id="odds3" value="0" step="0.01">
</label>
<button onclick="calculateArbitrage()">Calculate</button>
<div id="result"></div>
<script>
function calculateArbitrage() {
const bankroll = parseFloat(document.getElementById('bankroll').value);
const odds1 = parseFloat(document.getElementById('odds1').value);
const odds2 = parseFloat(document.getElementById('odds2').value);
let odds3 = parseFloat(document.getElementById('odds3').value);
if (!odds3) odds3 = 0;
const resultDiv = document.getElementById('result');
if (odds3 === 0) {
resultDiv.textContent = arbitrageTwo(odds1, odds2, bankroll);
} else {
resultDiv.textContent = arbitrageThree(odds1, odds2, odds3, bankroll);
}
}
function arbitrageTwo(odds1, odds2, bankroll, minBet = 1) {
const inv1 = 1 / odds1;
const inv2 = 1 / odds2;
const arb = inv1 + inv2;
if (arb >= 1) return "No arbitrage...";
const stake1 = bankroll * (inv1 / arb);
const stake2 = bankroll * (inv2 / arb);
if (stake1 < minBet || stake2 < minBet) return "The calculated bets are lower than the minimum bet.";
const payout = stake1 * odds1;
const profit = payout - (stake1 + stake2);
return `Bet ${stake1.toFixed(2)} on quote ${odds1}
Bet ${stake2.toFixed(2)} on quote${odds2}
Profit: ${profit.toFixed(2)}`;
}
function arbitrageThree(odds1, odds2, odds3, bankroll, minBet = 1) {
const inv1 = 1 / odds1;
const inv2 = 1 / odds2;
const inv3 = 1 / odds3;
const arb = inv1 + inv2 + inv3;
if (arb >= 1) return "No arbitrage...";
const stake1 = bankroll * (inv1 / arb);
const stake2 = bankroll * (inv2 / arb);
const stake3 = bankroll * (inv3 / arb);
if (stake1 < minBet || stake2 < minBet || stake3 < minBet) return "The calculated bets are lower than the minimum bet.";
const payout1 = stake1 * odds1;
const payout2 = stake2 * odds2;
const payout3 = stake3 * odds3;
const avgPayout = (payout1 + payout2 + payout3) / 3;
const profit = avgPayout - (stake1 + stake2 + stake3);
return `Bet ${stake1.toFixed(2)} on quote ${odds1}
Bet ${stake2.toFixed(2)} on quote ${odds2}
Bet ${stake3.toFixed(2)} on quote ${odds3}
Profit: ${profit.toFixed(2)}`;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment