ccxt 4.4.23__py2.py3-none-any.whl → 4.4.24__py2.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.
ccxt/kucoin.py CHANGED
@@ -222,6 +222,7 @@ class kucoin(Exchange, ImplicitAPI):
222
222
  'market/orderbook/level{level}': 3, # 3SW
223
223
  'market/orderbook/level2': 3, # 3SW
224
224
  'market/orderbook/level3': 3, # 3SW
225
+ 'hf/accounts/opened': 2, #
225
226
  'hf/orders/active': 2, # 2SW
226
227
  'hf/orders/active/symbols': 2, # 2SW
227
228
  'hf/margin/order/active/symbols': 2, # 2SW
@@ -651,7 +652,7 @@ class kucoin(Exchange, ImplicitAPI):
651
652
  'FUD': 'FTX Users\' Debt',
652
653
  },
653
654
  'options': {
654
- 'hf': False,
655
+ 'hf': None, # would be auto set to `true/false` after first load
655
656
  'version': 'v1',
656
657
  'symbolSeparator': '-',
657
658
  'fetchMyTradesMethod': 'private_get_fills',
@@ -1083,7 +1084,8 @@ class kucoin(Exchange, ImplicitAPI):
1083
1084
  # "enableTrading": True
1084
1085
  # },
1085
1086
  #
1086
- requestMarginables = self.check_required_credentials(False)
1087
+ credentialsSet = self.check_required_credentials(False)
1088
+ requestMarginables = credentialsSet and self.safe_bool(params, 'marginables', True)
1087
1089
  if requestMarginables:
1088
1090
  promises.append(self.privateGetMarginSymbols(params)) # cross margin symbols
1089
1091
  #
@@ -1146,6 +1148,9 @@ class kucoin(Exchange, ImplicitAPI):
1146
1148
  # "makerCoefficient": "1" # Maker Fee Coefficient
1147
1149
  # }
1148
1150
  #
1151
+ if credentialsSet:
1152
+ # load migration status for account
1153
+ promises.append(self.load_migration_status())
1149
1154
  responses = promises
1150
1155
  symbolsData = self.safe_list(responses[0], 'data')
1151
1156
  crossData = self.safe_dict(responses[1], 'data', {}) if requestMarginables else {}
@@ -1232,14 +1237,16 @@ class kucoin(Exchange, ImplicitAPI):
1232
1237
  return result
1233
1238
 
1234
1239
  def load_migration_status(self, force: bool = False):
1235
- if not ('hfMigrated' in self.options) or (self.options['hfMigrated'] is None) or force:
1236
- result: dict = self.privateGetMigrateUserAccountStatus()
1237
- data: dict = self.safe_dict(result, 'data', {})
1238
- status: Int = self.safe_integer(data, 'status')
1239
- self.options['hfMigrated'] = (status == 2)
1240
+ """
1241
+ loads the migration status for the account(hf or not)
1242
+ :see: https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-user-type
1243
+ """
1244
+ if not ('hf' in self.options) or (self.options['hf'] is None) or force:
1245
+ result: dict = self.privateGetHfAccountsOpened()
1246
+ self.options['hf'] = self.safe_bool(result, 'data')
1240
1247
 
1241
1248
  def handle_hf_and_params(self, params={}):
1242
- migrated: Bool = self.safe_bool_2(self.options, 'hfMigrated', 'hf', False)
1249
+ migrated: Bool = self.safe_bool(self.options, 'hf', False)
1243
1250
  loadedHf: Bool = None
1244
1251
  if migrated is not None:
1245
1252
  if migrated:
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.23'
7
+ __version__ = '4.4.24'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
ccxt/pro/kucoin.py CHANGED
@@ -1088,7 +1088,8 @@ class kucoin(ccxt.async_support.kucoin):
1088
1088
  self.myTrades = ArrayCacheBySymbolById(limit)
1089
1089
  data = self.safe_dict(message, 'data')
1090
1090
  parsed = self.parse_ws_trade(data)
1091
- self.myTrades.append(parsed)
1091
+ myTrades = self.myTrades
1092
+ myTrades.append(parsed)
1092
1093
  messageHash = 'myTrades'
1093
1094
  client.resolve(self.myTrades, messageHash)
1094
1095
  symbolSpecificMessageHash = messageHash + ':' + parsed['symbol']
ccxt/pro/onetrading.py CHANGED
@@ -965,7 +965,8 @@ class onetrading(ccxt.async_support.onetrading):
965
965
  if updateType == 'TRADE_SETTLED':
966
966
  parsed = self.parse_trade(update)
967
967
  symbol = self.safe_string(parsed, 'symbol', '')
968
- self.myTrades.append(parsed)
968
+ myTrades = self.myTrades
969
+ myTrades.append(parsed)
969
970
  client.resolve(self.myTrades, 'myTrades:' + symbol)
970
971
  client.resolve(self.myTrades, 'myTrades')
971
972
 
ccxt/test/tests_async.py CHANGED
@@ -639,9 +639,10 @@ class testMainClass:
639
639
  # -----------------------------------------------------------------------------
640
640
  calculated_string = json_stringify(calculated_output)
641
641
  stored_string = json_stringify(stored_output)
642
- error_message = message + ' computed ' + stored_string + ' stored: ' + calculated_string
642
+ error_message = message
643
643
  if key is not None:
644
- error_message = ' | ' + key + ' | ' + 'computed value: ' + stored_string + ' stored value: ' + calculated_string
644
+ error_message = '[' + key + ']'
645
+ error_message += ' computed: ' + stored_string + ' stored: ' + calculated_string
645
646
  assert cond, error_message
646
647
 
647
648
  def load_markets_from_file(self, id):
@@ -752,9 +753,17 @@ class testMainClass:
752
753
  # when comparing the response we want to allow some flexibility, because a 50.0 can be equal to 50 after saving it to the json file
753
754
  self.assert_static_error(sanitized_new_output == sanitized_stored_output, message_error, stored_output, new_output, asserting_key)
754
755
  else:
755
- is_boolean = (isinstance(sanitized_new_output, bool)) or (isinstance(sanitized_stored_output, bool))
756
- is_string = (isinstance(sanitized_new_output, str)) or (isinstance(sanitized_stored_output, str))
757
- is_undefined = (sanitized_new_output is None) or (sanitized_stored_output is None) # undefined is a perfetly valid value
756
+ is_computed_bool = (isinstance(sanitized_new_output, bool))
757
+ is_stored_bool = (isinstance(sanitized_stored_output, bool))
758
+ is_computed_string = (isinstance(sanitized_new_output, str))
759
+ is_stored_string = (isinstance(sanitized_stored_output, str))
760
+ is_computed_undefined = (sanitized_new_output is None)
761
+ is_stored_undefined = (sanitized_stored_output is None)
762
+ should_be_same = (is_computed_bool == is_stored_bool) and (is_computed_string == is_stored_string) and (is_computed_undefined == is_stored_undefined)
763
+ self.assert_static_error(should_be_same, 'output type mismatch', stored_output, new_output, asserting_key)
764
+ is_boolean = is_computed_bool or is_stored_bool
765
+ is_string = is_computed_string or is_stored_string
766
+ is_undefined = is_computed_undefined or is_stored_undefined # undefined is a perfetly valid value
758
767
  if is_boolean or is_string or is_undefined:
759
768
  if self.lang == 'C#':
760
769
  # tmp c# number comparsion
ccxt/test/tests_sync.py CHANGED
@@ -636,9 +636,10 @@ class testMainClass:
636
636
  # -----------------------------------------------------------------------------
637
637
  calculated_string = json_stringify(calculated_output)
638
638
  stored_string = json_stringify(stored_output)
639
- error_message = message + ' computed ' + stored_string + ' stored: ' + calculated_string
639
+ error_message = message
640
640
  if key is not None:
641
- error_message = ' | ' + key + ' | ' + 'computed value: ' + stored_string + ' stored value: ' + calculated_string
641
+ error_message = '[' + key + ']'
642
+ error_message += ' computed: ' + stored_string + ' stored: ' + calculated_string
642
643
  assert cond, error_message
643
644
 
644
645
  def load_markets_from_file(self, id):
@@ -749,9 +750,17 @@ class testMainClass:
749
750
  # when comparing the response we want to allow some flexibility, because a 50.0 can be equal to 50 after saving it to the json file
750
751
  self.assert_static_error(sanitized_new_output == sanitized_stored_output, message_error, stored_output, new_output, asserting_key)
751
752
  else:
752
- is_boolean = (isinstance(sanitized_new_output, bool)) or (isinstance(sanitized_stored_output, bool))
753
- is_string = (isinstance(sanitized_new_output, str)) or (isinstance(sanitized_stored_output, str))
754
- is_undefined = (sanitized_new_output is None) or (sanitized_stored_output is None) # undefined is a perfetly valid value
753
+ is_computed_bool = (isinstance(sanitized_new_output, bool))
754
+ is_stored_bool = (isinstance(sanitized_stored_output, bool))
755
+ is_computed_string = (isinstance(sanitized_new_output, str))
756
+ is_stored_string = (isinstance(sanitized_stored_output, str))
757
+ is_computed_undefined = (sanitized_new_output is None)
758
+ is_stored_undefined = (sanitized_stored_output is None)
759
+ should_be_same = (is_computed_bool == is_stored_bool) and (is_computed_string == is_stored_string) and (is_computed_undefined == is_stored_undefined)
760
+ self.assert_static_error(should_be_same, 'output type mismatch', stored_output, new_output, asserting_key)
761
+ is_boolean = is_computed_bool or is_stored_bool
762
+ is_string = is_computed_string or is_stored_string
763
+ is_undefined = is_computed_undefined or is_stored_undefined # undefined is a perfetly valid value
755
764
  if is_boolean or is_string or is_undefined:
756
765
  if self.lang == 'C#':
757
766
  # tmp c# number comparsion
ccxt/yobit.py CHANGED
@@ -1124,7 +1124,7 @@ class yobit(Exchange, ImplicitAPI):
1124
1124
  ids = list(trades.keys())
1125
1125
  result = []
1126
1126
  for i in range(0, len(ids)):
1127
- id = ids[i]
1127
+ id = self.safe_string(ids, i)
1128
1128
  trade = self.parse_trade(self.extend(trades[id], {
1129
1129
  'trade_id': id,
1130
1130
  }), market)