API key error handling.
This commit is contained in:
parent
1c7daa713b
commit
c352c9b293
@ -62,6 +62,9 @@ class Bittrex(Exchange):
|
||||
def buy(self, pair: str, rate: float, amount: float) -> str:
|
||||
data = _API.buy_limit(pair.replace('_', '-'), amount, rate)
|
||||
if not data['success']:
|
||||
if 'APIKEY_INVALID' in str(data['message']):
|
||||
print('Api Key...')
|
||||
else:
|
||||
Bittrex._validate_response(data)
|
||||
raise OperationalException('{message} params=({pair}, {rate}, {amount})'.format(
|
||||
message=data['message'],
|
||||
@ -73,6 +76,9 @@ class Bittrex(Exchange):
|
||||
def sell(self, pair: str, rate: float, amount: float) -> str:
|
||||
data = _API.sell_limit(pair.replace('_', '-'), amount, rate)
|
||||
if not data['success']:
|
||||
if 'APIKEY_INVALID' in str(data['message']):
|
||||
print('Api Key...')
|
||||
else:
|
||||
Bittrex._validate_response(data)
|
||||
raise OperationalException('{message} params=({pair}, {rate}, {amount})'.format(
|
||||
message=data['message'],
|
||||
@ -84,6 +90,9 @@ class Bittrex(Exchange):
|
||||
def get_balance(self, currency: str) -> float:
|
||||
data = _API.get_balance(currency)
|
||||
if not data['success']:
|
||||
if 'APIKEY_INVALID' in str(data['message']):
|
||||
print('Api Key...')
|
||||
else:
|
||||
Bittrex._validate_response(data)
|
||||
raise OperationalException('{message} params=({currency})'.format(
|
||||
message=data['message'],
|
||||
@ -93,6 +102,9 @@ class Bittrex(Exchange):
|
||||
def get_balances(self):
|
||||
data = _API.get_balances()
|
||||
if not data['success']:
|
||||
if 'APIKEY_INVALID' in str(data['message']):
|
||||
print('Api Key...')
|
||||
else:
|
||||
Bittrex._validate_response(data)
|
||||
raise OperationalException('{message}'.format(message=data['message']))
|
||||
return data['result']
|
||||
@ -101,6 +113,9 @@ class Bittrex(Exchange):
|
||||
if refresh or pair not in self.cached_ticker.keys():
|
||||
data = _API.get_ticker(pair.replace('_', '-'))
|
||||
if not data['success']:
|
||||
if 'APIKEY_INVALID' in str(data['message']):
|
||||
print('Api Key...')
|
||||
else:
|
||||
Bittrex._validate_response(data)
|
||||
raise OperationalException('{message} params=({pair})'.format(
|
||||
message=data['message'],
|
||||
@ -147,6 +162,9 @@ class Bittrex(Exchange):
|
||||
'in response params=({})'.format(prop, pair))
|
||||
|
||||
if not data['success']:
|
||||
if 'APIKEY_INVALID' in str(data['message']):
|
||||
print('Api Key...')
|
||||
else:
|
||||
Bittrex._validate_response(data)
|
||||
raise OperationalException('{message} params=({pair})'.format(
|
||||
message=data['message'],
|
||||
@ -176,6 +194,9 @@ class Bittrex(Exchange):
|
||||
def cancel_order(self, order_id: str) -> None:
|
||||
data = _API.cancel(order_id)
|
||||
if not data['success']:
|
||||
if 'APIKEY_INVALID' in str(data['message']):
|
||||
print('Api Key...')
|
||||
else:
|
||||
Bittrex._validate_response(data)
|
||||
raise OperationalException('{message} params=({order_id})'.format(
|
||||
message=data['message'],
|
||||
@ -187,6 +208,9 @@ class Bittrex(Exchange):
|
||||
def get_markets(self) -> List[str]:
|
||||
data = _API.get_markets()
|
||||
if not data['success']:
|
||||
if 'APIKEY_INVALID' in str(data['message']):
|
||||
print('Api Key...')
|
||||
else:
|
||||
Bittrex._validate_response(data)
|
||||
raise OperationalException(data['message'])
|
||||
return [m['MarketName'].replace('-', '_') for m in data['result']]
|
||||
@ -194,6 +218,9 @@ class Bittrex(Exchange):
|
||||
def get_market_summaries(self) -> List[Dict]:
|
||||
data = _API.get_market_summaries()
|
||||
if not data['success']:
|
||||
if 'APIKEY_INVALID' in str(data['message']):
|
||||
print('Api Key...')
|
||||
else:
|
||||
Bittrex._validate_response(data)
|
||||
raise OperationalException(data['message'])
|
||||
return data['result']
|
||||
@ -201,6 +228,9 @@ class Bittrex(Exchange):
|
||||
def get_wallet_health(self) -> List[Dict]:
|
||||
data = _API_V2.get_wallet_health()
|
||||
if not data['success']:
|
||||
if 'APIKEY_INVALID' in str(data['message']):
|
||||
print('Api Key...')
|
||||
else:
|
||||
Bittrex._validate_response(data)
|
||||
raise OperationalException(data['message'])
|
||||
return [{
|
||||
|
Loading…
Reference in New Issue
Block a user