Navigation
Bottom
Hashnest Showbalance
DOWNLOAD
Require:
hashnest
#-*-coding:utf8;-*- #qpy:console """ DONATION 16RdQZ86NUWQbE6rM86JbxnnaCDcAKqa9 AUTHOR http://steal1982.altervista.org/hashnest_showbalance.php """ #### HASHNEST SHOW-BALANCE #### #ver:1 ############ SETTINGS ############# USERNAME= '' KEY= '' SECRET= '' LOGFILE='balancelog.txt' ######################### from hashnest import hashnest_connector import math import os import datetime DATADIR=os.path.dirname(os.path.abspath(__file__)) def printlog(*data): try: f = open(DATADIR+LOGFILE, 'a') for d in data: f.write(d) print d f.write('\n') f.close() except Exception,e: print "ERROR: can't write log file :" ,e def print_bal(bal,format ='{:<5} {:0<10} {:0<10} {:0<10}'): out=0 for b in bal: if b['currency']['code']=='btc': out= b['total'] if float(b['amount'])>0 or float(b['blocked'])>0 or float(b['total'])>0: printlog (format.format(b['currency']['code'],b['amount'],b['blocked'],b['total'])) return round(float(out),8) def print_hash(a,bal, format='{:<12} {:>4} {:>4} {:>4} {:<10}' ): MARKETS={'AntS4':18,'AntS5':19,'AntS3':15,'AntS2':11,'UMISOO':17} out=0 for b in bal: if float(b['amount'])>0 or float(b['blocked'])>0 or float(b['total'])>0: market_orders= a.get_currency_orders(MARKETS[b['currency']['code']]) cont=0 i=0 btot=round(float(b['total'])) tprice=0 while cont
btot: n=btot-cont cont+=n tprice+=round(n*price,8) i+=1 b['totbtc']=round(tprice,8) out+=b['totbtc'] printlog(format.format(b['currency']['code'],b['amount'],b['blocked'],b['total'],b['totbtc'])) return out def show_balance(a): printlog('{:#^30}'.format('start')) printlog(datetime.datetime.today().isoformat(' ')) balance=a.get_account_balance() hashbal=a.get_account_hashrate() #print hashbal printlog('{:*^30}'.format('balance')) tot=print_bal(balance) printlog('{:*^30}'.format('hash')) tot+=print_hash(a,hashbal) printlog('{:$^30}'.format(tot)) printlog('{:#^30}'.format('end')) def readlog(): try: f = open(DATADIR+LOGFILE, 'r') for l in f: print l[:-1] f.close() except Exception,e: pass #print "ERROR: can't read log file :" ,e if __name__=='__main__': readlog() a=hashnest_connector(USERNAME, KEY, SECRET) show_balance(a)
Top