Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import time, sys, random
- from math import fsum, sqrt, ceil, floor
- def avg(n):
- return fsum(n)/float(len(n)) if n else 0
- random.seed(time.asctime())
- #print random.randint(1,77)
- bitdiff = float(1496978.5950256)
- hashrate = int(12460411271188)
- #print hashrate
- winestim = 600
- check_prev = 1
- check_preprev = 1
- prices = []
- checks = []
- times = []
- domfees = []
- bitcoms = []
- estim = []
- pdiffs = []
- xtimes = []
- txes = []
- xsteps = []
- txbuff = int(0)
- last = 100000
- firstcheckpoint=int(1)
- start_price = float(0.05)
- def reprice(h):
- global firstcheckpoint
- # print "=====checkpoint @", h
- if firstcheckpoint == 1:
- firstcheckpoint=0
- return old_price
- n_prev = h - check_prev - 1
- n_preprev = check_prev - check_preprev - 1
- if n_prev ==0 and n_preprev ==0:
- return old_price/4
- if n_prev == 0:
- return old_price/4
- if n_preprev == 0:
- return old_price * 4
- ts_prev = times[h-1] - times[check_prev]
- ts_preprev = times[check_prev-1] - times[check_preprev]
- koef = float(1)
- koef = koef * ts_preprev/ts_prev
- koef = koef * n_prev/n_preprev
- # print "check_prev=",check_prev," check_preprev=",check_preprev, " nprev=", n_prev, " npprev=",n_preprev, " tsprev=", ts_prev, " tspprev=",ts_preprev, "k=",koef
- price = old_price * koef
- if price > old_price*4:
- price = old_price*4
- if price < old_price/4:
- price = old_price/4
- # print "old=", old_price," new=", price
- return price
- def num_domain_trans(step, prc, blktime):
- return sqrt(5*step)*(start_price/prc)*(43200/blktime) ## changed coeff. 10 --> 2 !!!
- ## main loop
- old_price = start_price
- for x in range(0, last):
- times.append(0)
- z=int(0)
- steptime=int(0)
- nextsolvetime=int(0)
- xsteps.append(0)
- for z1 in range(1, last):
- # times[z] = set_time(z)
- steptime+=600
- pretime=600
- if z>1:
- pretime=times[z]-times[z-1]
- num_tx = int(num_domain_trans(z1, old_price, pretime))
- txbuff += num_tx
- # print "::step ",z1," time ",steptime," txbuff: ",txbuff, " pretime: ",pretime
- if nextsolvetime > steptime or txbuff == 0:
- continue
- #crafting block
- xsteps.append(z1)
- z+=1
- # print "num_tx", num_tx
- domfee = float(old_price*txbuff)
- # print "domfee", domfee
- bitcom = random.uniform(0.0, 5.0)
- pdiff = domfee/(50.0 + bitcom)
- # print "pdiff", pdiff
- txes.append(txbuff)
- domfees.append(domfee)
- bitcoms.append(bitcom)
- pdiffs.append(pdiff)
- xtime = int(bitdiff*(1.0 + pdiff))*2**32/hashrate
- nextsolvetime = steptime + xtime
- print "::BLOCK! dstep: ",(z1-xsteps[z-1])," step: ",z1," n: ",z," tx: ",txbuff," solvtime: ",xtime, " price: ", old_price ," fees: ", domfee
- txbuff=0
- # print "Xtime", xtime
- # print "--------------"
- xtimes.append(xtime)
- times[z] = nextsolvetime
- if z < 2016 and (times[z]-times[1]) < 1209600:
- continue
- if ((z - check_prev) % 2016 == 0):
- checks.append(z)
- # print "==checkpoint by blocknum"
- new_price = reprice(z)
- check_preprev = check_prev
- check_prev = z
- else:
- if ((times[z]-times[check_prev]) >= 1209600):
- checks.append(z)
- # print "==checkpoint by time: span=", times[z]-times[check_prev], " (tgt: 1209600)"
- new_price = reprice(z)
- check_preprev = check_prev
- check_prev = z
- if new_price != old_price:
- old_price = new_price
- # print "====== repricing ======="
- # print "price =", old_price, "at block #", z
- prices.append(old_price)
- print
- print " Checkpoints were at : "
- print
- print checks
- print
- print " We had ", len(checks), "of price checkpoints"
- print
- print "------------------------------------------------------------------------"
- print
- print " Min price =", min(prices)
- print
- print " Max price =", max(prices)
- print
- print " Average price =", avg(prices)
- print
- print "======================================================"
- print
- print " Minimal time between blocks =", min(xtimes)
- print
- print " Max time b/b =", max(xtimes)
- print
- print " Average time b/b =", avg(xtimes)
- print
- print "======================================================"
- print
- print " Minimal PDiff =", min(pdiffs)
- print
- print " Max PDiff =", max(pdiffs)
- print
- print " Average PDiff =", avg(pdiffs)
- print
- print "======================================================"
- print
- print " Minimal domain fees (per block) =", min(domfees)
- print
- print " Max domain fees =", max(domfees)
- print
- print " Average domain fees =", avg(domfees)
- print
- print "======================================================"
- print
- print " Minimal num. of trans. (per block) =", min(txes)
- print
- print " Max num. of trans. =", max(txes)
- print
- print " Average num of trans. =", avg(txes)
- print
- print "======================================================"
- print
- print " Minimal Bitcoin commissions (per block) =", min(bitcoms)
- print
- print " Max commissions =", max(bitcoms)
- print
- print " Average commissions =", avg(bitcoms)
- print
- exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement