Skip to content

Instantly share code, notes, and snippets.

@ruzli
Created September 15, 2018 13:37
Show Gist options
  • Save ruzli/0c19088c885d5d36516f14af5886a7d0 to your computer and use it in GitHub Desktop.
Save ruzli/0c19088c885d5d36516f14af5886a7d0 to your computer and use it in GitHub Desktop.
Greedy Scrooge
const baseBet = 1 /* Just starting value in bit, will recalculated automatically according balance divide 100 * percentBet value */
const baseTarget = 1.1 /* Place bets with this odd */
var percentBet = 1 /* Percent from balance to play on */
const multiplierBet = 3 /* Recovery from loss on 1.1x */
const baseDelay = 2 /* To prevent bad streaks */
const baseSkips = 29 /* Skip bad periods */
const maximumQueue = 1
const regularBet = 1
const regularTarget = 1.01
const engine = this
const LossProfitDivider = 2
const maximumBet = 512 //balanceBasedBet() * multiplierBet
const maxLoss = 1000 // toBits(this.balance ) / LossProfitDivider /* Maximum loss until script will turn off */
const maxProfit = 10000 //toBits(this.balance ) * LossProfitDivider /* Maximum profit until script will turn off */
var startingBalance = toBits(this.balance)
let restoreQueue = 1
const baseMemory = 5
let loss = 0
let bet = 1
let delay = 0
let skips = baseSkips
let target = baseTarget
var memory = 0
engine.log(`You regular bet will be ${Math.round(balanceBasedBet())} bits.`)
while(true){
await checkConditions()
if (bet > maximumBet){bet = maximumBet}
if (bet <= 1){ bet = balanceBasedBet()}
if (loss > 0 ){
var { multiplier } = await engine.bet(toSatoshi(bet), target)
} else {
var { multiplier } = await engine.bet(toSatoshi(regularBet), regularTarget)
}
if (multiplier < baseTarget){ /* LOST */
//await generateSeed()
percentBet++
this.log(percentBet)
newQueue()
loss++
delay++
if (delay >= baseDelay){
for (let i = 0; i < randomValue(2,skips); i++){
await engine.skip()
loss = 0
}
}
engine.log(`Current balance: ${Math.floor(toBits(engine.balance))}/${Math.floor(startingBalance)}`)
if (toBits(engine.balance) < startingBalance){
bet = (balanceBasedBet() * restoreQueue) * multiplierBet
}else{
bet = balanceBasedBet()
startingBalance = toBits(engine.balance)
}
if (memory < 1){
memory = baseMemory
if (restoreQueue < 1){
restoreQueue = 1
}
restoreQueue = restoreQueue - 1
}
}else{ /* WIN */
loss = 0
delay = 0
if(target != regularTarget){
memory--
percentBet = 1
}
}
}
function betQueue(){
if ( restoreQueue > 1){
percentBet++
memory--
} else{
percentBet = 1
}
return Math.round(percentBet * ((engine.balance / 100) / 100))
}
function newQueue(){
engine.log(`Restoring lost bits, queue ${restoreQueue}`)
memory = baseMemory
restoreQueue++
if (restoreQueue >= maximumQueue){
restoreQueue = maximumQueue
}
}
function toSatoshi(bits){
return bits * 100
}
function toBits(satoshi){
return satoshi / 100
}
function balanceBasedBet(){
return Math.round(percentBet * ((engine.balance / 100) / 100))
}
async function generateSeed(){
const { server_seed_hash } = await engine.newSeedPair()
try {
const clientSeed = randomSeed()
await engine.setClientSeed(clientSeed)
}
catch(e){
engine.log(e)
}
}
function randomSeed(){
const words = ['Alegra ','Bravon ','Charlik ','Delago ','Zecho ','Forextromb ','Hotelka ','Gnomus ','Addicted ','Aurelia ','Zigalo ','Wiverma ',
'Mariner ','Octoberfest ','Nascar ','Papaja ','Alberts ','Gomus ','Fierra ','GTO ','Unicorn ','Vicantus ','Siski ','Xavier ','Poiuplet ','Antutulika ']
return words[Math.floor(words.length * Math.random())] + words[Math.floor(words.length * Math.random())] + words[Math.floor(words.length * Math.random())]
}
async function checkConditions(){
if (maxLoss >= toBits(engine.balance)){
engine.log(`Script have stopped due meet minimal balance to run.`)
await engine.stop()
}
if (maxProfit <= toBits(engine.balance)){
engine.log(`Script have made profit you set. Stopping now.`)
await engine.stop()
}
}
function randomValue(min, max){
return Math.floor(Math.random() * (max - min)) + min;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment