-import ccxt
+from ccxt import ExchangeError
import time
from decimal import Decimal as D
# Put your poloniex api key in market.py
try:
r = http.request("GET", cls.URL)
except Exception:
- return
+ return None
try:
cls.data = json.loads(r.data,
parse_int=D,
def clean_weights(i):
def clean_weights_(h):
- if type(h[1][i]) == str:
+ if isinstance(h[1][i], str):
return [h[0], h[1][i]]
else:
return [h[0], int(h[1][i] * 10000)]
return Amount(self.currency, self.value - other.value)
def __mul__(self, value):
- if type(value) != int and type(value) != float and type(value) != D:
+ if not isinstance(value, (int, float, D)):
raise TypeError("Amount may only be multiplied by numbers")
return Amount(self.currency, self.value * value)
return self.__mul__(value)
def __floordiv__(self, value):
- if type(value) != int and type(value) != float and type(value) != D:
+ if not isinstance(value, (int, float, D)):
raise TypeError("Amount may only be multiplied by integers")
return Amount(self.currency, self.value / value)
try:
cls.ticker_cache[(c1, c2, market.__class__)] = market.fetch_ticker("{}/{}".format(c1, c2))
augment_ticker(cls.ticker_cache[(c1, c2, market.__class__)])
- except ccxt.ExchangeError:
+ except ExchangeError:
try:
cls.ticker_cache[(c2, c1, market.__class__)] = market.fetch_ticker("{}/{}".format(c2, c1))
augment_ticker(cls.ticker_cache[(c2, c1, market.__class__)])
- except ccxt.ExchangeError:
+ except ExchangeError:
cls.ticker_cache[(c1, c2, market.__class__)] = None
return cls.get_ticker(c1, c2, market)
@classmethod
def compute_value(cls, ticker, action, compute_value="default"):
- if type(compute_value) == str:
+ if isinstance(compute_value, str):
compute_value = Computation.computations[compute_value]
return compute_value(ticker, action)