# in coinex_api.py (2 lines before and after, new function GetWorkers):
raise exchange_api.ExchangeException(e)
return balances
def GetWorkers(self):
workers = {}
for pool in self._PrivateRequest('worker_stats'):
workers[pool['worker_id']] = pool['hashrate']
return workers
def GetMarkets(self):
try:
# hashrate.py:
#!/usr/bin/python -u
import coinex_api
import ConfigParser
import cryptsy_api
import exchange_api
import os
import sys
import time
import datetime
def _LoadExchangeConfig(config, target_currency, exchange_class, *keys):
if not config.has_section(exchange_class.name):
return None
args = {}
for key in keys:
if not config.has_option(exchange_class.name, key):
raise ValueError('Missing %s.%s.' % (exchange_class.name, key))
args[key] = config.get(exchange_class.name, key)
exchange = exchange_class(**args)
return exchange
c
config.read(os.path.expanduser('~/.altcoin-autosell.config'))
target_currency = (config.get('General', 'target_currency') if
config.has_option('General', 'target_currency') else 'BTC')
sleep_sec 'sleep_seconds') if
config.has_option('General', 'sleep_seconds') else 60)
exchanges = [_LoadExchangeConfig(config, target_currency, coinex_api.CoinEx,
'api_key', 'api_secret'),
_LoadExchangeConfig(config, target_currency, cryptsy_api.Cryptsy,
'api_private_key', 'api_public_key')]
exchanges = [exchange for exchange in exchanges if exchange is not None]
if not exchanges:
print 'No exchange sections defined!'
sys.exit(1)
for exchange in exchanges:
print ('%s\t%s' % (datetime.datetime.now().strftime('%Y-%m-%d %H:%M'), exchange.GetWorkers()))
Add a code snippet to your website: www.paste.org