python script after mangling code for personal edits. Very tiny readout, all unnecessary information removed or merged. Displays local time (strftime) instead of server time. Locked to BTC-e for price, removed data grab from Gox.
.....
Just got into scrypt mining with middlecoin.
First off, middlecoin is great! Sure, the website isn't very pretty and the influx of newbies like me is causing scaling problems, but it works and is making me more $ than mining LTC and trading them. Many thanks H2O! Keep up the good work.
I made a couple of small changes to the python script:
- Support for multiple wallets (I prefer to have a wallet per rig)
- Fixed the "time since json.." bug around midnight
I really wish it was in a proper repo.
#!/usr/bin/python2
import urllib2, json, os, time
import datetime as datetime
from fractions import gcd
from time import strftime, strptime
#orignal script: michwill, 15r271ADbvPkCcENraokEzrRgLrmaSpfc8
#modded version by: mardilv, 1PkCFatY7jgxY8BFaZe1YeL1baa8G7tVuR
#crippled by: kluge (mdc2cripple1.1)
mbtc = False
UTCOffset = 5
##^Set this for your computer's time zone. "5" assumes you're on US Eastern time like me (UTC+5).
print "Waiting for first JSON update..."
wallet = [u"wallet1", u"wallet2"]
mdc_checktime_interval = float(5)
ex_checktime_interval = float(6)
exchange = "btce_last"
mdc_json = "http://middlecoin2.s3-website-us-west-2.amazonaws.com/json"
def write(greeting, value, mode):
print " %s:\t%f BTC = $%f" % (greeting, value, c*value)
def f(x):
return "BTC-E Last"
runningFlag = True
mdc_checktime_counter = float(0)
ex_checktime_counter = float(0)
sleeptime = gcd(mdc_checktime_interval, ex_checktime_interval)
while runningFlag:
if mdc_checktime_counter <= 0:
response = urllib2.urlopen(mdc_json)
data = json.loads(response.read())
response.close()
mdc_checktime_counter = mdc_checktime_interval
if ex_checktime_counter <= 0:
response = urllib2.urlopen("https://btc-e.com/api/2/btc_usd/ticker")
btcticker = json.loads(response.read())
response.close()
btce_last = float(btcticker["ticker"]["last"])
btce_timestamp = int(btcticker["ticker"]["updated"])
ex_checktime_counter = ex_checktime_interval
if exchange == "btce_last":
c = btce_last
print (strftime("%m-%d-%Y %H:%M:%S",))
walletsFound = 0
for i in data["report"]:
if i[0] in wallet:
my = i[1]
walletsFound += 1
for k in my.keys():
my[k] = float(my[k])
print ("\nWallet: %s" % (i[0]))
write("Total paid ", my.get("paidOut", 0),mbtc)
write("Total unpaid", my.get("immatureBalance", 0) + my.get("unexchangedBalance", 0) + my.get("bitcoinBalance", 0), mbtc)
write("Exchanged ", my.get("bitcoinBalance", 0),mbtc)
write("Unxchg&Imm ",my.get("unexchangedBalance", 0) + my.get("immatureBalance", 0),mbtc)
print ("Shares last hr\t:\t%.0f" % (my["lastHourShares"]))
print (" Hashrate :\t%s KH/s" % (my.get("megahashesPerSecond")* 1000))
print (" Rejected : \t%.1f%%" % (my.get("rejectedMegahashesPerSecond", 0) / my["megahashesPerSecond"]* 100))
if walletsFound == len(wallet):
break
print "\nBTC-e Last\t:\t$%f" % (btce_last)
locNow = datetime.datetime.now()
servTime = datetime.datetime.strptime(data["time"], '%Y-%m-%d %H:%M:%S')
diffMin = -int(((servTime - locNow).total_seconds() - UTCOffset * 3600) / 60)
print "Time since JSON update:", diffMin, "minutes"
mdc_checktime_counter -= sleeptime
ex_checktime_counter -= sleeptime
time.sleep(sleeptime*60)