whitespace

This commit is contained in:
hackrush 2018-07-24 12:36:00 -04:00 committed by Jack Robison
parent 4e29041291
commit 3dc5a9de7b
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -12,7 +12,7 @@ log = logging.getLogger(__name__)
CURRENCY_PAIRS = ["USDBTC", "BTCLBC"] CURRENCY_PAIRS = ["USDBTC", "BTCLBC"]
BITTREX_FEE = 0.0025 BITTREX_FEE = 0.0025
COINBASE_FEE = 0.0 #add fee COINBASE_FEE = 0.0 # add fee
class ExchangeRate(object): class ExchangeRate(object):
@ -37,6 +37,7 @@ class ExchangeRate(object):
class MarketFeed(object): class MarketFeed(object):
REQUESTS_TIMEOUT = 20 REQUESTS_TIMEOUT = 20
EXCHANGE_RATE_UPDATE_RATE_SEC = 300 EXCHANGE_RATE_UPDATE_RATE_SEC = 300
def __init__(self, market, name, url, params, fee): def __init__(self, market, name, url, params, fee):
self.market = market self.market = market
self.name = name self.name = name
@ -115,7 +116,7 @@ class BittrexFeed(MarketFeed):
qtys = sum([i['Quantity'] for i in trades]) qtys = sum([i['Quantity'] for i in trades])
if totals <= 0 or qtys <= 0: if totals <= 0 or qtys <= 0:
raise InvalidExchangeRateResponse(self.market, 'quantities were not positive') raise InvalidExchangeRateResponse(self.market, 'quantities were not positive')
vwap = totals/qtys vwap = totals / qtys
return defer.succeed(float(1.0 / vwap)) return defer.succeed(float(1.0 / vwap))
@ -175,12 +176,11 @@ class CryptonatorBTCFeed(MarketFeed):
except ValueError: except ValueError:
raise InvalidExchangeRateResponse(self.name, "invalid rate response") raise InvalidExchangeRateResponse(self.name, "invalid rate response")
if 'ticker' not in json_response or len(json_response['ticker']) == 0 or \ if 'ticker' not in json_response or len(json_response['ticker']) == 0 or \
'success' not in json_response or json_response['success'] is not True: 'success' not in json_response or json_response['success'] is not True:
raise InvalidExchangeRateResponse(self.name, 'result not found') raise InvalidExchangeRateResponse(self.name, 'result not found')
return defer.succeed(float(json_response['ticker']['price'])) return defer.succeed(float(json_response['ticker']['price']))
class CryptonatorFeed(MarketFeed): class CryptonatorFeed(MarketFeed):
def __init__(self): def __init__(self):
MarketFeed.__init__( MarketFeed.__init__(
@ -198,7 +198,7 @@ class CryptonatorFeed(MarketFeed):
except ValueError: except ValueError:
raise InvalidExchangeRateResponse(self.name, "invalid rate response") raise InvalidExchangeRateResponse(self.name, "invalid rate response")
if 'ticker' not in json_response or len(json_response['ticker']) == 0 or \ if 'ticker' not in json_response or len(json_response['ticker']) == 0 or \
'success' not in json_response or json_response['success'] is not True: 'success' not in json_response or json_response['success'] is not True:
raise InvalidExchangeRateResponse(self.name, 'result not found') raise InvalidExchangeRateResponse(self.name, 'result not found')
return defer.succeed(float(json_response['ticker']['price'])) return defer.succeed(float(json_response['ticker']['price']))
@ -231,11 +231,11 @@ class ExchangeRateManager(object):
for market in self.market_feeds: for market in self.market_feeds:
if (market.rate_is_initialized() and market.is_online() and if (market.rate_is_initialized() and market.is_online() and
market.rate.currency_pair == (from_currency, to_currency)): market.rate.currency_pair == (from_currency, to_currency)):
return amount * market.rate.spot return amount * market.rate.spot
for market in self.market_feeds: for market in self.market_feeds:
if (market.rate_is_initialized() and market.is_online() and if (market.rate_is_initialized() and market.is_online() and
market.rate.currency_pair[0] == from_currency): market.rate.currency_pair[0] == from_currency):
return self.convert_currency( return self.convert_currency(
market.rate.currency_pair[1], to_currency, amount * market.rate.spot) market.rate.currency_pair[1], to_currency, amount * market.rate.spot)
raise Exception( raise Exception(