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.

@@ -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(isinstance(precision, float) or isinstance(precision, decimal.Decimal) or isinstance(precision, numbers.Integral) or isinstance(precision, str))
44
+ assert precision > 0, 'negative or zero precision can not be used with TICK_SIZE precisionMode'
40
45
  else:
41
- assert(isinstance(precision, numbers.Integral))
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 >= precision / 2:
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 >= precision / 2:
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 == ('-0.' + len(precise) * '0')[:2] or precise == '-0':
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 == ('-0.' + len(precise) * '0')[:3] or precise == '-0':
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',