ccxt 4.4.91__py2.py3-none-any.whl → 4.4.92__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/__init__.py CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.4.91'
25
+ __version__ = '4.4.92'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
ccxt/abstract/lbank.py CHANGED
@@ -5,6 +5,7 @@ class ImplicitAPI:
5
5
  spot_public_get_currencypairs = spotPublicGetCurrencyPairs = Entry('currencyPairs', ['spot', 'public'], 'GET', {'cost': 2.5})
6
6
  spot_public_get_accuracy = spotPublicGetAccuracy = Entry('accuracy', ['spot', 'public'], 'GET', {'cost': 2.5})
7
7
  spot_public_get_usdtocny = spotPublicGetUsdToCny = Entry('usdToCny', ['spot', 'public'], 'GET', {'cost': 2.5})
8
+ spot_public_get_assetconfigs = spotPublicGetAssetConfigs = Entry('assetConfigs', ['spot', 'public'], 'GET', {'cost': 2.5})
8
9
  spot_public_get_withdrawconfigs = spotPublicGetWithdrawConfigs = Entry('withdrawConfigs', ['spot', 'public'], 'GET', {'cost': 2.5})
9
10
  spot_public_get_timestamp = spotPublicGetTimestamp = Entry('timestamp', ['spot', 'public'], 'GET', {'cost': 2.5})
10
11
  spot_public_get_ticker_24hr = spotPublicGetTicker24hr = Entry('ticker/24hr', ['spot', 'public'], 'GET', {'cost': 2.5})
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.91'
7
+ __version__ = '4.4.92'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.4.91'
5
+ __version__ = '4.4.92'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -134,7 +134,7 @@ class Client(object):
134
134
  error = NetworkError(str(exception))
135
135
  if self.verbose:
136
136
  self.log(iso8601(milliseconds()), 'receive_loop', 'Exception', error)
137
- self.reset(error)
137
+ self.reject(error)
138
138
 
139
139
  task.add_done_callback(after_interrupt)
140
140
 
@@ -2160,6 +2160,7 @@ class bitmart(Exchange, ImplicitAPI):
2160
2160
  :param dict [params]: extra parameters specific to the exchange API endpoint
2161
2161
  :param int [params.until]: the latest time in ms to fetch trades for
2162
2162
  :param boolean [params.marginMode]: *spot* whether to fetch trades for margin orders or spot orders, defaults to spot orders(only isolated margin orders are supported)
2163
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
2163
2164
  :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
2164
2165
  """
2165
2166
  await self.load_markets()
@@ -2264,6 +2265,7 @@ class bitmart(Exchange, ImplicitAPI):
2264
2265
  :param int [since]: the earliest time in ms to fetch trades for
2265
2266
  :param int [limit]: the maximum number of trades to retrieve
2266
2267
  :param dict [params]: extra parameters specific to the exchange API endpoint
2268
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
2267
2269
  :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
2268
2270
  """
2269
2271
  await self.load_markets()
@@ -2706,6 +2708,7 @@ class bitmart(Exchange, ImplicitAPI):
2706
2708
  :param str [params.stopLossPrice]: *swap only* the price to trigger a stop-loss order
2707
2709
  :param str [params.takeProfitPrice]: *swap only* the price to trigger a take-profit order
2708
2710
  :param int [params.plan_category]: *swap tp/sl only* 1: tp/sl, 2: position tp/sl, default is 1
2711
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
2709
2712
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2710
2713
  """
2711
2714
  await self.load_markets()
@@ -2768,6 +2771,7 @@ class bitmart(Exchange, ImplicitAPI):
2768
2771
 
2769
2772
  :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
2770
2773
  :param dict [params]: extra parameters specific to the exchange API endpoint
2774
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
2771
2775
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2772
2776
  """
2773
2777
  await self.load_markets()
@@ -3270,6 +3274,7 @@ class bitmart(Exchange, ImplicitAPI):
3270
3274
  :param str [params.orderType]: *swap only* 'limit', 'market', or 'trailing'
3271
3275
  :param boolean [params.trailing]: *swap only* set to True if you want to fetch trailing orders
3272
3276
  :param boolean [params.trigger]: *swap only* set to True if you want to fetch trigger orders
3277
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3273
3278
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
3274
3279
  """
3275
3280
  await self.load_markets()
@@ -3383,6 +3388,7 @@ class bitmart(Exchange, ImplicitAPI):
3383
3388
  :param dict [params]: extra parameters specific to the exchange API endpoint
3384
3389
  :param int [params.until]: timestamp in ms of the latest entry
3385
3390
  :param str [params.marginMode]: *spot only* 'cross' or 'isolated', for margin trading
3391
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3386
3392
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
3387
3393
  """
3388
3394
  await self.load_markets()
@@ -3441,6 +3447,7 @@ class bitmart(Exchange, ImplicitAPI):
3441
3447
  :param str [params.clientOrderId]: *spot* fetch the order by client order id instead of order id
3442
3448
  :param str [params.orderType]: *swap only* 'limit', 'market', 'liquidate', 'bankruptcy', 'adl' or 'trailing'
3443
3449
  :param boolean [params.trailing]: *swap only* set to True if you want to fetch a trailing order
3450
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3444
3451
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3445
3452
  """
3446
3453
  await self.load_markets()
@@ -666,7 +666,7 @@ class bitvavo(Exchange, ImplicitAPI):
666
666
  },
667
667
  })
668
668
  # set currencies here to avoid calling publicGetAssets twice
669
- self.currencies = self.deep_extend(self.currencies, result)
669
+ self.currencies = self.map_to_safe_map(self.deep_extend(self.currencies, result))
670
670
  return result
671
671
 
672
672
  async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
@@ -1207,6 +1207,8 @@ class bitvavo(Exchange, ImplicitAPI):
1207
1207
  operatorId, params = self.handle_option_and_params(params, 'createOrder', 'operatorId')
1208
1208
  if operatorId is not None:
1209
1209
  request['operatorId'] = self.parse_to_int(operatorId)
1210
+ else:
1211
+ raise ArgumentsRequired(self.id + ' createOrder() requires an operatorId in params or options, eg: exchange.options[\'operatorId\'] = 1234567890')
1210
1212
  return self.extend(request, params)
1211
1213
 
1212
1214
  async def create_order(self, symbol: Str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
@@ -1304,6 +1306,8 @@ class bitvavo(Exchange, ImplicitAPI):
1304
1306
  operatorId, params = self.handle_option_and_params(params, 'editOrder', 'operatorId')
1305
1307
  if operatorId is not None:
1306
1308
  request['operatorId'] = self.parse_to_int(operatorId)
1309
+ else:
1310
+ raise ArgumentsRequired(self.id + ' editOrder() requires an operatorId in params or options, eg: exchange.options[\'operatorId\'] = 1234567890')
1307
1311
  request['market'] = market['id']
1308
1312
  return request
1309
1313
 
@@ -1342,6 +1346,8 @@ class bitvavo(Exchange, ImplicitAPI):
1342
1346
  operatorId, params = self.handle_option_and_params(params, 'cancelOrder', 'operatorId')
1343
1347
  if operatorId is not None:
1344
1348
  request['operatorId'] = self.parse_to_int(operatorId)
1349
+ else:
1350
+ raise ArgumentsRequired(self.id + ' cancelOrder() requires an operatorId in params or options, eg: exchange.options[\'operatorId\'] = 1234567890')
1345
1351
  return self.extend(request, params)
1346
1352
 
1347
1353
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
@@ -667,8 +667,9 @@ class exmo(Exchange, ImplicitAPI):
667
667
  :param dict [params]: extra parameters specific to the exchange API endpoint
668
668
  :returns dict: an associative dictionary of currencies
669
669
  """
670
+ promises = []
670
671
  #
671
- currencyList = await self.publicGetCurrencyListExtended(params)
672
+ promises.append(self.publicGetCurrencyListExtended(params))
672
673
  #
673
674
  # [
674
675
  # {"name":"VLX","description":"Velas"},
@@ -677,7 +678,7 @@ class exmo(Exchange, ImplicitAPI):
677
678
  # {"name":"USD","description":"US Dollar"}
678
679
  # ]
679
680
  #
680
- cryptoList = await self.publicGetPaymentsProvidersCryptoList(params)
681
+ promises.append(self.publicGetPaymentsProvidersCryptoList(params))
681
682
  #
682
683
  # {
683
684
  # "BTC":[
@@ -702,6 +703,9 @@ class exmo(Exchange, ImplicitAPI):
702
703
  # ],
703
704
  # }
704
705
  #
706
+ responses = await asyncio.gather(*promises)
707
+ currencyList = responses[0]
708
+ cryptoList = responses[1]
705
709
  result: dict = {}
706
710
  for i in range(0, len(currencyList)):
707
711
  currency = currencyList[i]
@@ -755,6 +759,10 @@ class exmo(Exchange, ImplicitAPI):
755
759
  commissionDesc = self.safe_string(provider, 'commission_desc')
756
760
  fee = self.parse_fixed_float_value(commissionDesc)
757
761
  code = self.safe_currency_code(currencyId)
762
+ info = {
763
+ 'currency': currency,
764
+ 'providers': providers,
765
+ }
758
766
  result[code] = {
759
767
  'id': currencyId,
760
768
  'code': code,
@@ -766,7 +774,7 @@ class exmo(Exchange, ImplicitAPI):
766
774
  'fee': fee,
767
775
  'precision': self.parse_number('1e-8'),
768
776
  'limits': limits,
769
- 'info': providers,
777
+ 'info': info,
770
778
  'networks': {},
771
779
  }
772
780
  return result
ccxt/async_support/htx.py CHANGED
@@ -6342,7 +6342,7 @@ class htx(Exchange, ImplicitAPI):
6342
6342
  fee = self.safe_number(params, 'fee')
6343
6343
  if fee is None:
6344
6344
  currencies = await self.fetch_currencies()
6345
- self.currencies = self.deep_extend(self.currencies, currencies)
6345
+ self.currencies = self.map_to_safe_map(self.deep_extend(self.currencies, currencies))
6346
6346
  targetNetwork = self.safe_value(currency['networks'], networkCode, {})
6347
6347
  fee = self.safe_number(targetNetwork, 'fee')
6348
6348
  if fee is None:
@@ -538,7 +538,7 @@ class krakenfutures(Exchange, ImplicitAPI):
538
538
  'code': code,
539
539
  'precision': None,
540
540
  })
541
- self.currencies = self.deep_extend(currencies, self.currencies)
541
+ self.currencies = self.map_to_safe_map(self.deep_extend(currencies, self.currencies))
542
542
  return result
543
543
 
544
544
  async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.lbank import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Any, Balances, Currency, DepositAddress, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction
10
+ from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -62,6 +62,7 @@ class lbank(Exchange, ImplicitAPI):
62
62
  'fetchClosedOrders': False,
63
63
  'fetchCrossBorrowRate': False,
64
64
  'fetchCrossBorrowRates': False,
65
+ 'fetchCurrencies': True,
65
66
  'fetchDepositAddress': True,
66
67
  'fetchDepositAddresses': False,
67
68
  'fetchDepositAddressesByNetwork': False,
@@ -136,6 +137,7 @@ class lbank(Exchange, ImplicitAPI):
136
137
  'currencyPairs': 2.5,
137
138
  'accuracy': 2.5,
138
139
  'usdToCny': 2.5,
140
+ 'assetConfigs': 2.5,
139
141
  'withdrawConfigs': 2.5,
140
142
  'timestamp': 2.5,
141
143
  'ticker/24hr': 2.5,
@@ -222,6 +224,7 @@ class lbank(Exchange, ImplicitAPI):
222
224
  },
223
225
  },
224
226
  'commonCurrencies': {
227
+ 'XBT': 'XBT', # not BTC!
225
228
  'HIT': 'Hiver',
226
229
  'VET_ERC20': 'VEN',
227
230
  'PNT': 'Penta',
@@ -289,21 +292,12 @@ class lbank(Exchange, ImplicitAPI):
289
292
  # ptx: 1
290
293
  # }
291
294
  },
292
- 'inverse-networks': {
295
+ 'networksById': {
293
296
  'erc20': 'ERC20',
294
297
  'trc20': 'TRC20',
295
- 'omni': 'OMNI',
296
- 'asa': 'ASA',
297
- 'bep20(bsc)': 'BSC',
298
- 'bep20': 'BSC',
299
- 'heco': 'HT',
300
- 'bep2': 'BNB',
301
- 'btc': 'BTC',
302
- 'dogecoin': 'DOGE',
303
- 'matic': 'MATIC',
304
- 'oec': 'OEC',
305
- 'btctron': 'BTCTRON',
306
- 'xrp': 'XRP',
298
+ 'TRX': 'TRC20',
299
+ 'bep20(bsc)': 'BEP20',
300
+ 'bep20': 'BEP20',
307
301
  },
308
302
  'defaultNetworks': {
309
303
  'USDT': 'TRC20',
@@ -424,6 +418,104 @@ class lbank(Exchange, ImplicitAPI):
424
418
  #
425
419
  return self.safe_integer(response, 'data')
426
420
 
421
+ async def fetch_currencies(self, params={}) -> Currencies:
422
+ """
423
+ fetches all available currencies on an exchange
424
+ :param dict [params]: extra parameters specific to the exchange API endpoint
425
+ :returns dict: an associative dictionary of currencies
426
+ """
427
+ response = await self.spotPublicGetWithdrawConfigs(params)
428
+ #
429
+ # {
430
+ # "msg": "Success",
431
+ # "result": "true",
432
+ # "data": [
433
+ # {
434
+ # "amountScale": "4",
435
+ # "chain": "bep20(bsc)",
436
+ # "assetCode": "usdt",
437
+ # "min": "10",
438
+ # "transferAmtScale": "4",
439
+ # "canWithDraw": True,
440
+ # "fee": "0.0000",
441
+ # "minTransfer": "0.0001",
442
+ # "type": "1"
443
+ # },
444
+ # {
445
+ # "amountScale": "4",
446
+ # "chain": "trc20",
447
+ # "assetCode": "usdt",
448
+ # "min": "1",
449
+ # "transferAmtScale": "4",
450
+ # "canWithDraw": True,
451
+ # "fee": "1.0000",
452
+ # "minTransfer": "0.0001",
453
+ # "type": "1"
454
+ # },
455
+ # ...
456
+ # ],
457
+ # "error_code": "0",
458
+ # "ts": "1747973911431"
459
+ # }
460
+ #
461
+ currenciesData = self.safe_list(response, 'data', [])
462
+ grouped = self.group_by(currenciesData, 'assetCode')
463
+ groupedKeys = list(grouped.keys())
464
+ result: dict = {}
465
+ for i in range(0, len(groupedKeys)):
466
+ id = str((groupedKeys[i])) # some currencies are numeric
467
+ code = self.safe_currency_code(id)
468
+ networksRaw = grouped[id]
469
+ networks = {}
470
+ for j in range(0, len(networksRaw)):
471
+ networkEntry = networksRaw[j]
472
+ networkId = self.safe_string(networkEntry, 'chain')
473
+ networkCode = self.network_id_to_code(networkId)
474
+ networks[networkCode] = {
475
+ 'id': networkId,
476
+ 'network': networkCode,
477
+ 'limits': {
478
+ 'withdraw': {
479
+ 'min': self.safe_number(networkEntry, 'min'),
480
+ 'max': None,
481
+ },
482
+ 'deposit': {
483
+ 'min': self.safe_number(networkEntry, 'minTransfer'),
484
+ 'max': None,
485
+ },
486
+ },
487
+ 'active': None,
488
+ 'deposit': None,
489
+ 'withdraw': self.safe_bool(networkEntry, 'canWithDraw'),
490
+ 'fee': self.safe_number(networkEntry, 'fee'),
491
+ 'precision': self.parse_number(self.parse_precision(self.safe_string(networkEntry, 'transferAmtScale'))),
492
+ 'info': networkEntry,
493
+ }
494
+ result[code] = self.safe_currency_structure({
495
+ 'id': id,
496
+ 'code': code,
497
+ 'precision': None,
498
+ 'type': None,
499
+ 'name': None,
500
+ 'active': None,
501
+ 'deposit': None,
502
+ 'withdraw': None,
503
+ 'fee': None,
504
+ 'limits': {
505
+ 'withdraw': {
506
+ 'min': None,
507
+ 'max': None,
508
+ },
509
+ 'deposit': {
510
+ 'min': None,
511
+ 'max': None,
512
+ },
513
+ },
514
+ 'networks': networks,
515
+ 'info': networksRaw,
516
+ })
517
+ return result
518
+
427
519
  async def fetch_markets(self, params={}) -> List[Market]:
428
520
  """
429
521
  retrieves data on all markets for lbank
@@ -2098,13 +2190,10 @@ class lbank(Exchange, ImplicitAPI):
2098
2190
  result = self.safe_value(response, 'data')
2099
2191
  address = self.safe_string(result, 'address')
2100
2192
  tag = self.safe_string(result, 'memo')
2101
- networkId = self.safe_string(result, 'netWork')
2102
- inverseNetworks = self.safe_value(self.options, 'inverse-networks', {})
2103
- networkCode = self.safe_string_upper(inverseNetworks, networkId, networkId)
2104
2193
  return {
2105
2194
  'info': response,
2106
2195
  'currency': code,
2107
- 'network': networkCode,
2196
+ 'network': self.network_id_to_code(self.safe_string(result, 'netWork')),
2108
2197
  'address': address,
2109
2198
  'tag': tag,
2110
2199
  }
@@ -2138,12 +2227,10 @@ class lbank(Exchange, ImplicitAPI):
2138
2227
  result = self.safe_value(response, 'data')
2139
2228
  address = self.safe_string(result, 'address')
2140
2229
  tag = self.safe_string(result, 'memo')
2141
- inverseNetworks = self.safe_value(self.options, 'inverse-networks', {})
2142
- networkCode = self.safe_string_upper(inverseNetworks, network, network)
2143
2230
  return {
2144
2231
  'info': response,
2145
2232
  'currency': code,
2146
- 'network': networkCode, # will be None if not specified in request
2233
+ 'network': None,
2147
2234
  'address': address,
2148
2235
  'tag': tag,
2149
2236
  }
@@ -2263,9 +2350,6 @@ class lbank(Exchange, ImplicitAPI):
2263
2350
  type = 'withdrawal'
2264
2351
  txid = self.safe_string(transaction, 'txId')
2265
2352
  timestamp = self.safe_integer_2(transaction, 'insertTime', 'applyTime')
2266
- networks = self.safe_value(self.options, 'inverse-networks', {})
2267
- networkId = self.safe_string(transaction, 'networkName')
2268
- network = self.safe_string(networks, networkId, networkId)
2269
2353
  address = self.safe_string(transaction, 'address')
2270
2354
  addressFrom = None
2271
2355
  addressTo = None
@@ -2290,7 +2374,7 @@ class lbank(Exchange, ImplicitAPI):
2290
2374
  'txid': txid,
2291
2375
  'timestamp': timestamp,
2292
2376
  'datetime': self.iso8601(timestamp),
2293
- 'network': network,
2377
+ 'network': self.network_id_to_code(self.safe_string(transaction, 'networkName')),
2294
2378
  'address': address,
2295
2379
  'addressTo': addressTo,
2296
2380
  'addressFrom': addressFrom,
@@ -2483,10 +2567,9 @@ class lbank(Exchange, ImplicitAPI):
2483
2567
  withdrawFees[code] = {}
2484
2568
  for j in range(0, len(networkList)):
2485
2569
  networkEntry = networkList[j]
2486
- networkId = self.safe_string(networkEntry, 'name')
2487
- networkCode = self.safe_string(self.options['inverse-networks'], networkId, networkId)
2488
2570
  fee = self.safe_number(networkEntry, 'withdrawFee')
2489
2571
  if fee is not None:
2572
+ networkCode = self.network_id_to_code(self.safe_string(networkEntry, 'name'))
2490
2573
  withdrawFees[code][networkCode] = fee
2491
2574
  return {
2492
2575
  'withdraw': withdrawFees,
@@ -2534,8 +2617,7 @@ class lbank(Exchange, ImplicitAPI):
2534
2617
  if canWithdraw == 'true':
2535
2618
  currencyId = self.safe_string(item, 'assetCode')
2536
2619
  codeInner = self.safe_currency_code(currencyId)
2537
- chain = self.safe_string(item, 'chain')
2538
- network = self.safe_string(self.options['inverse-networks'], chain, chain)
2620
+ network = self.network_id_to_code(self.safe_string(item, 'chain'))
2539
2621
  if network is None:
2540
2622
  network = codeInner
2541
2623
  fee = self.safe_string(item, 'fee')
@@ -2676,8 +2758,7 @@ class lbank(Exchange, ImplicitAPI):
2676
2758
  else:
2677
2759
  resultCodeInfo = result[code]['info']
2678
2760
  resultCodeInfo.append(fee)
2679
- chain = self.safe_string(fee, 'chain')
2680
- networkCode = self.safe_string(self.options['inverse-networks'], chain, chain)
2761
+ networkCode = self.network_id_to_code(self.safe_string(fee, 'chain'))
2681
2762
  if networkCode is not None:
2682
2763
  result[code]['networks'][networkCode] = {
2683
2764
  'withdraw': {
@@ -2727,8 +2808,7 @@ class lbank(Exchange, ImplicitAPI):
2727
2808
  networkList = self.safe_value(fee, 'networkList', [])
2728
2809
  for j in range(0, len(networkList)):
2729
2810
  networkEntry = networkList[j]
2730
- networkId = self.safe_string(networkEntry, 'name')
2731
- networkCode = self.safe_string_upper(self.options['inverse-networks'], networkId, networkId)
2811
+ networkCode = self.network_id_to_code(self.safe_string(networkEntry, 'name'))
2732
2812
  withdrawFee = self.safe_number(networkEntry, 'withdrawFee')
2733
2813
  isDefault = self.safe_value(networkEntry, 'isDefault')
2734
2814
  if withdrawFee is not None:
ccxt/async_support/okx.py CHANGED
@@ -4894,7 +4894,7 @@ class okx(Exchange, ImplicitAPI):
4894
4894
  fee = self.safe_string(params, 'fee')
4895
4895
  if fee is None:
4896
4896
  currencies = await self.fetch_currencies()
4897
- self.currencies = self.deep_extend(self.currencies, currencies)
4897
+ self.currencies = self.map_to_safe_map(self.deep_extend(self.currencies, currencies))
4898
4898
  targetNetwork = self.safe_dict(currency['networks'], self.network_id_to_code(network), {})
4899
4899
  fee = self.safe_string(targetNetwork, 'fee')
4900
4900
  if fee is None:
@@ -6844,7 +6844,7 @@ class okx(Exchange, ImplicitAPI):
6844
6844
 
6845
6845
  async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
6846
6846
  """
6847
- fetch the interest owed by the user for borrowing currency for margin trading
6847
+ fetch the interest owed b the user for borrowing currency for margin trading
6848
6848
 
6849
6849
  https://www.okx.com/docs-v5/en/#rest-api-account-get-interest-accrued-data
6850
6850
 
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.91'
7
+ __version__ = '4.4.92'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -1515,6 +1515,12 @@ class Exchange(object):
1515
1515
  parts = re.sub(r'0+$', '', str).split('.')
1516
1516
  return len(parts[1]) if len(parts) > 1 else 0
1517
1517
 
1518
+ def map_to_safe_map(self, dictionary):
1519
+ return dictionary # wrapper for go
1520
+
1521
+ def safe_map_to_map(self, dictionary):
1522
+ return dictionary # wrapper for go
1523
+
1518
1524
  def load_markets(self, reload=False, params={}):
1519
1525
  """
1520
1526
  Loads and prepares the markets for trading.
@@ -3222,14 +3228,14 @@ class Exchange(object):
3222
3228
  else:
3223
3229
  market['subType'] = None
3224
3230
  values.append(market)
3225
- self.markets = self.index_by(values, 'symbol')
3231
+ self.markets = self.map_to_safe_map(self.index_by(values, 'symbol'))
3226
3232
  marketsSortedBySymbol = self.keysort(self.markets)
3227
3233
  marketsSortedById = self.keysort(self.markets_by_id)
3228
3234
  self.symbols = list(marketsSortedBySymbol.keys())
3229
3235
  self.ids = list(marketsSortedById.keys())
3230
3236
  if currencies is not None:
3231
3237
  # currencies is always None when called in constructor but not when called from loadMarkets
3232
- self.currencies = self.deep_extend(self.currencies, currencies)
3238
+ self.currencies = self.map_to_safe_map(self.deep_extend(self.currencies, currencies))
3233
3239
  else:
3234
3240
  baseCurrencies = []
3235
3241
  quoteCurrencies = []
@@ -3255,8 +3261,8 @@ class Exchange(object):
3255
3261
  quoteCurrencies.append(currency)
3256
3262
  baseCurrencies = self.sort_by(baseCurrencies, 'code', False, '')
3257
3263
  quoteCurrencies = self.sort_by(quoteCurrencies, 'code', False, '')
3258
- self.baseCurrencies = self.index_by(baseCurrencies, 'code')
3259
- self.quoteCurrencies = self.index_by(quoteCurrencies, 'code')
3264
+ self.baseCurrencies = self.map_to_safe_map(self.index_by(baseCurrencies, 'code'))
3265
+ self.quoteCurrencies = self.map_to_safe_map(self.index_by(quoteCurrencies, 'code'))
3260
3266
  allCurrencies = self.array_concat(baseCurrencies, quoteCurrencies)
3261
3267
  groupedCurrencies = self.group_by(allCurrencies, 'code')
3262
3268
  codes = list(groupedCurrencies.keys())
@@ -3273,7 +3279,7 @@ class Exchange(object):
3273
3279
  highestPrecisionCurrency = currentCurrency if (currentCurrency['precision'] > highestPrecisionCurrency['precision']) else highestPrecisionCurrency
3274
3280
  resultingCurrencies.append(highestPrecisionCurrency)
3275
3281
  sortedCurrencies = self.sort_by(resultingCurrencies, 'code')
3276
- self.currencies = self.deep_extend(self.currencies, self.index_by(sortedCurrencies, 'code'))
3282
+ self.currencies = self.map_to_safe_map(self.deep_extend(self.currencies, self.index_by(sortedCurrencies, 'code')))
3277
3283
  self.currencies_by_id = self.index_by_safe(self.currencies, 'id')
3278
3284
  currenciesSortedByCode = self.keysort(self.currencies)
3279
3285
  self.codes = list(currenciesSortedByCode.keys())
@@ -6792,7 +6798,7 @@ class Exchange(object):
6792
6798
  return reconstructedDate
6793
6799
 
6794
6800
  def convert_market_id_expire_date(self, date: str):
6795
- # parse 03JAN24 to 240103
6801
+ # parse 03JAN24 to 240103.
6796
6802
  monthMappping = {
6797
6803
  'JAN': '01',
6798
6804
  'FEB': '02',
@@ -6914,19 +6920,9 @@ class Exchange(object):
6914
6920
  del self.tickers[symbol]
6915
6921
  else:
6916
6922
  if topic == 'myTrades' and (self.myTrades is not None):
6917
- # don't reset self.myTrades directly here
6918
- # because in c# we need to use a different object(thread-safe dict)
6919
- keys = list(self.myTrades.keys())
6920
- for i in range(0, len(keys)):
6921
- key = keys[i]
6922
- if key in self.myTrades:
6923
- del self.myTrades[key]
6923
+ self.myTrades = None
6924
6924
  elif topic == 'orders' and (self.orders is not None):
6925
- orderSymbols = list(self.orders.keys())
6926
- for i in range(0, len(orderSymbols)):
6927
- orderSymbol = orderSymbols[i]
6928
- if orderSymbol in self.orders:
6929
- del self.orders[orderSymbol]
6925
+ self.orders = None
6930
6926
  elif topic == 'ticker' and (self.tickers is not None):
6931
6927
  tickerSymbols = list(self.tickers.keys())
6932
6928
  for i in range(0, len(tickerSymbols)):
ccxt/base/types.py CHANGED
@@ -606,3 +606,4 @@ class ConstructorArgs(TypedDict, total=False):
606
606
  hostname: str
607
607
  urls: Dict[str, Any]
608
608
  headers: Dict[str, Any]
609
+ session: Any
ccxt/bitmart.py CHANGED
@@ -2160,6 +2160,7 @@ class bitmart(Exchange, ImplicitAPI):
2160
2160
  :param dict [params]: extra parameters specific to the exchange API endpoint
2161
2161
  :param int [params.until]: the latest time in ms to fetch trades for
2162
2162
  :param boolean [params.marginMode]: *spot* whether to fetch trades for margin orders or spot orders, defaults to spot orders(only isolated margin orders are supported)
2163
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
2163
2164
  :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
2164
2165
  """
2165
2166
  self.load_markets()
@@ -2264,6 +2265,7 @@ class bitmart(Exchange, ImplicitAPI):
2264
2265
  :param int [since]: the earliest time in ms to fetch trades for
2265
2266
  :param int [limit]: the maximum number of trades to retrieve
2266
2267
  :param dict [params]: extra parameters specific to the exchange API endpoint
2268
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
2267
2269
  :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
2268
2270
  """
2269
2271
  self.load_markets()
@@ -2706,6 +2708,7 @@ class bitmart(Exchange, ImplicitAPI):
2706
2708
  :param str [params.stopLossPrice]: *swap only* the price to trigger a stop-loss order
2707
2709
  :param str [params.takeProfitPrice]: *swap only* the price to trigger a take-profit order
2708
2710
  :param int [params.plan_category]: *swap tp/sl only* 1: tp/sl, 2: position tp/sl, default is 1
2711
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
2709
2712
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2710
2713
  """
2711
2714
  self.load_markets()
@@ -2768,6 +2771,7 @@ class bitmart(Exchange, ImplicitAPI):
2768
2771
 
2769
2772
  :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
2770
2773
  :param dict [params]: extra parameters specific to the exchange API endpoint
2774
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
2771
2775
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2772
2776
  """
2773
2777
  self.load_markets()
@@ -3270,6 +3274,7 @@ class bitmart(Exchange, ImplicitAPI):
3270
3274
  :param str [params.orderType]: *swap only* 'limit', 'market', or 'trailing'
3271
3275
  :param boolean [params.trailing]: *swap only* set to True if you want to fetch trailing orders
3272
3276
  :param boolean [params.trigger]: *swap only* set to True if you want to fetch trigger orders
3277
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3273
3278
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
3274
3279
  """
3275
3280
  self.load_markets()
@@ -3383,6 +3388,7 @@ class bitmart(Exchange, ImplicitAPI):
3383
3388
  :param dict [params]: extra parameters specific to the exchange API endpoint
3384
3389
  :param int [params.until]: timestamp in ms of the latest entry
3385
3390
  :param str [params.marginMode]: *spot only* 'cross' or 'isolated', for margin trading
3391
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3386
3392
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
3387
3393
  """
3388
3394
  self.load_markets()
@@ -3441,6 +3447,7 @@ class bitmart(Exchange, ImplicitAPI):
3441
3447
  :param str [params.clientOrderId]: *spot* fetch the order by client order id instead of order id
3442
3448
  :param str [params.orderType]: *swap only* 'limit', 'market', 'liquidate', 'bankruptcy', 'adl' or 'trailing'
3443
3449
  :param boolean [params.trailing]: *swap only* set to True if you want to fetch a trailing order
3450
+ :param str [params.stpMode]: self-trade prevention only for spot, defaults to none, ['none', 'cancel_maker', 'cancel_taker', 'cancel_both']
3444
3451
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
3445
3452
  """
3446
3453
  self.load_markets()