forked from sammchardy/python-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
88 lines (56 loc) · 2.27 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# coding=utf-8
import json
class BinanceAPIException(Exception):
def __init__(self, response, status_code, text):
self.code = 0
try:
json_res = json.loads(text)
except ValueError:
self.message = 'Invalid JSON error message from Binance: {}'.format(response.text)
else:
self.code = json_res['code']
self.message = json_res['msg']
self.status_code = status_code
self.response = response
self.request = getattr(response, 'request', None)
def __str__(self): # pragma: no cover
return 'APIError(code=%s): %s' % (self.code, self.message)
class BinanceRequestException(Exception):
def __init__(self, message):
self.message = message
def __str__(self):
return 'BinanceRequestException: %s' % self.message
class BinanceOrderException(Exception):
def __init__(self, code, message):
self.code = code
self.message = message
def __str__(self):
return 'BinanceOrderException(code=%s): %s' % (self.code, self.message)
class BinanceOrderMinAmountException(BinanceOrderException):
def __init__(self, value):
message = "Amount must be a multiple of %s" % value
super().__init__(-1013, message)
class BinanceOrderMinPriceException(BinanceOrderException):
def __init__(self, value):
message = "Price must be at least %s" % value
super().__init__(-1013, message)
class BinanceOrderMinTotalException(BinanceOrderException):
def __init__(self, value):
message = "Total must be at least %s" % value
super().__init__(-1013, message)
class BinanceOrderUnknownSymbolException(BinanceOrderException):
def __init__(self, value):
message = "Unknown symbol %s" % value
super().__init__(-1013, message)
class BinanceOrderInactiveSymbolException(BinanceOrderException):
def __init__(self, value):
message = "Attempting to trade an inactive symbol %s" % value
super().__init__(-1013, message)
class BinanceWebsocketUnableToConnect(Exception):
pass
class NotImplementedException(Exception):
def __init__(self, value):
message = f'Not implemented: {value}'
super().__init__(message)
class UnknownDateFormat(Exception):
...