gate-io-api 0.0.65__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 +165 -27
- gate/ccxt/async_support/base/throttler.py +1 -1
- gate/ccxt/async_support/base/ws/client.py +194 -64
- gate/ccxt/async_support/base/ws/future.py +27 -50
- gate/ccxt/async_support/gate.py +356 -253
- gate/ccxt/base/decimal_to_precision.py +14 -10
- gate/ccxt/base/errors.py +6 -0
- gate/ccxt/base/exchange.py +606 -119
- gate/ccxt/base/types.py +4 -0
- gate/ccxt/gate.py +356 -253
- gate/ccxt/pro/__init__.py +2 -89
- gate/ccxt/pro/gate.py +14 -7
- {gate_io_api-0.0.65.dist-info → gate_io_api-0.0.100.dist-info}/METADATA +70 -25
- {gate_io_api-0.0.65.dist-info → gate_io_api-0.0.100.dist-info}/RECORD +18 -19
- gate/ccxt/async_support/base/ws/aiohttp_client.py +0 -147
- {gate_io_api-0.0.65.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
|
@@ -23,6 +23,7 @@ error_hierarchy = {
|
|
|
23
23
|
},
|
|
24
24
|
'MarketClosed': {},
|
|
25
25
|
'ManualInteractionNeeded': {},
|
|
26
|
+
'RestrictedLocation': {},
|
|
26
27
|
},
|
|
27
28
|
'InsufficientFunds': {},
|
|
28
29
|
'InvalidAddress': {
|
|
@@ -118,6 +119,10 @@ class ManualInteractionNeeded(OperationRejected):
|
|
|
118
119
|
pass
|
|
119
120
|
|
|
120
121
|
|
|
122
|
+
class RestrictedLocation(OperationRejected):
|
|
123
|
+
pass
|
|
124
|
+
|
|
125
|
+
|
|
121
126
|
class InsufficientFunds(ExchangeError):
|
|
122
127
|
pass
|
|
123
128
|
|
|
@@ -238,6 +243,7 @@ __all__ = [
|
|
|
238
243
|
'MarginModeAlreadySet',
|
|
239
244
|
'MarketClosed',
|
|
240
245
|
'ManualInteractionNeeded',
|
|
246
|
+
'RestrictedLocation',
|
|
241
247
|
'InsufficientFunds',
|
|
242
248
|
'InvalidAddress',
|
|
243
249
|
'AddressPending',
|