Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # run.py
- #
- # Copyright 2013 [mad]Berry <[email protected]>
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- #
- ###
- ### Please send donations to [mad]Berry:
- #btc: 1Q2QDC78uaGgkm4r3G5YzZSriPv7KMUuQU
- #ltc: Lb5TUyhdUtqsExLmiyqCLAiBZUrs8mEYze
- ### Thanks.
- ### Nikki's addresses, if you're feeling extra generous:
- #btc: 1J18oi6EdWALyFyk9mbNMmiZnbtyHSERPu
- #ltc: LSt4C729DmykfRKAUi7ijjyryt75awBkC2
- #
- #
- # About this fork:
- # [mad]Berry wrote a cool script, but it was completely different from my understanding
- # of what Martingale is. There was too much randomness for me. So I rewrote most of it
- # such that it behaves more like the popular definition of Martingale. It will follow the
- # common last_bet^2 formula in an attempt to win back any losses (when the payout is 2.0x,
- # the formula is actually (((multiplier - 1) * initial_bet) + round_bet) / (multiplier - 1)))
- # where round_bet is the amount you've bet since you began losing).
- #
- # I hope someone's able to make some use of it. Please be aware though, after many simulations
- # of the different payouts and percents to win offered by coinroll.it, a Martingale strategy is
- # nearly always beaten by a maximum bet set only a few percent lower than the highest bet the strategy
- # would commonly need to make. This is likely very deliberate on coinroll.it's part. I wouldn't
- # try to make money with this.
- #
- # Also, there's a small C# simulation program I wrote up here: http://pastebin.com/yjv4V08f
- # I'd recommend changing it to use something other than doubles, as there are rounding errors.
- #
- ### Good luck.
- # Variables used to run the script
- user='' # userid from the site
- password = '' # password from the site
- initial_bet = 1000 # Your starting bet
- less_than = 60000 # The number you're betting on
- max_iter = 8 # Setting this too low will cause the bot to write off a lot of losses
- # For example, if we're using 50% odds with a 2x payout and a 1000 Satoshi
- # bet, 8 iterations would equal a 128000 Satoshi bet, after which if the bot
- # doesn't win, it'll go back to a 1000 Satoshi bet and start the process over.
- # Set this > 15 to effectively ignore it with most current bets
- max_loss = 0.75 # balance <= initial_balance * max_loss, 0.75 means 25% loss
- address = '' # Receive address
- #-------Any changes below this line might break the script------
- import urllib2,urllib,os,random,math,atexit,time
- from sys import stdout
- from datetime import datetime
- __prog__ = "coinroll.it automated gambling script"
- __scriptname__ = "run.py"
- __author__ = "[mad]Berry"
- __date__ = "$May 07, 2013 17:10:45 PM$"
- __version__ = "1.0.04 - Nikki's fork 0.1.03"
- start_time = datetime.now()
- stdscr = 0
- hasCurses = False
- class Error(Exception):
- pass
- def module_exists(module_name):
- try:
- __import__(module_name)
- except ImportError:
- return False
- else:
- return True
- def cls():
- os.system(['clear','cls'][os.name == 'nt'])
- def initCurses():
- global stdscr
- stdscr = curses.initscr()
- curses.noecho()
- curses.cbreak()
- stdscr.keypad(1)
- @atexit.register
- def exitF():
- if(hasCurses):
- endCurses()
- def endCurses():
- curses.nocbreak()
- curses.echo()
- stdscr.keypad(0)
- curses.endwin()
- def perHour():
- dt = datetime.now() - start_time
- ms = (dt.days * 24 * 60 * 60 + dt.seconds) * 1000 + dt.microseconds / 1000.0
- return 3600000.0 / ms
- def cout(out, y, x):
- if(hasCurses):
- stdscr.addstr(y, x, out)
- stdscr.refresh()
- else:
- #sorry Windows...python really isn't my thing..
- cls()
- print out
- def call(api_url, **kwargs):
- try:
- baseurl = 'https://coinroll.it/'
- api_url = baseurl + api_url
- data = urllib.urlencode(kwargs) #({'user': user, 'password': password})
- header = {
- "Content-type": "application/x-www-form-urlencoded",
- "User-Agent" : "Coinroll Martingale by "+__author__+" Version "+ __version__
- }
- req = urllib2.Request(api_url, data, header)
- response = urllib2.urlopen(req)
- result = response.read()
- result = simplejson.loads(result)
- if 'error' in result:
- # An error occurred; raise an exception
- raise Error({'message': result['error']})
- time.sleep(2.5)
- exit(1)
- return result
- except Exception, e:
- out = data
- out += '\n' + e.args[0]['message']
- cout(out, 0, 0)
- time.sleep(2.5)
- exit(1)
- def main():
- cout("Starting", 0, 0)
- resultgameinfo = call('getgameinfo', lessthan=less_than)
- multiplier = resultgameinfo['multiplier']
- resultbalance = call('getbalance', user=user, password=password)
- initial_balance = resultbalance['balance']
- profit = 0
- bet = initial_bet
- round_bet = 0
- withdrawn = 0
- iters = 0
- while True:
- result = call('bet',user=user, password=password, lessthan=less_than,amount=bet)
- balance = result['balance']
- profit += result['diff']
- if (result['win'] == True):
- bet = initial_bet
- round_bet = 0
- iters = 0
- else:
- round_bet += bet
- bet = int(math.ceil((((multiplier - 1) * initial_bet) + round_bet) / (multiplier - 1)))
- iters += 1
- if(iters >= max_iter):
- bet = initial_bet
- round_bet = 0
- iters = 0
- if(balance > initial_balance * 2):
- withdraw = balance - initial_balance
- resultwithdraw = call('withdraw', user=user, password=password, address=address, amount=withdraw)
- balance = resultwithdraw['balance']
- withdrawn += withdraw
- if((balance <= 0 or bet > balance) or balance <= initial_balance * max_loss):
- exit('Balance too low.')
- output = "Multiplier:\t\t\t{5:.3f}\nInitial Balance:\t\t{6:.8f}\nIn Play Balance:\t\t{0:.8f}\nCurrent Bet:\t\t\t{1:.8f}\nWithdraw:\t\t\t{2:.8f}\nTotal:\t\t\t\t{3:.8f}\nBTC/Hour:\t\t\t{4:.8f}\nIterations:\t\t\t{7}\n".format(float(balance) / 100000000, float(bet) / 100000000, float(withdrawn) / 100000000, float(balance + withdrawn) / 100000000, float(profit * perHour()) / 100000000, multiplier, float(initial_balance) / 100000000, iters)
- cout(output, 0, 0)
- return 0
- if __name__ == '__main__':
- if(module_exists('curses')):
- import curses
- hasCurses = True
- else:
- hasCurses = False
- if(module_exists('simplejson')):
- import simplejson
- else:
- exit("Please download and install simplejson from: https://pypi.python.org/pypi/simplejson")
- if(hasCurses):
- initCurses()
- try:
- main()
- except KeyboardInterrupt:
- exit("Bye Bye")
Advertisement
Add Comment
Please, Sign In to add comment