Skip to content

Instantly share code, notes, and snippets.

@dsetzer
Last active August 18, 2019 18:56
Show Gist options
  • Save dsetzer/d97a5f80e7f53cb27cb82ab3049c1a50 to your computer and use it in GitHub Desktop.
Save dsetzer/d97a5f80e7f53cb27cb82ab3049c1a50 to your computer and use it in GitHub Desktop.
/**
* purzi's Martingale bot V0.1
*/
const baseBet = 200 // how many satoshis to bet initially
const target = 2.75 // target multiplier
const betMultiplier = 1.7 // what to multiply the bet size by when we lose a wager
const maxBet = 200000 // Maximum bet in satoshis
var bet
let lossCount = 0
this.log(`Starting martingale with a base bet of ${baseBet} satoshis.`)
while (lossCount < 3)
{
// make the bet and wait for the result
const { multiplier } = await this.bet(betSize(lossCount), target+(lossCount/100))
if (multiplier < target)
{ // loss
if(bet >= maxBet)
{
lossCount = 0
this.log(`Cut our losses and run!`)
}
else
{
lossCount++
this.log(`Lost bet. Multiplying bet size by ${betMultiplier} for new bet size of ${betSize(lossCount)} satoshis.`)
}
}
else
{ // win
lossCount = 0
this.log(`Won bet. Setting bet size to ${baseBet} satoshis.`)
}
}
function betSize(lossCount)
{
bet = baseBet * Math.pow(betMultiplier, lossCount)
return bet > maxBet ? maxBet : Math.round(bet / 100) * 100
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment