ccxt 4.4.28__py2.py3-none-any.whl → 4.4.30__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.
Files changed (162) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/alpaca.py +1 -0
  3. ccxt/abstract/binance.py +9 -0
  4. ccxt/abstract/binancecoinm.py +9 -0
  5. ccxt/abstract/binanceus.py +9 -0
  6. ccxt/abstract/binanceusdm.py +9 -0
  7. ccxt/abstract/bybit.py +0 -13
  8. ccxt/alpaca.py +53 -8
  9. ccxt/async_support/__init__.py +1 -1
  10. ccxt/async_support/alpaca.py +53 -8
  11. ccxt/async_support/base/exchange.py +4 -1
  12. ccxt/async_support/bigone.py +1 -1
  13. ccxt/async_support/binance.py +10 -1
  14. ccxt/async_support/bingx.py +1 -1
  15. ccxt/async_support/bitbank.py +1 -1
  16. ccxt/async_support/bitbns.py +12 -12
  17. ccxt/async_support/bitfinex.py +10 -10
  18. ccxt/async_support/bitfinex2.py +1 -1
  19. ccxt/async_support/bitflyer.py +1 -1
  20. ccxt/async_support/bitget.py +96 -8
  21. ccxt/async_support/bithumb.py +1 -1
  22. ccxt/async_support/bitmart.py +54 -54
  23. ccxt/async_support/bitmex.py +1 -1
  24. ccxt/async_support/bitopro.py +22 -22
  25. ccxt/async_support/bitrue.py +29 -29
  26. ccxt/async_support/bitso.py +1 -1
  27. ccxt/async_support/bitstamp.py +1 -1
  28. ccxt/async_support/bitvavo.py +4 -1
  29. ccxt/async_support/blockchaincom.py +1 -1
  30. ccxt/async_support/btcmarkets.py +1 -1
  31. ccxt/async_support/bybit.py +50 -585
  32. ccxt/async_support/coinbase.py +1 -1
  33. ccxt/async_support/coinbaseexchange.py +1 -1
  34. ccxt/async_support/coinbaseinternational.py +1 -1
  35. ccxt/async_support/coincatch.py +25 -5
  36. ccxt/async_support/coinex.py +1 -1
  37. ccxt/async_support/coinlist.py +1 -1
  38. ccxt/async_support/coinmate.py +1 -1
  39. ccxt/async_support/coinsph.py +1 -1
  40. ccxt/async_support/cryptocom.py +1 -1
  41. ccxt/async_support/deribit.py +8 -4
  42. ccxt/async_support/digifinex.py +1 -1
  43. ccxt/async_support/exmo.py +1 -1
  44. ccxt/async_support/gate.py +1 -1
  45. ccxt/async_support/gemini.py +1 -1
  46. ccxt/async_support/hashkey.py +1 -1
  47. ccxt/async_support/hitbtc.py +1 -1
  48. ccxt/async_support/hollaex.py +1 -1
  49. ccxt/async_support/htx.py +1 -1
  50. ccxt/async_support/huobijp.py +1 -1
  51. ccxt/async_support/hyperliquid.py +110 -5
  52. ccxt/async_support/idex.py +1 -1
  53. ccxt/async_support/independentreserve.py +1 -1
  54. ccxt/async_support/indodax.py +1 -1
  55. ccxt/async_support/kraken.py +1 -1
  56. ccxt/async_support/kucoin.py +1 -1
  57. ccxt/async_support/kuna.py +1 -1
  58. ccxt/async_support/lbank.py +6 -1
  59. ccxt/async_support/lykke.py +1 -1
  60. ccxt/async_support/mercado.py +1 -1
  61. ccxt/async_support/mexc.py +1 -1
  62. ccxt/async_support/ndax.py +1 -1
  63. ccxt/async_support/novadax.py +1 -1
  64. ccxt/async_support/okcoin.py +1 -1
  65. ccxt/async_support/okx.py +1 -1
  66. ccxt/async_support/onetrading.py +1 -1
  67. ccxt/async_support/oxfun.py +1 -1
  68. ccxt/async_support/phemex.py +1 -1
  69. ccxt/async_support/poloniex.py +1 -1
  70. ccxt/async_support/probit.py +1 -1
  71. ccxt/async_support/tokocrypto.py +1 -1
  72. ccxt/async_support/upbit.py +1 -1
  73. ccxt/async_support/vertex.py +52 -8
  74. ccxt/async_support/wavesexchange.py +1 -1
  75. ccxt/async_support/whitebit.py +1 -1
  76. ccxt/async_support/woo.py +1 -1
  77. ccxt/async_support/woofipro.py +1 -1
  78. ccxt/async_support/xt.py +1 -1
  79. ccxt/async_support/yobit.py +2 -2
  80. ccxt/async_support/zaif.py +1 -1
  81. ccxt/async_support/zonda.py +1 -1
  82. ccxt/base/exchange.py +4 -1
  83. ccxt/bigone.py +1 -1
  84. ccxt/binance.py +10 -1
  85. ccxt/bingx.py +1 -1
  86. ccxt/bitbank.py +1 -1
  87. ccxt/bitbns.py +12 -12
  88. ccxt/bitfinex.py +10 -10
  89. ccxt/bitfinex2.py +1 -1
  90. ccxt/bitflyer.py +1 -1
  91. ccxt/bitget.py +96 -8
  92. ccxt/bithumb.py +1 -1
  93. ccxt/bitmart.py +54 -54
  94. ccxt/bitmex.py +1 -1
  95. ccxt/bitopro.py +22 -22
  96. ccxt/bitrue.py +29 -29
  97. ccxt/bitso.py +1 -1
  98. ccxt/bitstamp.py +1 -1
  99. ccxt/bitvavo.py +4 -1
  100. ccxt/blockchaincom.py +1 -1
  101. ccxt/btcmarkets.py +1 -1
  102. ccxt/bybit.py +50 -585
  103. ccxt/coinbase.py +1 -1
  104. ccxt/coinbaseexchange.py +1 -1
  105. ccxt/coinbaseinternational.py +1 -1
  106. ccxt/coincatch.py +25 -5
  107. ccxt/coinex.py +1 -1
  108. ccxt/coinlist.py +1 -1
  109. ccxt/coinmate.py +1 -1
  110. ccxt/coinsph.py +1 -1
  111. ccxt/cryptocom.py +1 -1
  112. ccxt/deribit.py +8 -4
  113. ccxt/digifinex.py +1 -1
  114. ccxt/exmo.py +1 -1
  115. ccxt/gate.py +1 -1
  116. ccxt/gemini.py +1 -1
  117. ccxt/hashkey.py +1 -1
  118. ccxt/hitbtc.py +1 -1
  119. ccxt/hollaex.py +1 -1
  120. ccxt/htx.py +1 -1
  121. ccxt/huobijp.py +1 -1
  122. ccxt/hyperliquid.py +110 -5
  123. ccxt/idex.py +1 -1
  124. ccxt/independentreserve.py +1 -1
  125. ccxt/indodax.py +1 -1
  126. ccxt/kraken.py +1 -1
  127. ccxt/kucoin.py +1 -1
  128. ccxt/kuna.py +1 -1
  129. ccxt/lbank.py +6 -1
  130. ccxt/lykke.py +1 -1
  131. ccxt/mercado.py +1 -1
  132. ccxt/mexc.py +1 -1
  133. ccxt/ndax.py +1 -1
  134. ccxt/novadax.py +1 -1
  135. ccxt/okcoin.py +1 -1
  136. ccxt/okx.py +1 -1
  137. ccxt/onetrading.py +1 -1
  138. ccxt/oxfun.py +1 -1
  139. ccxt/phemex.py +1 -1
  140. ccxt/poloniex.py +1 -1
  141. ccxt/pro/__init__.py +1 -1
  142. ccxt/pro/bitvavo.py +2 -1
  143. ccxt/pro/blofin.py +2 -1
  144. ccxt/pro/mexc.py +187 -30
  145. ccxt/probit.py +1 -1
  146. ccxt/test/tests_helpers.py +2 -2
  147. ccxt/tokocrypto.py +1 -1
  148. ccxt/upbit.py +1 -1
  149. ccxt/vertex.py +52 -8
  150. ccxt/wavesexchange.py +1 -1
  151. ccxt/whitebit.py +1 -1
  152. ccxt/woo.py +1 -1
  153. ccxt/woofipro.py +1 -1
  154. ccxt/xt.py +1 -1
  155. ccxt/yobit.py +2 -2
  156. ccxt/zaif.py +1 -1
  157. ccxt/zonda.py +1 -1
  158. {ccxt-4.4.28.dist-info → ccxt-4.4.30.dist-info}/METADATA +4 -4
  159. {ccxt-4.4.28.dist-info → ccxt-4.4.30.dist-info}/RECORD +162 -162
  160. {ccxt-4.4.28.dist-info → ccxt-4.4.30.dist-info}/LICENSE.txt +0 -0
  161. {ccxt-4.4.28.dist-info → ccxt-4.4.30.dist-info}/WHEEL +0 -0
  162. {ccxt-4.4.28.dist-info → ccxt-4.4.30.dist-info}/top_level.txt +0 -0
@@ -435,7 +435,7 @@ class bitfinex(Exchange, ImplicitAPI):
435
435
  # }
436
436
  # }
437
437
  #
438
- fees = self.safe_value(response, 'withdraw')
438
+ fees = self.safe_dict(response, 'withdraw', {})
439
439
  ids = list(fees.keys())
440
440
  for i in range(0, len(ids)):
441
441
  id = ids[i]
@@ -536,7 +536,7 @@ class bitfinex(Exchange, ImplicitAPI):
536
536
  # }
537
537
  #
538
538
  result: dict = {}
539
- fiat = self.safe_value(self.options, 'fiat', {})
539
+ fiat = self.safe_dict(self.options, 'fiat', {})
540
540
  makerFee = self.safe_number(response, 'maker_fee')
541
541
  takerFee = self.safe_number(response, 'taker_fee')
542
542
  makerFee2Fiat = self.safe_number(response, 'maker_fee_2fiat')
@@ -625,7 +625,7 @@ class bitfinex(Exchange, ImplicitAPI):
625
625
  'settleId': None,
626
626
  'type': type,
627
627
  'spot': (type == 'spot'),
628
- 'margin': self.safe_value(market, 'margin'),
628
+ 'margin': self.safe_bool(market, 'margin'),
629
629
  'swap': (type == 'swap'),
630
630
  'future': False,
631
631
  'option': False,
@@ -692,7 +692,7 @@ class bitfinex(Exchange, ImplicitAPI):
692
692
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
693
693
  """
694
694
  await self.load_markets()
695
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
695
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
696
696
  requestedType = self.safe_string(params, 'type', 'exchange')
697
697
  accountType = self.safe_string(accountsByType, requestedType, requestedType)
698
698
  if accountType is None:
@@ -750,7 +750,7 @@ class bitfinex(Exchange, ImplicitAPI):
750
750
  # transferring between derivatives wallet and regular wallet is not documented in their API
751
751
  # however we support it in CCXT(from just looking at web inspector)
752
752
  await self.load_markets()
753
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
753
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
754
754
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
755
755
  toId = self.safe_string(accountsByType, toAccount, toAccount)
756
756
  currency = self.currency(code)
@@ -1191,8 +1191,8 @@ class bitfinex(Exchange, ImplicitAPI):
1191
1191
  # }
1192
1192
  #
1193
1193
  side = self.safe_string(order, 'side')
1194
- open = self.safe_value(order, 'is_live')
1195
- canceled = self.safe_value(order, 'is_cancelled')
1194
+ open = self.safe_bool(order, 'is_live')
1195
+ canceled = self.safe_bool(order, 'is_cancelled')
1196
1196
  status = None
1197
1197
  if open:
1198
1198
  status = 'open'
@@ -1529,7 +1529,7 @@ class bitfinex(Exchange, ImplicitAPI):
1529
1529
  }
1530
1530
  return self.safe_string(statuses, status, status)
1531
1531
 
1532
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1532
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
1533
1533
  """
1534
1534
  make a withdrawal
1535
1535
  :see: https://docs.bitfinex.com/v1/reference/rest-auth-withdrawal
@@ -1564,7 +1564,7 @@ class bitfinex(Exchange, ImplicitAPI):
1564
1564
  # }
1565
1565
  # ]
1566
1566
  #
1567
- response = self.safe_value(responses, 0, {})
1567
+ response = self.safe_dict(responses, 0, {})
1568
1568
  id = self.safe_integer(response, 'withdrawal_id')
1569
1569
  message = self.safe_string(response, 'message')
1570
1570
  errorMessage = self.find_broadly_matched_key(self.exceptions['broad'], message)
@@ -1647,7 +1647,7 @@ class bitfinex(Exchange, ImplicitAPI):
1647
1647
  else:
1648
1648
  # json response with error, i.e:
1649
1649
  # [{"status":"error","message":"Momentary balance check. Please wait few seconds and try the transfer again."}]
1650
- responseObject = self.safe_value(response, 0, {})
1650
+ responseObject = self.safe_dict(response, 0, {})
1651
1651
  status = self.safe_string(responseObject, 'status', '')
1652
1652
  if status == 'error':
1653
1653
  throwError = True
@@ -2459,7 +2459,7 @@ class bitfinex2(Exchange, ImplicitAPI):
2459
2459
  #
2460
2460
  return self.parse_transactions(response, currency, since, limit)
2461
2461
 
2462
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2462
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
2463
2463
  """
2464
2464
  make a withdrawal
2465
2465
  :see: https://docs.bitfinex.com/reference/rest-auth-withdraw
@@ -775,7 +775,7 @@ class bitflyer(Exchange, ImplicitAPI):
775
775
  # todo unify parsePosition/parsePositions
776
776
  return response
777
777
 
778
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
778
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
779
779
  """
780
780
  make a withdrawal
781
781
  :see: https://lightning.bitflyer.com/docs?lang=en#withdrawing-funds
@@ -8,7 +8,7 @@ from ccxt.abstract.bitget import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import json
11
- from ccxt.base.types import Balances, BorrowInterest, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, FundingHistory, Int, IsolatedBorrowRate, LedgerEntry, Leverage, LeverageTier, Liquidation, LongShortRatio, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
11
+ from ccxt.base.types import Balances, BorrowInterest, Conversion, CrossBorrowRate, Currencies, Currency, DepositAddress, FundingHistory, Int, IsolatedBorrowRate, LedgerEntry, Leverage, LeverageTier, Liquidation, LongShortRatio, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import AuthenticationError
@@ -106,7 +106,7 @@ class bitget(Exchange, ImplicitAPI):
106
106
  'fetchFundingIntervals': False,
107
107
  'fetchFundingRate': True,
108
108
  'fetchFundingRateHistory': True,
109
- 'fetchFundingRates': False,
109
+ 'fetchFundingRates': True,
110
110
  'fetchIndexOHLCV': True,
111
111
  'fetchIsolatedBorrowRate': True,
112
112
  'fetchIsolatedBorrowRates': False,
@@ -2143,7 +2143,7 @@ class bitget(Exchange, ImplicitAPI):
2143
2143
  rawTransactions = self.safe_list(response, 'data', [])
2144
2144
  return self.parse_transactions(rawTransactions, currency, since, limit)
2145
2145
 
2146
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2146
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
2147
2147
  """
2148
2148
  make a withdrawal
2149
2149
  :see: https://www.bitget.com/api-doc/spot/account/Wallet-Withdrawal
@@ -6351,6 +6351,66 @@ class bitget(Exchange, ImplicitAPI):
6351
6351
  data = self.safe_value(response, 'data', [])
6352
6352
  return self.parse_funding_rate(data[0], market)
6353
6353
 
6354
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
6355
+ """
6356
+ fetch the current funding rates for all markets
6357
+ :see: https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
6358
+ :param str[] [symbols]: list of unified market symbols
6359
+ :param dict [params]: extra parameters specific to the exchange API endpoint
6360
+ :param str [params.subType]: *contract only* 'linear', 'inverse'
6361
+ :param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
6362
+ :returns dict: a dictionary of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
6363
+ """
6364
+ await self.load_markets()
6365
+ market = None
6366
+ if symbols is not None:
6367
+ symbol = self.safe_value(symbols, 0)
6368
+ sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
6369
+ if sandboxMode:
6370
+ sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
6371
+ market = self.market(sandboxSymbol)
6372
+ else:
6373
+ market = self.market(symbol)
6374
+ request: dict = {}
6375
+ productType = None
6376
+ productType, params = self.handle_product_type_and_params(market, params)
6377
+ request['productType'] = productType
6378
+ response = await self.publicMixGetV2MixMarketTickers(self.extend(request, params))
6379
+ # {
6380
+ # "code": "00000",
6381
+ # "msg": "success",
6382
+ # "requestTime": 1700533773477,
6383
+ # "data": [
6384
+ # {
6385
+ # "symbol": "BTCUSD",
6386
+ # "lastPr": "29904.5",
6387
+ # "askPr": "29904.5",
6388
+ # "bidPr": "29903.5",
6389
+ # "bidSz": "0.5091",
6390
+ # "askSz": "2.2694",
6391
+ # "high24h": "0",
6392
+ # "low24h": "0",
6393
+ # "ts": "1695794271400",
6394
+ # "change24h": "0",
6395
+ # "baseVolume": "0",
6396
+ # "quoteVolume": "0",
6397
+ # "usdtVolume": "0",
6398
+ # "openUtc": "0",
6399
+ # "changeUtc24h": "0",
6400
+ # "indexPrice": "29132.353333",
6401
+ # "fundingRate": "-0.0007",
6402
+ # "holdingAmount": "125.6844",
6403
+ # "deliveryStartTime": null,
6404
+ # "deliveryTime": null,
6405
+ # "deliveryStatus": "delivery_normal",
6406
+ # "open24h": "0",
6407
+ # "markPrice": "12345"
6408
+ # },
6409
+ # ]
6410
+ # }
6411
+ data = self.safe_list(response, 'data', [])
6412
+ return self.parse_funding_rates(data, market)
6413
+
6354
6414
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
6355
6415
  #
6356
6416
  # fetchFundingRate
@@ -6367,23 +6427,51 @@ class bitget(Exchange, ImplicitAPI):
6367
6427
  # "nextFundingTime": "1727942400000",
6368
6428
  # "ratePeriod": "8"
6369
6429
  # }
6370
- #
6430
+ # fetchFundingRates
6431
+ # {
6432
+ # "symbol": "BTCUSD",
6433
+ # "lastPr": "29904.5",
6434
+ # "askPr": "29904.5",
6435
+ # "bidPr": "29903.5",
6436
+ # "bidSz": "0.5091",
6437
+ # "askSz": "2.2694",
6438
+ # "high24h": "0",
6439
+ # "low24h": "0",
6440
+ # "ts": "1695794271400",
6441
+ # "change24h": "0",
6442
+ # "baseVolume": "0",
6443
+ # "quoteVolume": "0",
6444
+ # "usdtVolume": "0",
6445
+ # "openUtc": "0",
6446
+ # "changeUtc24h": "0",
6447
+ # "indexPrice": "29132.353333",
6448
+ # "fundingRate": "-0.0007",
6449
+ # "holdingAmount": "125.6844",
6450
+ # "deliveryStartTime": null,
6451
+ # "deliveryTime": null,
6452
+ # "deliveryStatus": "delivery_normal",
6453
+ # "open24h": "0",
6454
+ # "markPrice": "12345"
6455
+ # }
6371
6456
  marketId = self.safe_string(contract, 'symbol')
6372
6457
  symbol = self.safe_symbol(marketId, market, None, 'swap')
6373
6458
  fundingTimestamp = self.safe_integer(contract, 'nextFundingTime')
6374
6459
  interval = self.safe_string(contract, 'ratePeriod')
6460
+ timestamp = self.safe_integer(contract, 'ts')
6461
+ markPrice = self.safe_number(contract, 'markPrice')
6462
+ indexPrice = self.safe_number(contract, 'indexPrice')
6375
6463
  intervalString = None
6376
6464
  if interval is not None:
6377
6465
  intervalString = interval + 'h'
6378
6466
  return {
6379
6467
  'info': contract,
6380
6468
  'symbol': symbol,
6381
- 'markPrice': None,
6382
- 'indexPrice': None,
6469
+ 'markPrice': markPrice,
6470
+ 'indexPrice': indexPrice,
6383
6471
  'interestRate': None,
6384
6472
  'estimatedSettlePrice': None,
6385
- 'timestamp': None,
6386
- 'datetime': None,
6473
+ 'timestamp': timestamp,
6474
+ 'datetime': self.iso8601(timestamp),
6387
6475
  'fundingRate': self.safe_number(contract, 'fundingRate'),
6388
6476
  'fundingTimestamp': fundingTimestamp,
6389
6477
  'fundingDatetime': self.iso8601(fundingTimestamp),
@@ -983,7 +983,7 @@ class bithumb(Exchange, ImplicitAPI):
983
983
  }
984
984
  return await self.cancel_order(order['id'], order['symbol'], self.extend(request, params))
985
985
 
986
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
986
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
987
987
  """
988
988
  make a withdrawal
989
989
  :see: https://apidocs.bithumb.com/v1.2.0/reference/%EC%BD%94%EC%9D%B8-%EC%B6%9C%EA%B8%88%ED%95%98%EA%B8%B0-%EA%B0%9C%EC%9D%B8
@@ -723,7 +723,7 @@ class bitmart(Exchange, ImplicitAPI):
723
723
  # }
724
724
  # }
725
725
  #
726
- data = self.safe_value(response, 'data', {})
726
+ data = self.safe_dict(response, 'data', {})
727
727
  return self.safe_integer(data, 'server_time')
728
728
 
729
729
  async def fetch_status(self, params={}):
@@ -732,7 +732,7 @@ class bitmart(Exchange, ImplicitAPI):
732
732
  :param dict [params]: extra parameters specific to the exchange API endpoint
733
733
  :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
734
734
  """
735
- options = self.safe_value(self.options, 'fetchStatus', {})
735
+ options = self.safe_dict(self.options, 'fetchStatus', {})
736
736
  defaultType = self.safe_string(self.options, 'defaultType')
737
737
  type = self.safe_string(options, 'type', defaultType)
738
738
  type = self.safe_string(params, 'type', type)
@@ -763,12 +763,12 @@ class bitmart(Exchange, ImplicitAPI):
763
763
  # }
764
764
  # }
765
765
  #
766
- data = self.safe_value(response, 'data', {})
767
- services = self.safe_value(data, 'service', [])
766
+ data = self.safe_dict(response, 'data', {})
767
+ services = self.safe_list(data, 'service', [])
768
768
  servicesByType = self.index_by(services, 'service_type')
769
769
  if type == 'swap':
770
770
  type = 'contract'
771
- service = self.safe_value(servicesByType, type)
771
+ service = self.safe_string(servicesByType, type)
772
772
  status = None
773
773
  eta = None
774
774
  if service is not None:
@@ -814,8 +814,8 @@ class bitmart(Exchange, ImplicitAPI):
814
814
  # }
815
815
  # }
816
816
  #
817
- data = self.safe_value(response, 'data', {})
818
- symbols = self.safe_value(data, 'symbols', [])
817
+ data = self.safe_dict(response, 'data', {})
818
+ symbols = self.safe_list(data, 'symbols', [])
819
819
  result = []
820
820
  for i in range(0, len(symbols)):
821
821
  market = symbols[i]
@@ -923,8 +923,8 @@ class bitmart(Exchange, ImplicitAPI):
923
923
  # }
924
924
  # }
925
925
  #
926
- data = self.safe_value(response, 'data', {})
927
- symbols = self.safe_value(data, 'symbols', [])
926
+ data = self.safe_dict(response, 'data', {})
927
+ symbols = self.safe_list(data, 'symbols', [])
928
928
  result = []
929
929
  for i in range(0, len(symbols)):
930
930
  market = symbols[i]
@@ -1026,16 +1026,16 @@ class bitmart(Exchange, ImplicitAPI):
1026
1026
  # }
1027
1027
  # }
1028
1028
  #
1029
- data = self.safe_value(response, 'data', {})
1030
- currencies = self.safe_value(data, 'currencies', [])
1029
+ data = self.safe_dict(response, 'data', {})
1030
+ currencies = self.safe_list(data, 'currencies', [])
1031
1031
  result: dict = {}
1032
1032
  for i in range(0, len(currencies)):
1033
1033
  currency = currencies[i]
1034
1034
  id = self.safe_string(currency, 'id')
1035
1035
  code = self.safe_currency_code(id)
1036
1036
  name = self.safe_string(currency, 'name')
1037
- withdrawEnabled = self.safe_value(currency, 'withdraw_enabled')
1038
- depositEnabled = self.safe_value(currency, 'deposit_enabled')
1037
+ withdrawEnabled = self.safe_bool(currency, 'withdraw_enabled')
1038
+ depositEnabled = self.safe_bool(currency, 'deposit_enabled')
1039
1039
  active = withdrawEnabled and depositEnabled
1040
1040
  result[code] = {
1041
1041
  'id': id,
@@ -1386,7 +1386,7 @@ class bitmart(Exchange, ImplicitAPI):
1386
1386
  else:
1387
1387
  data = self.safe_dict(response, 'data', {})
1388
1388
  tickers = self.safe_list(data, 'symbols', [])
1389
- ticker = self.safe_value(tickers, 0, {})
1389
+ ticker = self.safe_dict(tickers, 0, {})
1390
1390
  return self.parse_ticker(ticker, market)
1391
1391
 
1392
1392
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
@@ -1403,7 +1403,7 @@ class bitmart(Exchange, ImplicitAPI):
1403
1403
  type = None
1404
1404
  market = None
1405
1405
  if symbols is not None:
1406
- symbol = self.safe_value(symbols, 0)
1406
+ symbol = self.safe_string(symbols, 0)
1407
1407
  market = self.market(symbol)
1408
1408
  type, params = self.handle_market_type_and_params('fetchTickers', market, params)
1409
1409
  response = None
@@ -1563,7 +1563,7 @@ class bitmart(Exchange, ImplicitAPI):
1563
1563
  # "trace": "4cad855074664097ac6ba5258c47305d.72.16952643834721135"
1564
1564
  # }
1565
1565
  #
1566
- data = self.safe_value(response, 'data', {})
1566
+ data = self.safe_dict(response, 'data', {})
1567
1567
  timestamp = self.safe_integer_2(data, 'ts', 'timestamp')
1568
1568
  return self.parse_order_book(data, market['symbol'], timestamp)
1569
1569
 
@@ -1891,7 +1891,7 @@ class bitmart(Exchange, ImplicitAPI):
1891
1891
  marginMode, params = self.handle_margin_mode_and_params('fetchMyTrades', params)
1892
1892
  if marginMode == 'isolated':
1893
1893
  request['orderMode'] = 'iso_margin'
1894
- options = self.safe_value(self.options, 'fetchMyTrades', {})
1894
+ options = self.safe_dict(self.options, 'fetchMyTrades', {})
1895
1895
  defaultLimit = self.safe_integer(options, 'limit', 200)
1896
1896
  if limit is None:
1897
1897
  limit = defaultLimit
@@ -1985,22 +1985,22 @@ class bitmart(Exchange, ImplicitAPI):
1985
1985
  return self.parse_trades(data, None, since, limit)
1986
1986
 
1987
1987
  def custom_parse_balance(self, response, marketType) -> Balances:
1988
- data = self.safe_value(response, 'data', {})
1988
+ data = self.safe_dict(response, 'data', {})
1989
1989
  wallet = None
1990
1990
  if marketType == 'swap':
1991
- wallet = self.safe_value(response, 'data', [])
1991
+ wallet = self.safe_list(response, 'data', [])
1992
1992
  elif marketType == 'margin':
1993
- wallet = self.safe_value(data, 'symbols', [])
1993
+ wallet = self.safe_list(data, 'symbols', [])
1994
1994
  else:
1995
- wallet = self.safe_value(data, 'wallet', [])
1995
+ wallet = self.safe_list(data, 'wallet', [])
1996
1996
  result = {'info': response}
1997
1997
  if marketType == 'margin':
1998
1998
  for i in range(0, len(wallet)):
1999
1999
  entry = wallet[i]
2000
2000
  marketId = self.safe_string(entry, 'symbol')
2001
2001
  symbol = self.safe_symbol(marketId, None, '_')
2002
- base = self.safe_value(entry, 'base', {})
2003
- quote = self.safe_value(entry, 'quote', {})
2002
+ base = self.safe_dict(entry, 'base', {})
2003
+ quote = self.safe_dict(entry, 'quote', {})
2004
2004
  baseCode = self.safe_currency_code(self.safe_string(base, 'currency'))
2005
2005
  quoteCode = self.safe_currency_code(self.safe_string(quote, 'currency'))
2006
2006
  subResult: dict = {}
@@ -2202,7 +2202,7 @@ class bitmart(Exchange, ImplicitAPI):
2202
2202
  # }
2203
2203
  # }
2204
2204
  #
2205
- data = self.safe_value(response, 'data')
2205
+ data = self.safe_dict(response, 'data', {})
2206
2206
  return self.parse_trading_fee(data)
2207
2207
 
2208
2208
  def parse_order(self, order: dict, market: Market = None) -> Order:
@@ -2361,7 +2361,7 @@ class bitmart(Exchange, ImplicitAPI):
2361
2361
  '4': 'closed', # Completed
2362
2362
  },
2363
2363
  }
2364
- statuses = self.safe_value(statusesByType, type, {})
2364
+ statuses = self.safe_dict(statusesByType, type, {})
2365
2365
  return self.safe_string(statuses, status, status)
2366
2366
 
2367
2367
  async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
@@ -2451,7 +2451,7 @@ class bitmart(Exchange, ImplicitAPI):
2451
2451
  # swap
2452
2452
  # {"code":1000,"message":"Ok","data":{"order_id":231116359426639,"price":"market price"},"trace":"7f9c94e10f9d4513bc08a7bfc2a5559a.62.16996369620521911"}
2453
2453
  #
2454
- data = self.safe_value(response, 'data', {})
2454
+ data = self.safe_dict(response, 'data', {})
2455
2455
  order = self.parse_order(data, market)
2456
2456
  order['type'] = type
2457
2457
  order['side'] = side
@@ -2739,7 +2739,7 @@ class bitmart(Exchange, ImplicitAPI):
2739
2739
  if market['spot']:
2740
2740
  response = await self.privatePostSpotV3CancelOrder(self.extend(request, params))
2741
2741
  else:
2742
- stop = self.safe_value_2(params, 'stop', 'trigger')
2742
+ stop = self.safe_bool_2(params, 'stop', 'trigger')
2743
2743
  params = self.omit(params, ['stop', 'trigger'])
2744
2744
  if not stop:
2745
2745
  response = await self.privatePostContractPrivateCancelOrder(self.extend(request, params))
@@ -2935,7 +2935,7 @@ class bitmart(Exchange, ImplicitAPI):
2935
2935
  # }
2936
2936
  # }
2937
2937
  #
2938
- data = self.safe_value(response, 'data', {})
2938
+ data = self.safe_dict(response, 'data', {})
2939
2939
  orders = self.safe_list(data, 'orders', [])
2940
2940
  return self.parse_orders(orders, market, since, limit)
2941
2941
 
@@ -2982,7 +2982,7 @@ class bitmart(Exchange, ImplicitAPI):
2982
2982
  request['endTime'] = until
2983
2983
  response = await self.privatePostSpotV4QueryOpenOrders(self.extend(request, params))
2984
2984
  elif type == 'swap':
2985
- isStop = self.safe_value_2(params, 'stop', 'trigger')
2985
+ isStop = self.safe_bool_2(params, 'stop', 'trigger')
2986
2986
  params = self.omit(params, ['stop', 'trigger'])
2987
2987
  if isStop:
2988
2988
  response = await self.privateGetContractPrivateCurrentPlanOrder(self.extend(request, params))
@@ -3223,7 +3223,7 @@ class bitmart(Exchange, ImplicitAPI):
3223
3223
  if code == 'USDT':
3224
3224
  defaultNetworks = self.safe_value(self.options, 'defaultNetworks')
3225
3225
  defaultNetwork = self.safe_string_upper(defaultNetworks, code)
3226
- networks = self.safe_value(self.options, 'networks', {})
3226
+ networks = self.safe_dict(self.options, 'networks', {})
3227
3227
  networkInner = self.safe_string_upper(params, 'network', defaultNetwork) # self line allows the user to specify either ERC20 or ETH
3228
3228
  networkInner = self.safe_string(networks, networkInner, networkInner) # handle ERC20>ETH alias
3229
3229
  if networkInner is not None:
@@ -3277,7 +3277,7 @@ class bitmart(Exchange, ImplicitAPI):
3277
3277
  'tag': self.safe_string(depositAddress, 'address_memo'),
3278
3278
  }
3279
3279
 
3280
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
3280
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
3281
3281
  """
3282
3282
  make a withdrawal
3283
3283
  :param str code: unified currency code
@@ -3302,7 +3302,7 @@ class bitmart(Exchange, ImplicitAPI):
3302
3302
  if code == 'USDT':
3303
3303
  defaultNetworks = self.safe_value(self.options, 'defaultNetworks')
3304
3304
  defaultNetwork = self.safe_string_upper(defaultNetworks, code)
3305
- networks = self.safe_value(self.options, 'networks', {})
3305
+ networks = self.safe_dict(self.options, 'networks', {})
3306
3306
  network = self.safe_string_upper(params, 'network', defaultNetwork) # self line allows the user to specify either ERC20 or ETH
3307
3307
  network = self.safe_string(networks, network, network) # handle ERC20>ETH alias
3308
3308
  if network is not None:
@@ -3319,7 +3319,7 @@ class bitmart(Exchange, ImplicitAPI):
3319
3319
  # }
3320
3320
  # }
3321
3321
  #
3322
- data = self.safe_value(response, 'data')
3322
+ data = self.safe_dict(response, 'data', {})
3323
3323
  transaction = self.parse_transaction(data, currency)
3324
3324
  return self.extend(transaction, {
3325
3325
  'code': code,
@@ -3343,7 +3343,7 @@ class bitmart(Exchange, ImplicitAPI):
3343
3343
  if code == 'USDT':
3344
3344
  defaultNetworks = self.safe_value(self.options, 'defaultNetworks')
3345
3345
  defaultNetwork = self.safe_string_upper(defaultNetworks, code)
3346
- networks = self.safe_value(self.options, 'networks', {})
3346
+ networks = self.safe_dict(self.options, 'networks', {})
3347
3347
  network = self.safe_string_upper(params, 'network', defaultNetwork) # self line allows the user to specify either ERC20 or ETH
3348
3348
  network = self.safe_string(networks, network, network) # handle ERC20>ETH alias
3349
3349
  if network is not None:
@@ -3375,7 +3375,7 @@ class bitmart(Exchange, ImplicitAPI):
3375
3375
  # }
3376
3376
  # }
3377
3377
  #
3378
- data = self.safe_value(response, 'data', {})
3378
+ data = self.safe_dict(response, 'data', {})
3379
3379
  records = self.safe_list(data, 'records', [])
3380
3380
  return self.parse_transactions(records, currency, since, limit)
3381
3381
 
@@ -3414,7 +3414,7 @@ class bitmart(Exchange, ImplicitAPI):
3414
3414
  # }
3415
3415
  # }
3416
3416
  #
3417
- data = self.safe_value(response, 'data', {})
3417
+ data = self.safe_dict(response, 'data', {})
3418
3418
  record = self.safe_dict(data, 'record', {})
3419
3419
  return self.parse_transaction(record)
3420
3420
 
@@ -3464,7 +3464,7 @@ class bitmart(Exchange, ImplicitAPI):
3464
3464
  # }
3465
3465
  # }
3466
3466
  #
3467
- data = self.safe_value(response, 'data', {})
3467
+ data = self.safe_dict(response, 'data', {})
3468
3468
  record = self.safe_dict(data, 'record', {})
3469
3469
  return self.parse_transaction(record)
3470
3470
 
@@ -3591,7 +3591,7 @@ class bitmart(Exchange, ImplicitAPI):
3591
3591
  # }
3592
3592
  # }
3593
3593
  #
3594
- data = self.safe_value(response, 'data', {})
3594
+ data = self.safe_dict(response, 'data', {})
3595
3595
  transaction = self.parse_margin_loan(data, currency)
3596
3596
  return self.extend(transaction, {
3597
3597
  'amount': amount,
@@ -3627,7 +3627,7 @@ class bitmart(Exchange, ImplicitAPI):
3627
3627
  # }
3628
3628
  # }
3629
3629
  #
3630
- data = self.safe_value(response, 'data', {})
3630
+ data = self.safe_dict(response, 'data', {})
3631
3631
  transaction = self.parse_margin_loan(data, currency)
3632
3632
  return self.extend(transaction, {
3633
3633
  'amount': amount,
@@ -3704,9 +3704,9 @@ class bitmart(Exchange, ImplicitAPI):
3704
3704
  # }
3705
3705
  # }
3706
3706
  #
3707
- data = self.safe_value(response, 'data', {})
3708
- symbols = self.safe_value(data, 'symbols', [])
3709
- borrowRate = self.safe_value(symbols, 0)
3707
+ data = self.safe_dict(response, 'data', {})
3708
+ symbols = self.safe_list(data, 'symbols', [])
3709
+ borrowRate = self.safe_dict(symbols, 0, [])
3710
3710
  return self.parse_isolated_borrow_rate(borrowRate, market)
3711
3711
 
3712
3712
  def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
@@ -3735,8 +3735,8 @@ class bitmart(Exchange, ImplicitAPI):
3735
3735
  #
3736
3736
  marketId = self.safe_string(info, 'symbol')
3737
3737
  symbol = self.safe_symbol(marketId, market)
3738
- baseData = self.safe_value(info, 'base', {})
3739
- quoteData = self.safe_value(info, 'quote', {})
3738
+ baseData = self.safe_dict(info, 'base', {})
3739
+ quoteData = self.safe_dict(info, 'quote', {})
3740
3740
  baseId = self.safe_string(baseData, 'currency')
3741
3741
  quoteId = self.safe_string(quoteData, 'currency')
3742
3742
  return {
@@ -3792,8 +3792,8 @@ class bitmart(Exchange, ImplicitAPI):
3792
3792
  # }
3793
3793
  # }
3794
3794
  #
3795
- data = self.safe_value(response, 'data', {})
3796
- symbols = self.safe_value(data, 'symbols', [])
3795
+ data = self.safe_dict(response, 'data', {})
3796
+ symbols = self.safe_list(data, 'symbols', [])
3797
3797
  return self.parse_isolated_borrow_rates(symbols)
3798
3798
 
3799
3799
  async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
@@ -3861,7 +3861,7 @@ class bitmart(Exchange, ImplicitAPI):
3861
3861
  # }
3862
3862
  # }
3863
3863
  #
3864
- data = self.safe_value(response, 'data', {})
3864
+ data = self.safe_dict(response, 'data', {})
3865
3865
  return self.extend(self.parse_transfer(data, currency), {
3866
3866
  'status': self.parse_transfer_status(self.safe_string_2(response, 'code', 'message')),
3867
3867
  })
@@ -3979,7 +3979,7 @@ class bitmart(Exchange, ImplicitAPI):
3979
3979
  # }
3980
3980
  # }
3981
3981
  #
3982
- data = self.safe_value(response, 'data', {})
3982
+ data = self.safe_dict(response, 'data', {})
3983
3983
  records = self.safe_list(data, 'records', [])
3984
3984
  return self.parse_transfers(records, currency, since, limit)
3985
3985
 
@@ -4027,8 +4027,8 @@ class bitmart(Exchange, ImplicitAPI):
4027
4027
  # }
4028
4028
  # }
4029
4029
  #
4030
- data = self.safe_value(response, 'data', {})
4031
- rows = self.safe_value(data, 'records', [])
4030
+ data = self.safe_dict(response, 'data', {})
4031
+ rows = self.safe_list(data, 'records', [])
4032
4032
  interest = self.parse_borrow_interests(rows, market)
4033
4033
  return self.filter_by_currency_since_limit(interest, code, since, limit)
4034
4034
 
@@ -4168,7 +4168,7 @@ class bitmart(Exchange, ImplicitAPI):
4168
4168
  # "trace": "4cad855074654097ac7ba5257c47305d.54.16951844206655589"
4169
4169
  # }
4170
4170
  #
4171
- data = self.safe_value(response, 'data', {})
4171
+ data = self.safe_dict(response, 'data', {})
4172
4172
  return self.parse_funding_rate(data, market)
4173
4173
 
4174
4174
  def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
@@ -4247,7 +4247,7 @@ class bitmart(Exchange, ImplicitAPI):
4247
4247
  # "trace":"4cad855074664097ac5ba5257c47305d.67.16963925142065945"
4248
4248
  # }
4249
4249
  #
4250
- data = self.safe_value(response, 'data', [])
4250
+ data = self.safe_list(response, 'data', [])
4251
4251
  first = self.safe_dict(data, 0, {})
4252
4252
  return self.parse_position(first, market)
4253
4253
 
@@ -4301,7 +4301,7 @@ class bitmart(Exchange, ImplicitAPI):
4301
4301
  # "trace":"4cad855074664097ac5ba5257c47305d.67.16963925142065945"
4302
4302
  # }
4303
4303
  #
4304
- positions = self.safe_value(response, 'data', [])
4304
+ positions = self.safe_list(response, 'data', [])
4305
4305
  result = []
4306
4306
  for i in range(0, len(positions)):
4307
4307
  result.append(self.parse_position(positions[i]))
@@ -4421,7 +4421,7 @@ class bitmart(Exchange, ImplicitAPI):
4421
4421
  # "trace": "4cad855074664097ac6ba4257c47305d.71.16965658195443021"
4422
4422
  # }
4423
4423
  #
4424
- data = self.safe_value(response, 'data', [])
4424
+ data = self.safe_list(response, 'data', [])
4425
4425
  result = []
4426
4426
  for i in range(0, len(data)):
4427
4427
  entry = data[i]
@@ -2285,7 +2285,7 @@ class bitmex(Exchange, ImplicitAPI):
2285
2285
  'takeProfitPrice': None,
2286
2286
  })
2287
2287
 
2288
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2288
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
2289
2289
  """
2290
2290
  make a withdrawal
2291
2291
  :see: https://www.bitmex.com/api/explorer/#not /User/User_requestWithdrawal