) is for announcements I am posting here. Even though it's a reply to kakobrekla's post in other thread.
#!/usr/bin/python
# bitbets.py
# GPL v3 license
# send bug reports to
[email protected]# send donations to: 1MtpRjRUNXhPUY89Ah9vZ3jcdSVwS7oXGn
import copy
import readline
global text
global won_weight_bet
global added_bets
text=[]
won_weight_bet=[]
added_bets=[]
def start():
print("==================== bitbet analyzer ====================")
print("Welcome!")
print("If you find this small program useful or win something, please")
print("send donations to: 1MtpRjRUNXhPUY89Ah9vZ3jcdSVwS7oXGn\n")
print("Paste raw data as seen on http://bitbet.us/")
print("in the table just under \"CONFIRMED BETS\"")
print("(enter blank line twice to finish)")
line="start"
global text
global won_weight_bet
global added_bets
text=[]
won_weight_bet=[]
added_bets=[]
errors=0
while(line!="\n"):
try:
import sys
sys.stdout.write("["+str(len(text)-errors)+"] ")
line = sys.stdin.readline()
if(line!="\n"):
text.append(line)
if(len(line.split()) >= 5):
won_weight_bet.append((
line.split()[2],
int(line.split()[3].replace("`","")),
float(line.split()[4])))
else:
sys.stdout.write("something is wrong, please paste carefully\n")
errors = errors+1
except:
sys.stdout.write("something is wrong, please paste carefully\n")
errors = errors+1
print("data enetered correctly, type 'help' for help")
def str8(arg):
res=str('%.8f'%arg)
res=" "*(13 - len(res))+res
return res
def str5(arg): return str('%5i'%arg)
def str3(arg): return str('%3i'%arg)
def inp():
for a in range(len(text)):
print("["+str(a)+"] "+text[a])
def wwb():
global text
global won_weight_bet
print("[ ] won weight bet")
for a in range(len(won_weight_bet)):
won = won_weight_bet[a][0]
weight= won_weight_bet[a][1]
bet = won_weight_bet[a][2]
print("["+str3(a+1)+"] "+("No " if won=="No" else "Yes")+" "
+ str5(weight) + " "+str8(bet))
def win(res,N=0):
global text
global won_weight_bet
global added_bets
print("[ ] won weight bet winning net win net loss")
losers=0
bet_weight_sum=0
for a in range(len(won_weight_bet)):
won = ((True if won_weight_bet[a][0]=="Yes" else False) == res)
weight= won_weight_bet[a][1]
bet = won_weight_bet[a][2]
if(not won):
losers = losers + bet
else:
bet_weight_sum = bet_weight_sum + bet*weight
if(N<0): N=len(won_weight_bet)+N
net=0
for a in range(len(won_weight_bet)):
won_ = won_weight_bet[a][0]
won = ((True if won_weight_bet[a][0]=="Yes" else False) == res)
weight = won_weight_bet[a][1]
bet = won_weight_bet[a][2]
winning = ( (bet+losers*bet*weight/bet_weight_sum)*0.99 if won else 0 )
if(a>=N):
net = net + winning - bet
print("["+str3(a+1)+"] "+("No " if won_=="No" else "Yes")+" "
+ str5(weight) + " "+str8(bet) + " "
+ ( str8(winning) if (winning!=0) else (" ") ) + " "
+ ((str8(winning - bet ) + " ") if ((winning - bet)>0) else (" " + str8(winning - bet )))
+ " "
+ ( ( "total:"+str8(net) ) if ((N == len(won_weight_bet)-2) and (a == len(won_weight_bet)-1) ) else " ")
+ ((" (*)") if (a in added_bets) else ( ((" (+)") if ((-1*a) in added_bets) else ( " " )) )) )
def help():
print("help|h - help")
print("reset|res|r - start working on a new bet")
print("inp - print raw input data")
print("bets - show current bets")
print("win yes|no - see what happens when bet is resolved to yes|no")
print("bet yes|no weight BTC - see what you can win if you place a new bet")
print("bett yes|no weight BTC - same as above, but print everyone's results - marked with (+)")
print("bet yes weight BTC no BTC - place double bet on both sides, see what happens")
print("add bet yes|no weight BTC - permanently add a bet to table - marked with (*)")
print("quit|q CTRL-\ - quit")
cmd=""
start()
#global text
#global won_weight_bet
#global added_bets
while(cmd!="quit" and cmd!="q"):
try:
cmd = raw_input("> ")
if(cmd!=""):
if(cmd.split()[0] == "help" or cmd.split()[0] == "h"): help()
if(cmd.split()[0] == "res" or cmd.split()[0] == "reset" or cmd.split()[0] == "r"): start()
if(cmd.split()[0] == "inp"): inp()
if(cmd.split()[0] == "bets"): wwb()
if(cmd.split()[0] == "win"):
if(len(cmd.split())==2):
if(cmd.split()[1] == "yes"): win(True)
if(cmd.split()[1] == "no"): win(False)
else:
print("win yes|no")
if(cmd.split()[0] == "bet" or cmd.split()[0] == "bett"):
if(len(cmd.split())==4):
if(cmd.split()[1] == "yes"):
tmp = ( copy.deepcopy(won_weight_bet) , copy.deepcopy(added_bets) )
won_weight_bet.append(( "Yes",
int(cmd.split()[2]),
float(cmd.split()[3])))
if(cmd.split()[0] == "bett"):
added_bets.append( -1*(len(won_weight_bet)-1) )
win(True)
else:
win(True,-1)
won_weight_bet , added_bets = copy.deepcopy(tmp)
if(cmd.split()[1] == "no"):
tmp = ( copy.deepcopy(won_weight_bet) , copy.deepcopy(added_bets) )
won_weight_bet.append(( "No",
int(cmd.split()[2]),
float(cmd.split()[3])))
if(cmd.split()[0] == "bett"):
added_bets.append( -1*(len(won_weight_bet)-1) )
win(False)
else:
win(False,-1)
won_weight_bet , added_bets = copy.deepcopy(tmp)
elif(len(cmd.split())==6 and cmd.split()[1] == "yes"):
tmp = copy.deepcopy(won_weight_bet)
won_weight_bet.append(( "Yes",
int(cmd.split()[2]),
float(cmd.split()[3])))
won_weight_bet.append(( "No",
int(cmd.split()[2]),
float(cmd.split()[5])))
print("result: YES")
win(True,-2)
print("result: NO")
win(False,-2)
won_weight_bet=copy.deepcopy(tmp)
else:
print("bet yes|no weight sum\nbet yes weight sum no sum")
if(cmd.split()[0] == "add" and len(cmd.split())==5 and cmd.split()[1] == "bet"):
if(cmd.split()[2] == "yes"):
won_weight_bet.append(( "Yes",
int(cmd.split()[3]),
float(cmd.split()[4])))
added_bets.append(len(won_weight_bet)-1)
win(True)
if(cmd.split()[2] == "no"):
won_weight_bet.append(( "No",
int(cmd.split()[3]),
float(cmd.split()[4])))
added_bets.append(len(won_weight_bet)-1)
win(False)
except:
print("wrong command, check 'help'")
And I was looking for possible bet outcomes.
(BetAmount + (LosersBtcSum / WinnersWeightedBtcSum) * ( BetAmount * BetWeight ) )*0.99
I have found that it is possible to abuse rewards if someone is rich and don't mind losing few bitcoins. The method is simple, bet so much, that the 1% fee is larger than total LosersBtcSum.
Now lets say, that someone places a bet of 42 BTC with weight 25000 (that would happen today). His net winning would be quite nice: 1.02 BTC:
The (*) marks freshly placed bet.
Next someone rich decides, that he doesn't want anybody to win this bet, and decides to lose 6 BTC on that, he places a bet of 770 BTC with weight 20000, and here's what we get:
If you take 2% fee from losers only, instead of 1% from everyone, this problem would not occur.
Moreover, you are welcome to use my small python program and send me some donations if you like it!