gate-io-api 0.0.74__py3-none-any.whl → 0.0.100__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of gate-io-api might be problematic. Click here for more details.
- gate/ccxt/__init__.py +2 -1
- gate/ccxt/abstract/gate.py +62 -18
- gate/ccxt/async_support/__init__.py +2 -1
- gate/ccxt/async_support/base/exchange.py +150 -21
- gate/ccxt/async_support/base/throttler.py +1 -1
- gate/ccxt/async_support/base/ws/client.py +20 -2
- gate/ccxt/async_support/base/ws/future.py +5 -3
- gate/ccxt/async_support/gate.py +339 -241
- gate/ccxt/base/decimal_to_precision.py +14 -10
- gate/ccxt/base/errors.py +12 -0
- gate/ccxt/base/exchange.py +466 -56
- gate/ccxt/base/types.py +3 -0
- gate/ccxt/gate.py +339 -241
- gate/ccxt/pro/__init__.py +2 -1
- gate/ccxt/pro/gate.py +14 -7
- {gate_io_api-0.0.74.dist-info → gate_io_api-0.0.100.dist-info}/METADATA +70 -25
- {gate_io_api-0.0.74.dist-info → gate_io_api-0.0.100.dist-info}/RECORD +18 -18
- {gate_io_api-0.0.74.dist-info → gate_io_api-0.0.100.dist-info}/WHEEL +0 -0
|
@@ -34,17 +34,21 @@ PAD_WITH_ZERO = 6
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
def decimal_to_precision(n, rounding_mode=ROUND, precision=None, counting_mode=DECIMAL_PLACES, padding_mode=NO_PADDING):
|
|
37
|
-
assert precision is not None
|
|
37
|
+
assert precision is not None, 'precision should not be None'
|
|
38
|
+
|
|
39
|
+
if isinstance(precision, str):
|
|
40
|
+
precision = float(precision)
|
|
41
|
+
assert isinstance(precision, float) or isinstance(precision, decimal.Decimal) or isinstance(precision, numbers.Integral), 'precision has an invalid number'
|
|
42
|
+
|
|
38
43
|
if counting_mode == TICK_SIZE:
|
|
39
|
-
assert
|
|
44
|
+
assert precision > 0, 'negative or zero precision can not be used with TICK_SIZE precisionMode'
|
|
40
45
|
else:
|
|
41
|
-
assert
|
|
46
|
+
assert isinstance(precision, numbers.Integral)
|
|
47
|
+
|
|
42
48
|
assert rounding_mode in [TRUNCATE, ROUND]
|
|
43
49
|
assert counting_mode in [DECIMAL_PLACES, SIGNIFICANT_DIGITS, TICK_SIZE]
|
|
44
50
|
assert padding_mode in [NO_PADDING, PAD_WITH_ZERO]
|
|
45
|
-
|
|
46
|
-
if isinstance(precision, str):
|
|
47
|
-
precision = float(precision)
|
|
51
|
+
# end of checks
|
|
48
52
|
|
|
49
53
|
context = decimal.getcontext()
|
|
50
54
|
|
|
@@ -78,12 +82,12 @@ def decimal_to_precision(n, rounding_mode=ROUND, precision=None, counting_mode=D
|
|
|
78
82
|
if missing != 0:
|
|
79
83
|
if rounding_mode == ROUND:
|
|
80
84
|
if dec > 0:
|
|
81
|
-
if missing >=
|
|
85
|
+
if missing >= precision_dec / 2:
|
|
82
86
|
dec = dec - missing + precision_dec
|
|
83
87
|
else:
|
|
84
88
|
dec = dec - missing
|
|
85
89
|
else:
|
|
86
|
-
if missing >=
|
|
90
|
+
if missing >= precision_dec / 2:
|
|
87
91
|
dec = dec + missing - precision_dec
|
|
88
92
|
else:
|
|
89
93
|
dec = dec + missing
|
|
@@ -117,7 +121,7 @@ def decimal_to_precision(n, rounding_mode=ROUND, precision=None, counting_mode=D
|
|
|
117
121
|
precise = '{:f}'.format(min((below, above), key=lambda x: abs(x - dec)))
|
|
118
122
|
else:
|
|
119
123
|
precise = '{:f}'.format(dec.quantize(sigfig))
|
|
120
|
-
if precise
|
|
124
|
+
if precise.startswith('-0') and all(c in '0.' for c in precise[1:]):
|
|
121
125
|
precise = precise[1:]
|
|
122
126
|
|
|
123
127
|
elif rounding_mode == TRUNCATE:
|
|
@@ -138,7 +142,7 @@ def decimal_to_precision(n, rounding_mode=ROUND, precision=None, counting_mode=D
|
|
|
138
142
|
precise = string
|
|
139
143
|
else:
|
|
140
144
|
precise = string[:end].ljust(dot, '0')
|
|
141
|
-
if precise
|
|
145
|
+
if precise.startswith('-0') and all(c in '0.' for c in precise[1:]):
|
|
142
146
|
precise = precise[1:]
|
|
143
147
|
precise = precise.rstrip('.')
|
|
144
148
|
|
gate/ccxt/base/errors.py
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
# EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
1
7
|
error_hierarchy = {
|
|
2
8
|
'BaseError': {
|
|
3
9
|
'ExchangeError': {
|
|
@@ -17,6 +23,7 @@ error_hierarchy = {
|
|
|
17
23
|
},
|
|
18
24
|
'MarketClosed': {},
|
|
19
25
|
'ManualInteractionNeeded': {},
|
|
26
|
+
'RestrictedLocation': {},
|
|
20
27
|
},
|
|
21
28
|
'InsufficientFunds': {},
|
|
22
29
|
'InvalidAddress': {
|
|
@@ -112,6 +119,10 @@ class ManualInteractionNeeded(OperationRejected):
|
|
|
112
119
|
pass
|
|
113
120
|
|
|
114
121
|
|
|
122
|
+
class RestrictedLocation(OperationRejected):
|
|
123
|
+
pass
|
|
124
|
+
|
|
125
|
+
|
|
115
126
|
class InsufficientFunds(ExchangeError):
|
|
116
127
|
pass
|
|
117
128
|
|
|
@@ -232,6 +243,7 @@ __all__ = [
|
|
|
232
243
|
'MarginModeAlreadySet',
|
|
233
244
|
'MarketClosed',
|
|
234
245
|
'ManualInteractionNeeded',
|
|
246
|
+
'RestrictedLocation',
|
|
235
247
|
'InsufficientFunds',
|
|
236
248
|
'InvalidAddress',
|
|
237
249
|
'AddressPending',
|