ccxt 4.2.94__py2.py3-none-any.whl → 4.2.96__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 (185) hide show
  1. ccxt/__init__.py +2 -2
  2. ccxt/abstract/bitstamp.py +6 -0
  3. ccxt/abstract/coinbase.py +1 -0
  4. ccxt/ace.py +1 -1
  5. ccxt/ascendex.py +1 -1
  6. ccxt/async_support/__init__.py +2 -2
  7. ccxt/async_support/ace.py +1 -1
  8. ccxt/async_support/ascendex.py +1 -1
  9. ccxt/async_support/base/exchange.py +1 -1
  10. ccxt/async_support/bigone.py +1 -1
  11. ccxt/async_support/binance.py +3 -3
  12. ccxt/async_support/bingx.py +1 -1
  13. ccxt/async_support/bit2c.py +1 -1
  14. ccxt/async_support/bitbank.py +1 -1
  15. ccxt/async_support/bitfinex.py +1 -1
  16. ccxt/async_support/bitfinex2.py +1 -1
  17. ccxt/async_support/bitget.py +1 -1
  18. ccxt/async_support/bithumb.py +1 -1
  19. ccxt/async_support/bitmart.py +1 -1
  20. ccxt/async_support/bitmex.py +1 -1
  21. ccxt/async_support/bitopro.py +1 -1
  22. ccxt/async_support/bitrue.py +1 -1
  23. ccxt/async_support/bitso.py +1 -1
  24. ccxt/async_support/bitstamp.py +7 -1
  25. ccxt/async_support/bitteam.py +1 -1
  26. ccxt/async_support/bitvavo.py +1 -1
  27. ccxt/async_support/blockchaincom.py +1 -1
  28. ccxt/async_support/blofin.py +1 -1
  29. ccxt/async_support/btcalpha.py +1 -1
  30. ccxt/async_support/btcbox.py +1 -1
  31. ccxt/async_support/bybit.py +2 -2
  32. ccxt/async_support/cex.py +1 -1
  33. ccxt/async_support/coinbase.py +587 -103
  34. ccxt/async_support/coinbaseinternational.py +1 -1
  35. ccxt/async_support/coinbasepro.py +1 -1
  36. ccxt/async_support/coincheck.py +1 -1
  37. ccxt/async_support/coinex.py +62 -56
  38. ccxt/async_support/coinlist.py +1 -1
  39. ccxt/async_support/coinmate.py +1 -1
  40. ccxt/async_support/coinsph.py +1 -1
  41. ccxt/async_support/cryptocom.py +1 -1
  42. ccxt/async_support/currencycom.py +1 -1
  43. ccxt/async_support/delta.py +1 -1
  44. ccxt/async_support/deribit.py +1 -1
  45. ccxt/async_support/digifinex.py +1 -1
  46. ccxt/async_support/exmo.py +1 -1
  47. ccxt/async_support/gate.py +1 -1
  48. ccxt/async_support/gemini.py +27 -11
  49. ccxt/async_support/hitbtc.py +1 -1
  50. ccxt/async_support/hollaex.py +1 -1
  51. ccxt/async_support/htx.py +117 -116
  52. ccxt/async_support/huobijp.py +1 -1
  53. ccxt/async_support/idex.py +1 -1
  54. ccxt/async_support/indodax.py +1 -1
  55. ccxt/async_support/kraken.py +1 -1
  56. ccxt/async_support/krakenfutures.py +2 -2
  57. ccxt/async_support/kucoin.py +1 -1
  58. ccxt/async_support/kucoinfutures.py +1 -1
  59. ccxt/async_support/latoken.py +1 -1
  60. ccxt/async_support/lbank.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/oceanex.py +1 -1
  65. ccxt/async_support/okcoin.py +1 -1
  66. ccxt/async_support/okx.py +42 -42
  67. ccxt/async_support/onetrading.py +1 -1
  68. ccxt/async_support/p2b.py +1 -1
  69. ccxt/async_support/phemex.py +1 -1
  70. ccxt/async_support/poloniex.py +1 -1
  71. ccxt/async_support/poloniexfutures.py +1 -1
  72. ccxt/async_support/probit.py +1 -1
  73. ccxt/async_support/timex.py +1 -1
  74. ccxt/async_support/tokocrypto.py +1 -1
  75. ccxt/async_support/tradeogre.py +1 -1
  76. ccxt/async_support/upbit.py +2 -2
  77. ccxt/async_support/wavesexchange.py +1 -1
  78. ccxt/async_support/whitebit.py +1 -1
  79. ccxt/async_support/woo.py +1 -1
  80. ccxt/async_support/yobit.py +1 -1
  81. ccxt/async_support/zonda.py +1 -1
  82. ccxt/base/errors.py +7 -7
  83. ccxt/base/exchange.py +2 -2
  84. ccxt/bigone.py +1 -1
  85. ccxt/binance.py +3 -3
  86. ccxt/bingx.py +1 -1
  87. ccxt/bit2c.py +1 -1
  88. ccxt/bitbank.py +1 -1
  89. ccxt/bitfinex.py +1 -1
  90. ccxt/bitfinex2.py +1 -1
  91. ccxt/bitget.py +1 -1
  92. ccxt/bithumb.py +1 -1
  93. ccxt/bitmart.py +1 -1
  94. ccxt/bitmex.py +1 -1
  95. ccxt/bitopro.py +1 -1
  96. ccxt/bitrue.py +1 -1
  97. ccxt/bitso.py +1 -1
  98. ccxt/bitstamp.py +7 -1
  99. ccxt/bitteam.py +1 -1
  100. ccxt/bitvavo.py +1 -1
  101. ccxt/blockchaincom.py +1 -1
  102. ccxt/blofin.py +1 -1
  103. ccxt/btcalpha.py +1 -1
  104. ccxt/btcbox.py +1 -1
  105. ccxt/bybit.py +2 -2
  106. ccxt/cex.py +1 -1
  107. ccxt/coinbase.py +587 -103
  108. ccxt/coinbaseinternational.py +1 -1
  109. ccxt/coinbasepro.py +1 -1
  110. ccxt/coincheck.py +1 -1
  111. ccxt/coinex.py +62 -56
  112. ccxt/coinlist.py +1 -1
  113. ccxt/coinmate.py +1 -1
  114. ccxt/coinsph.py +1 -1
  115. ccxt/cryptocom.py +1 -1
  116. ccxt/currencycom.py +1 -1
  117. ccxt/delta.py +1 -1
  118. ccxt/deribit.py +1 -1
  119. ccxt/digifinex.py +1 -1
  120. ccxt/exmo.py +1 -1
  121. ccxt/gate.py +1 -1
  122. ccxt/gemini.py +27 -11
  123. ccxt/hitbtc.py +1 -1
  124. ccxt/hollaex.py +1 -1
  125. ccxt/htx.py +117 -116
  126. ccxt/huobijp.py +1 -1
  127. ccxt/idex.py +1 -1
  128. ccxt/indodax.py +1 -1
  129. ccxt/kraken.py +1 -1
  130. ccxt/krakenfutures.py +2 -2
  131. ccxt/kucoin.py +1 -1
  132. ccxt/kucoinfutures.py +1 -1
  133. ccxt/latoken.py +1 -1
  134. ccxt/lbank.py +1 -1
  135. ccxt/mexc.py +1 -1
  136. ccxt/ndax.py +1 -1
  137. ccxt/novadax.py +1 -1
  138. ccxt/oceanex.py +1 -1
  139. ccxt/okcoin.py +1 -1
  140. ccxt/okx.py +42 -42
  141. ccxt/onetrading.py +1 -1
  142. ccxt/p2b.py +1 -1
  143. ccxt/phemex.py +1 -1
  144. ccxt/poloniex.py +1 -1
  145. ccxt/poloniexfutures.py +1 -1
  146. ccxt/pro/__init__.py +1 -1
  147. ccxt/pro/ascendex.py +1 -1
  148. ccxt/pro/bitfinex2.py +1 -1
  149. ccxt/pro/bitget.py +1 -1
  150. ccxt/pro/bitmart.py +1 -1
  151. ccxt/pro/bitmex.py +1 -1
  152. ccxt/pro/bitstamp.py +1 -1
  153. ccxt/pro/bitvavo.py +1 -1
  154. ccxt/pro/blockchaincom.py +1 -1
  155. ccxt/pro/bybit.py +1 -1
  156. ccxt/pro/coinbase.py +31 -4
  157. ccxt/pro/coinbaseinternational.py +1 -1
  158. ccxt/pro/coinbasepro.py +1 -1
  159. ccxt/pro/coinex.py +1 -1
  160. ccxt/pro/cryptocom.py +1 -1
  161. ccxt/pro/gate.py +1 -1
  162. ccxt/pro/hitbtc.py +1 -1
  163. ccxt/pro/hollaex.py +1 -1
  164. ccxt/pro/htx.py +1 -1
  165. ccxt/pro/kraken.py +1 -1
  166. ccxt/pro/krakenfutures.py +1 -1
  167. ccxt/pro/okcoin.py +1 -1
  168. ccxt/pro/okx.py +1 -1
  169. ccxt/pro/poloniex.py +1 -1
  170. ccxt/pro/poloniexfutures.py +1 -1
  171. ccxt/pro/whitebit.py +1 -1
  172. ccxt/probit.py +1 -1
  173. ccxt/timex.py +1 -1
  174. ccxt/tokocrypto.py +1 -1
  175. ccxt/tradeogre.py +1 -1
  176. ccxt/upbit.py +2 -2
  177. ccxt/wavesexchange.py +1 -1
  178. ccxt/whitebit.py +1 -1
  179. ccxt/woo.py +1 -1
  180. ccxt/yobit.py +1 -1
  181. ccxt/zonda.py +1 -1
  182. {ccxt-4.2.94.dist-info → ccxt-4.2.96.dist-info}/METADATA +4 -4
  183. {ccxt-4.2.94.dist-info → ccxt-4.2.96.dist-info}/RECORD +185 -185
  184. {ccxt-4.2.94.dist-info → ccxt-4.2.96.dist-info}/WHEEL +0 -0
  185. {ccxt-4.2.94.dist-info → ccxt-4.2.96.dist-info}/top_level.txt +0 -0
ccxt/okx.py CHANGED
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Account, Balances, Conversion, Currencies, Currency, Greeks, Int, Leverage, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import PermissionDenied
13
14
  from ccxt.base.errors import AccountNotEnabled
14
15
  from ccxt.base.errors import AccountSuspended
@@ -20,6 +21,7 @@ from ccxt.base.errors import InvalidAddress
20
21
  from ccxt.base.errors import InvalidOrder
21
22
  from ccxt.base.errors import OrderNotFound
22
23
  from ccxt.base.errors import CancelPending
24
+ from ccxt.base.errors import ContractUnavailable
23
25
  from ccxt.base.errors import NotSupported
24
26
  from ccxt.base.errors import NetworkError
25
27
  from ccxt.base.errors import RateLimitExceeded
@@ -27,8 +29,6 @@ from ccxt.base.errors import ExchangeNotAvailable
27
29
  from ccxt.base.errors import OnMaintenance
28
30
  from ccxt.base.errors import InvalidNonce
29
31
  from ccxt.base.errors import RequestTimeout
30
- from ccxt.base.errors import AuthenticationError
31
- from ccxt.base.errors import ContractUnavailable
32
32
  from ccxt.base.decimal_to_precision import TICK_SIZE
33
33
  from ccxt.base.precise import Precise
34
34
 
@@ -1138,7 +1138,7 @@ class okx(Exchange, ImplicitAPI):
1138
1138
  return super(okx, self).handle_market_type_and_params(methodName, market, params)
1139
1139
 
1140
1140
  def convert_to_instrument_type(self, type):
1141
- exchangeTypes = self.safe_value(self.options, 'exchangeType', {})
1141
+ exchangeTypes = self.safe_dict(self.options, 'exchangeType', {})
1142
1142
  return self.safe_string(exchangeTypes, type, type)
1143
1143
 
1144
1144
  def create_expired_option_market(self, symbol: str):
@@ -2772,7 +2772,7 @@ class okx(Exchange, ImplicitAPI):
2772
2772
  side = self.safe_string(rawOrder, 'side')
2773
2773
  amount = self.safe_value(rawOrder, 'amount')
2774
2774
  price = self.safe_value(rawOrder, 'price')
2775
- orderParams = self.safe_value(rawOrder, 'params', {})
2775
+ orderParams = self.safe_dict(rawOrder, 'params', {})
2776
2776
  extendedParams = self.extend(orderParams, params) # the request does not accept extra params since it's a list, so we're extending each order with the common params
2777
2777
  orderRequest = self.create_order_request(marketId, type, side, amount, price, extendedParams)
2778
2778
  ordersRequests.append(orderRequest)
@@ -2934,8 +2934,8 @@ class okx(Exchange, ImplicitAPI):
2934
2934
  # "msg": ""
2935
2935
  # }
2936
2936
  #
2937
- data = self.safe_value(response, 'data', [])
2938
- first = self.safe_value(data, 0)
2937
+ data = self.safe_list(response, 'data', [])
2938
+ first = self.safe_dict(data, 0, {})
2939
2939
  order = self.parse_order(first, market)
2940
2940
  order['type'] = type
2941
2941
  order['side'] = side
@@ -4040,7 +4040,7 @@ class okx(Exchange, ImplicitAPI):
4040
4040
  paginate, params = self.handle_option_and_params(params, 'fetchLedger', 'paginate')
4041
4041
  if paginate:
4042
4042
  return self.fetch_paginated_call_dynamic('fetchLedger', code, since, limit, params)
4043
- options = self.safe_value(self.options, 'fetchLedger', {})
4043
+ options = self.safe_dict(self.options, 'fetchLedger', {})
4044
4044
  method = self.safe_string(options, 'method')
4045
4045
  method = self.safe_string(params, 'method', method)
4046
4046
  params = self.omit(params, 'method')
@@ -4355,7 +4355,7 @@ class okx(Exchange, ImplicitAPI):
4355
4355
  # ]
4356
4356
  # }
4357
4357
  #
4358
- data = self.safe_value(response, 'data', [])
4358
+ data = self.safe_list(response, 'data', [])
4359
4359
  filtered = self.filter_by(data, 'selected', True)
4360
4360
  parsed = self.parse_deposit_addresses(filtered, [currency['code']], False)
4361
4361
  return self.index_by(parsed, 'network')
@@ -4418,7 +4418,7 @@ class okx(Exchange, ImplicitAPI):
4418
4418
  }
4419
4419
  network = self.safe_string(params, 'network') # self line allows the user to specify either ERC20 or ETH
4420
4420
  if network is not None:
4421
- networks = self.safe_value(self.options, 'networks', {})
4421
+ networks = self.safe_dict(self.options, 'networks', {})
4422
4422
  network = self.safe_string(networks, network.upper(), network) # handle ETH>ERC20 alias
4423
4423
  request['chain'] = currency['id'] + '-' + network
4424
4424
  params = self.omit(params, 'network')
@@ -4426,7 +4426,7 @@ class okx(Exchange, ImplicitAPI):
4426
4426
  if fee is None:
4427
4427
  currencies = self.fetch_currencies()
4428
4428
  self.currencies = self.deep_extend(self.currencies, currencies)
4429
- targetNetwork = self.safe_value(currency['networks'], self.network_id_to_code(network), {})
4429
+ targetNetwork = self.safe_dict(currency['networks'], self.network_id_to_code(network), {})
4430
4430
  fee = self.safe_string(targetNetwork, 'fee')
4431
4431
  if fee is None:
4432
4432
  raise ArgumentsRequired(self.id + ' withdraw() requires a "fee" string parameter, network transaction fee must be ≥ 0. Withdrawals to OKCoin or OKX are fee-free, please set "0". Withdrawing to external digital asset address requires network transaction fee.')
@@ -4446,7 +4446,7 @@ class okx(Exchange, ImplicitAPI):
4446
4446
  # ]
4447
4447
  # }
4448
4448
  #
4449
- data = self.safe_value(response, 'data', [])
4449
+ data = self.safe_list(response, 'data', [])
4450
4450
  transaction = self.safe_dict(data, 0)
4451
4451
  return self.parse_transaction(transaction, currency)
4452
4452
 
@@ -4653,7 +4653,7 @@ class okx(Exchange, ImplicitAPI):
4653
4653
  # "msg": ''
4654
4654
  # }
4655
4655
  #
4656
- data = self.safe_value(response, 'data')
4656
+ data = self.safe_list(response, 'data', [])
4657
4657
  withdrawal = self.safe_dict(data, 0, {})
4658
4658
  return self.parse_transaction(withdrawal)
4659
4659
 
@@ -4925,8 +4925,8 @@ class okx(Exchange, ImplicitAPI):
4925
4925
  # ]
4926
4926
  # }
4927
4927
  #
4928
- data = self.safe_value(response, 'data', [])
4929
- position = self.safe_value(data, 0)
4928
+ data = self.safe_list(response, 'data', [])
4929
+ position = self.safe_dict(data, 0)
4930
4930
  if position is None:
4931
4931
  return None
4932
4932
  return self.parse_position(position, market)
@@ -4956,7 +4956,7 @@ class okx(Exchange, ImplicitAPI):
4956
4956
  marketIdsLength = len(marketIds)
4957
4957
  if marketIdsLength > 0:
4958
4958
  request['instId'] = ','.join(marketIds)
4959
- fetchPositionsOptions = self.safe_value(self.options, 'fetchPositions', {})
4959
+ fetchPositionsOptions = self.safe_dict(self.options, 'fetchPositions', {})
4960
4960
  method = self.safe_string(fetchPositionsOptions, 'method', 'privateGetAccountPositions')
4961
4961
  response = None
4962
4962
  if method == 'privateGetAccountPositionsHistory':
@@ -5009,7 +5009,7 @@ class okx(Exchange, ImplicitAPI):
5009
5009
  # ]
5010
5010
  # }
5011
5011
  #
5012
- positions = self.safe_value(response, 'data', [])
5012
+ positions = self.safe_list(response, 'data', [])
5013
5013
  result = []
5014
5014
  for i in range(0, len(positions)):
5015
5015
  result.append(self.parse_position(positions[i]))
@@ -5197,7 +5197,7 @@ class okx(Exchange, ImplicitAPI):
5197
5197
  """
5198
5198
  self.load_markets()
5199
5199
  currency = self.currency(code)
5200
- accountsByType = self.safe_value(self.options, 'accountsByType', {})
5200
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
5201
5201
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
5202
5202
  toId = self.safe_string(accountsByType, toAccount, toAccount)
5203
5203
  request = {
@@ -5237,7 +5237,7 @@ class okx(Exchange, ImplicitAPI):
5237
5237
  # ]
5238
5238
  # }
5239
5239
  #
5240
- data = self.safe_value(response, 'data', [])
5240
+ data = self.safe_list(response, 'data', [])
5241
5241
  rawTransfer = self.safe_dict(data, 0, {})
5242
5242
  return self.parse_transfer(rawTransfer, currency)
5243
5243
 
@@ -5300,7 +5300,7 @@ class okx(Exchange, ImplicitAPI):
5300
5300
  amount = self.safe_number(transfer, 'amt')
5301
5301
  fromAccountId = self.safe_string(transfer, 'from')
5302
5302
  toAccountId = self.safe_string(transfer, 'to')
5303
- accountsById = self.safe_value(self.options, 'accountsById', {})
5303
+ accountsById = self.safe_dict(self.options, 'accountsById', {})
5304
5304
  timestamp = self.safe_integer(transfer, 'ts')
5305
5305
  balanceChange = self.safe_string(transfer, 'sz')
5306
5306
  if balanceChange is not None:
@@ -5350,7 +5350,7 @@ class okx(Exchange, ImplicitAPI):
5350
5350
  # "msg": ""
5351
5351
  # }
5352
5352
  #
5353
- data = self.safe_value(response, 'data', [])
5353
+ data = self.safe_list(response, 'data', [])
5354
5354
  transfer = self.safe_dict(data, 0)
5355
5355
  return self.parse_transfer(transfer)
5356
5356
 
@@ -5535,8 +5535,8 @@ class okx(Exchange, ImplicitAPI):
5535
5535
  # "msg": ""
5536
5536
  # }
5537
5537
  #
5538
- data = self.safe_value(response, 'data', [])
5539
- entry = self.safe_value(data, 0, {})
5538
+ data = self.safe_list(response, 'data', [])
5539
+ entry = self.safe_dict(data, 0, {})
5540
5540
  return self.parse_funding_rate(entry, market)
5541
5541
 
5542
5542
  def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
@@ -5668,7 +5668,7 @@ class okx(Exchange, ImplicitAPI):
5668
5668
  # "type": "8"
5669
5669
  # }
5670
5670
  #
5671
- data = self.safe_value(response, 'data', [])
5671
+ data = self.safe_list(response, 'data', [])
5672
5672
  result = []
5673
5673
  for i in range(0, len(data)):
5674
5674
  entry = data[i]
@@ -5839,7 +5839,7 @@ class okx(Exchange, ImplicitAPI):
5839
5839
  # ],
5840
5840
  # }
5841
5841
  #
5842
- data = self.safe_value(response, 'data', [])
5842
+ data = self.safe_list(response, 'data', [])
5843
5843
  rates = []
5844
5844
  for i in range(0, len(data)):
5845
5845
  rates.append(self.parse_borrow_rate(data[i]))
@@ -5872,8 +5872,8 @@ class okx(Exchange, ImplicitAPI):
5872
5872
  # "msg": ""
5873
5873
  # }
5874
5874
  #
5875
- data = self.safe_value(response, 'data')
5876
- rate = self.safe_value(data, 0)
5875
+ data = self.safe_list(response, 'data', [])
5876
+ rate = self.safe_dict(data, 0, {})
5877
5877
  return self.parse_borrow_rate(rate)
5878
5878
 
5879
5879
  def parse_borrow_rate(self, info, currency: Currency = None):
@@ -5968,7 +5968,7 @@ class okx(Exchange, ImplicitAPI):
5968
5968
  # "msg": ""
5969
5969
  # }
5970
5970
  #
5971
- data = self.safe_value(response, 'data')
5971
+ data = self.safe_list(response, 'data', [])
5972
5972
  return self.parse_borrow_rate_histories(data, codes, since, limit)
5973
5973
 
5974
5974
  def fetch_borrow_rate_history(self, code: str, since: Int = None, limit: Int = None, params={}):
@@ -6008,7 +6008,7 @@ class okx(Exchange, ImplicitAPI):
6008
6008
  # "msg": ""
6009
6009
  # }
6010
6010
  #
6011
- data = self.safe_value(response, 'data')
6011
+ data = self.safe_list(response, 'data', [])
6012
6012
  return self.parse_borrow_rate_history(data, code, since, limit)
6013
6013
 
6014
6014
  def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
@@ -6188,7 +6188,7 @@ class okx(Exchange, ImplicitAPI):
6188
6188
  # ]
6189
6189
  # }
6190
6190
  #
6191
- data = self.safe_value(response, 'data')
6191
+ data = self.safe_list(response, 'data', [])
6192
6192
  return self.parse_market_leverage_tiers(data, market)
6193
6193
 
6194
6194
  def parse_market_leverage_tiers(self, info, market: Market = None):
@@ -6281,7 +6281,7 @@ class okx(Exchange, ImplicitAPI):
6281
6281
  # "msg": ""
6282
6282
  # }
6283
6283
  #
6284
- data = self.safe_value(response, 'data')
6284
+ data = self.safe_list(response, 'data', [])
6285
6285
  interest = self.parse_borrow_interests(data)
6286
6286
  return self.filter_by_currency_since_limit(interest, code, since, limit)
6287
6287
 
@@ -6334,8 +6334,8 @@ class okx(Exchange, ImplicitAPI):
6334
6334
  # "msg": ""
6335
6335
  # }
6336
6336
  #
6337
- data = self.safe_value(response, 'data', [])
6338
- loan = self.safe_value(data, 0)
6337
+ data = self.safe_list(response, 'data', [])
6338
+ loan = self.safe_dict(data, 0, {})
6339
6339
  return self.parse_margin_loan(loan, currency)
6340
6340
 
6341
6341
  def repay_cross_margin(self, code: str, amount, params={}):
@@ -6376,8 +6376,8 @@ class okx(Exchange, ImplicitAPI):
6376
6376
  # "msg": ""
6377
6377
  # }
6378
6378
  #
6379
- data = self.safe_value(response, 'data', [])
6380
- loan = self.safe_value(data, 0)
6379
+ data = self.safe_list(response, 'data', [])
6380
+ loan = self.safe_dict(data, 0, {})
6381
6381
  return self.parse_margin_loan(loan, currency)
6382
6382
 
6383
6383
  def parse_margin_loan(self, info, currency: Currency = None):
@@ -6454,8 +6454,8 @@ class okx(Exchange, ImplicitAPI):
6454
6454
  :param int [params.until]: The time in ms of the latest record to retrieve unix timestamp
6455
6455
  :returns: An array of `open interest structures <https://docs.ccxt.com/#/?id=open-interest-structure>`
6456
6456
  """
6457
- options = self.safe_value(self.options, 'fetchOpenInterestHistory', {})
6458
- timeframes = self.safe_value(options, 'timeframes', {})
6457
+ options = self.safe_dict(self.options, 'fetchOpenInterestHistory', {})
6458
+ timeframes = self.safe_dict(options, 'timeframes', {})
6459
6459
  timeframe = self.safe_string(timeframes, timeframe, timeframe)
6460
6460
  if timeframe != '5m' and timeframe != '1H' and timeframe != '1D':
6461
6461
  raise BadRequest(self.id + ' fetchOpenInterestHistory cannot only use the 5m, 1h, and 1d timeframe')
@@ -6720,7 +6720,7 @@ class okx(Exchange, ImplicitAPI):
6720
6720
  # "msg": ""
6721
6721
  # }
6722
6722
  #
6723
- data = self.safe_value(response, 'data', [])
6723
+ data = self.safe_list(response, 'data', [])
6724
6724
  settlements = self.parse_settlements(data, market)
6725
6725
  sorted = self.sort_by(settlements, 'timestamp')
6726
6726
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
@@ -6759,7 +6759,7 @@ class okx(Exchange, ImplicitAPI):
6759
6759
  for i in range(0, len(settlements)):
6760
6760
  entry = settlements[i]
6761
6761
  timestamp = self.safe_integer(entry, 'ts')
6762
- details = self.safe_value(entry, 'details', [])
6762
+ details = self.safe_list(entry, 'details', [])
6763
6763
  for j in range(0, len(details)):
6764
6764
  settlement = self.parse_settlement(details[j], market)
6765
6765
  result.append(self.extend(settlement, {
@@ -6799,7 +6799,7 @@ class okx(Exchange, ImplicitAPI):
6799
6799
  # "msg": ""
6800
6800
  # }
6801
6801
  #
6802
- underlyings = self.safe_value(response, 'data', [])
6802
+ underlyings = self.safe_list(response, 'data', [])
6803
6803
  return underlyings[0]
6804
6804
 
6805
6805
  def fetch_greeks(self, symbol: str, params={}) -> Greeks:
@@ -6849,7 +6849,7 @@ class okx(Exchange, ImplicitAPI):
6849
6849
  # "msg": ""
6850
6850
  # }
6851
6851
  #
6852
- data = self.safe_value(response, 'data', [])
6852
+ data = self.safe_list(response, 'data', [])
6853
6853
  for i in range(0, len(data)):
6854
6854
  entry = data[i]
6855
6855
  entryMarketId = self.safe_string(entry, 'instId')
@@ -6962,7 +6962,7 @@ class okx(Exchange, ImplicitAPI):
6962
6962
  # "outTime": "1701877077102579"
6963
6963
  # }
6964
6964
  #
6965
- data = self.safe_value(response, 'data')
6965
+ data = self.safe_list(response, 'data', [])
6966
6966
  order = self.safe_dict(data, 0)
6967
6967
  return self.parse_order(order, market)
6968
6968
 
@@ -7271,7 +7271,7 @@ class okx(Exchange, ImplicitAPI):
7271
7271
  code = self.safe_string(response, 'code')
7272
7272
  if (code != '0') and (code != '2'): # 2 means that bulk operation partially succeeded
7273
7273
  feedback = self.id + ' ' + body
7274
- data = self.safe_value(response, 'data', [])
7274
+ data = self.safe_list(response, 'data', [])
7275
7275
  for i in range(0, len(data)):
7276
7276
  error = data[i]
7277
7277
  errorCode = self.safe_string(error, 'sCode')
ccxt/onetrading.py CHANGED
@@ -8,6 +8,7 @@ from ccxt.abstract.onetrading import ImplicitAPI
8
8
  from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
+ from ccxt.base.errors import AuthenticationError
11
12
  from ccxt.base.errors import PermissionDenied
12
13
  from ccxt.base.errors import ArgumentsRequired
13
14
  from ccxt.base.errors import BadRequest
@@ -17,7 +18,6 @@ from ccxt.base.errors import InvalidOrder
17
18
  from ccxt.base.errors import OrderNotFound
18
19
  from ccxt.base.errors import DDoSProtection
19
20
  from ccxt.base.errors import ExchangeNotAvailable
20
- from ccxt.base.errors import AuthenticationError
21
21
  from ccxt.base.decimal_to_precision import TICK_SIZE
22
22
  from ccxt.base.precise import Precise
23
23
 
ccxt/p2b.py CHANGED
@@ -8,11 +8,11 @@ from ccxt.abstract.p2b import ImplicitAPI
8
8
  import hashlib
9
9
  from ccxt.base.types import Int, Market, Num, Order, OrderSide, OrderType, Str, Strings, Ticker, Tickers
10
10
  from typing import List
11
+ from ccxt.base.errors import AuthenticationError
11
12
  from ccxt.base.errors import ArgumentsRequired
12
13
  from ccxt.base.errors import BadRequest
13
14
  from ccxt.base.errors import InsufficientFunds
14
15
  from ccxt.base.errors import ExchangeNotAvailable
15
- from ccxt.base.errors import AuthenticationError
16
16
  from ccxt.base.decimal_to_precision import TICK_SIZE
17
17
 
18
18
 
ccxt/phemex.py CHANGED
@@ -10,6 +10,7 @@ import numbers
10
10
  from ccxt.base.types import Balances, Currencies, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
+ from ccxt.base.errors import AuthenticationError
13
14
  from ccxt.base.errors import PermissionDenied
14
15
  from ccxt.base.errors import AccountSuspended
15
16
  from ccxt.base.errors import ArgumentsRequired
@@ -23,7 +24,6 @@ from ccxt.base.errors import DuplicateOrderId
23
24
  from ccxt.base.errors import NotSupported
24
25
  from ccxt.base.errors import DDoSProtection
25
26
  from ccxt.base.errors import RateLimitExceeded
26
- from ccxt.base.errors import AuthenticationError
27
27
  from ccxt.base.decimal_to_precision import TICK_SIZE
28
28
  from ccxt.base.precise import Precise
29
29
 
ccxt/poloniex.py CHANGED
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import PermissionDenied
13
14
  from ccxt.base.errors import AccountSuspended
14
15
  from ccxt.base.errors import ArgumentsRequired
@@ -21,7 +22,6 @@ from ccxt.base.errors import NotSupported
21
22
  from ccxt.base.errors import ExchangeNotAvailable
22
23
  from ccxt.base.errors import OnMaintenance
23
24
  from ccxt.base.errors import RequestTimeout
24
- from ccxt.base.errors import AuthenticationError
25
25
  from ccxt.base.decimal_to_precision import TICK_SIZE
26
26
  from ccxt.base.precise import Precise
27
27
 
ccxt/poloniexfutures.py CHANGED
@@ -8,6 +8,7 @@ from ccxt.abstract.poloniexfutures import ImplicitAPI
8
8
  import hashlib
9
9
  from ccxt.base.types import Balances, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade
10
10
  from typing import List
11
+ from ccxt.base.errors import AuthenticationError
11
12
  from ccxt.base.errors import AccountSuspended
12
13
  from ccxt.base.errors import ArgumentsRequired
13
14
  from ccxt.base.errors import BadRequest
@@ -17,7 +18,6 @@ from ccxt.base.errors import NotSupported
17
18
  from ccxt.base.errors import RateLimitExceeded
18
19
  from ccxt.base.errors import ExchangeNotAvailable
19
20
  from ccxt.base.errors import InvalidNonce
20
- from ccxt.base.errors import AuthenticationError
21
21
  from ccxt.base.decimal_to_precision import TICK_SIZE
22
22
  from ccxt.base.precise import Precise
23
23
 
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.94'
7
+ __version__ = '4.2.96'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
ccxt/pro/ascendex.py CHANGED
@@ -9,8 +9,8 @@ import hashlib
9
9
  from ccxt.base.types import Balances, Int, Order, OrderBook, Str, Trade
10
10
  from ccxt.async_support.base.ws.client import Client
11
11
  from typing import List
12
- from ccxt.base.errors import NetworkError
13
12
  from ccxt.base.errors import AuthenticationError
13
+ from ccxt.base.errors import NetworkError
14
14
 
15
15
 
16
16
  class ascendex(ccxt.async_support.ascendex):
ccxt/pro/bitfinex2.py CHANGED
@@ -10,8 +10,8 @@ from ccxt.base.types import Balances, Int, Order, OrderBook, Str, Ticker, Trade
10
10
  from ccxt.async_support.base.ws.client import Client
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
- from ccxt.base.errors import InvalidNonce
14
13
  from ccxt.base.errors import AuthenticationError
14
+ from ccxt.base.errors import InvalidNonce
15
15
  from ccxt.base.precise import Precise
16
16
 
17
17
 
ccxt/pro/bitget.py CHANGED
@@ -10,12 +10,12 @@ from ccxt.base.types import Balances, Int, Order, OrderBook, Position, Str, Stri
10
10
  from ccxt.async_support.base.ws.client import Client
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
+ from ccxt.base.errors import AuthenticationError
13
14
  from ccxt.base.errors import ArgumentsRequired
14
15
  from ccxt.base.errors import BadRequest
15
16
  from ccxt.base.errors import NotSupported
16
17
  from ccxt.base.errors import RateLimitExceeded
17
18
  from ccxt.base.errors import InvalidNonce
18
- from ccxt.base.errors import AuthenticationError
19
19
  from ccxt.base.precise import Precise
20
20
 
21
21
 
ccxt/pro/bitmart.py CHANGED
@@ -11,9 +11,9 @@ from ccxt.base.types import Balances, Int, Market, Order, OrderBook, Position, S
11
11
  from ccxt.async_support.base.ws.client import Client
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
+ from ccxt.base.errors import AuthenticationError
14
15
  from ccxt.base.errors import ArgumentsRequired
15
16
  from ccxt.base.errors import NotSupported
16
- from ccxt.base.errors import AuthenticationError
17
17
 
18
18
 
19
19
  class bitmart(ccxt.async_support.bitmart):
ccxt/pro/bitmex.py CHANGED
@@ -10,8 +10,8 @@ from ccxt.base.types import Balances, Int, Order, OrderBook, Position, Str, Stri
10
10
  from ccxt.async_support.base.ws.client import Client
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
- from ccxt.base.errors import RateLimitExceeded
14
13
  from ccxt.base.errors import AuthenticationError
14
+ from ccxt.base.errors import RateLimitExceeded
15
15
 
16
16
 
17
17
  class bitmex(ccxt.async_support.bitmex):
ccxt/pro/bitstamp.py CHANGED
@@ -8,8 +8,8 @@ from ccxt.async_support.base.ws.cache import ArrayCache, ArrayCacheBySymbolById
8
8
  from ccxt.base.types import Int, Order, OrderBook, Str, Trade
9
9
  from ccxt.async_support.base.ws.client import Client
10
10
  from typing import List
11
- from ccxt.base.errors import ArgumentsRequired
12
11
  from ccxt.base.errors import AuthenticationError
12
+ from ccxt.base.errors import ArgumentsRequired
13
13
 
14
14
 
15
15
  class bitstamp(ccxt.async_support.bitstamp):
ccxt/pro/bitvavo.py CHANGED
@@ -10,8 +10,8 @@ from ccxt.base.types import Balances, Int, Num, Order, OrderBook, OrderSide, Ord
10
10
  from ccxt.async_support.base.ws.client import Client
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
- from ccxt.base.errors import ArgumentsRequired
14
13
  from ccxt.base.errors import AuthenticationError
14
+ from ccxt.base.errors import ArgumentsRequired
15
15
 
16
16
 
17
17
  class bitvavo(ccxt.async_support.bitvavo):
ccxt/pro/blockchaincom.py CHANGED
@@ -9,8 +9,8 @@ from ccxt.base.types import Balances, Int, Order, OrderBook, Str, Ticker, Trade
9
9
  from ccxt.async_support.base.ws.client import Client
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
- from ccxt.base.errors import NotSupported
13
12
  from ccxt.base.errors import AuthenticationError
13
+ from ccxt.base.errors import NotSupported
14
14
 
15
15
 
16
16
  class blockchaincom(ccxt.async_support.blockchaincom):
ccxt/pro/bybit.py CHANGED
@@ -11,9 +11,9 @@ from ccxt.base.types import Balances, Int, Order, OrderBook, Position, Str, Stri
11
11
  from ccxt.async_support.base.ws.client import Client
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
+ from ccxt.base.errors import AuthenticationError
14
15
  from ccxt.base.errors import ArgumentsRequired
15
16
  from ccxt.base.errors import BadRequest
16
- from ccxt.base.errors import AuthenticationError
17
17
 
18
18
 
19
19
  class bybit(ccxt.async_support.bybit):
ccxt/pro/coinbase.py CHANGED
@@ -136,6 +136,11 @@ class coinbase(ccxt.async_support.coinbase):
136
136
  # "low_52_w": "15460",
137
137
  # "high_52_w": "48240",
138
138
  # "price_percent_chg_24_h": "-4.15775596190603"
139
+ # new 2024-04-12
140
+ # "best_bid":"21835.29",
141
+ # "best_bid_quantity": "0.02000000",
142
+ # "best_ask":"23011.18",
143
+ # "best_ask_quantity": "0.01500000"
139
144
  # }
140
145
  # ]
141
146
  # }
@@ -161,6 +166,11 @@ class coinbase(ccxt.async_support.coinbase):
161
166
  # "low_52_w": "0.04908",
162
167
  # "high_52_w": "0.1801",
163
168
  # "price_percent_chg_24_h": "0.50177456859626"
169
+ # new 2024-04-12
170
+ # "best_bid":"0.07989",
171
+ # "best_bid_quantity": "500.0",
172
+ # "best_ask":"0.08308",
173
+ # "best_ask_quantity": "300.0"
164
174
  # }
165
175
  # ]
166
176
  # }
@@ -182,6 +192,8 @@ class coinbase(ccxt.async_support.coinbase):
182
192
  messageHash = channel + '::' + wsMarketId
183
193
  newTickers.append(result)
184
194
  client.resolve(result, messageHash)
195
+ if messageHash.endswith('USD'):
196
+ client.resolve(result, messageHash + 'C') # sometimes we subscribe to BTC/USDC and coinbase returns BTC/USD
185
197
  messageHashes = self.find_message_hashes(client, 'ticker_batch::')
186
198
  for i in range(0, len(messageHashes)):
187
199
  messageHash = messageHashes[i]
@@ -191,6 +203,8 @@ class coinbase(ccxt.async_support.coinbase):
191
203
  tickers = self.filter_by_array(newTickers, 'symbol', symbols)
192
204
  if not self.is_empty(tickers):
193
205
  client.resolve(tickers, messageHash)
206
+ if messageHash.endswith('USD'):
207
+ client.resolve(tickers, messageHash + 'C') # sometimes we subscribe to BTC/USDC and coinbase returns BTC/USD
194
208
  return message
195
209
 
196
210
  def parse_ws_ticker(self, ticker, market=None):
@@ -205,6 +219,11 @@ class coinbase(ccxt.async_support.coinbase):
205
219
  # "low_52_w": "0.04908",
206
220
  # "high_52_w": "0.1801",
207
221
  # "price_percent_chg_24_h": "0.50177456859626"
222
+ # new 2024-04-12
223
+ # "best_bid":"0.07989",
224
+ # "best_bid_quantity": "500.0",
225
+ # "best_ask":"0.08308",
226
+ # "best_ask_quantity": "300.0"
208
227
  # }
209
228
  #
210
229
  marketId = self.safe_string(ticker, 'product_id')
@@ -217,10 +236,10 @@ class coinbase(ccxt.async_support.coinbase):
217
236
  'datetime': self.iso8601(timestamp),
218
237
  'high': self.safe_string(ticker, 'high_24_h'),
219
238
  'low': self.safe_string(ticker, 'low_24_h'),
220
- 'bid': None,
221
- 'bidVolume': None,
222
- 'ask': None,
223
- 'askVolume': None,
239
+ 'bid': self.safe_string(ticker, 'best_bid'),
240
+ 'bidVolume': self.safe_string(ticker, 'best_bid_quantity'),
241
+ 'ask': self.safe_string(ticker, 'best_ask'),
242
+ 'askVolume': self.safe_string(ticker, 'best_ask_quantity'),
224
243
  'vwap': None,
225
244
  'open': None,
226
245
  'close': last,
@@ -327,6 +346,8 @@ class coinbase(ccxt.async_support.coinbase):
327
346
  item = currentTrades[i]
328
347
  tradesArray.append(self.parse_trade(item))
329
348
  client.resolve(tradesArray, messageHash)
349
+ if marketId.endswith('USD'):
350
+ client.resolve(tradesArray, messageHash + 'C') # sometimes we subscribe to BTC/USDC and coinbase returns BTC/USD
330
351
  return message
331
352
 
332
353
  def handle_order(self, client, message):
@@ -378,6 +399,8 @@ class coinbase(ccxt.async_support.coinbase):
378
399
  marketId = marketIds[i]
379
400
  messageHash = 'user::' + marketId
380
401
  client.resolve(self.orders, messageHash)
402
+ if messageHash.endswith('USD'):
403
+ client.resolve(self.orders, messageHash + 'C') # sometimes we subscribe to BTC/USDC and coinbase returns BTC/USD
381
404
  client.resolve(self.orders, 'user')
382
405
  return message
383
406
 
@@ -488,6 +511,8 @@ class coinbase(ccxt.async_support.coinbase):
488
511
  orderbook['datetime'] = None
489
512
  orderbook['symbol'] = symbol
490
513
  client.resolve(orderbook, messageHash)
514
+ if messageHash.endswith('USD'):
515
+ client.resolve(orderbook, messageHash + 'C') # sometimes we subscribe to BTC/USDC and coinbase returns BTC/USD
491
516
  elif type == 'update':
492
517
  orderbook = self.orderbooks[symbol]
493
518
  self.handle_order_book_helper(orderbook, updates)
@@ -495,6 +520,8 @@ class coinbase(ccxt.async_support.coinbase):
495
520
  orderbook['timestamp'] = self.parse8601(datetime)
496
521
  orderbook['symbol'] = symbol
497
522
  client.resolve(orderbook, messageHash)
523
+ if messageHash.endswith('USD'):
524
+ client.resolve(orderbook, messageHash + 'C') # sometimes we subscribe to BTC/USDC and coinbase returns BTC/USD
498
525
  return message
499
526
 
500
527
  def handle_subscription_status(self, client, message):
@@ -10,8 +10,8 @@ from ccxt.base.types import Int, Market, OrderBook, Strings, Ticker, Trade
10
10
  from ccxt.async_support.base.ws.client import Client
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
- from ccxt.base.errors import NotSupported
14
13
  from ccxt.base.errors import AuthenticationError
14
+ from ccxt.base.errors import NotSupported
15
15
 
16
16
 
17
17
  class coinbaseinternational(ccxt.async_support.coinbaseinternational):
ccxt/pro/coinbasepro.py CHANGED
@@ -10,10 +10,10 @@ from ccxt.base.types import Int, Order, OrderBook, Str, Strings, Ticker, Tickers
10
10
  from ccxt.async_support.base.ws.client import Client
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
+ from ccxt.base.errors import AuthenticationError
13
14
  from ccxt.base.errors import ArgumentsRequired
14
15
  from ccxt.base.errors import BadRequest
15
16
  from ccxt.base.errors import BadSymbol
16
- from ccxt.base.errors import AuthenticationError
17
17
 
18
18
 
19
19
  class coinbasepro(ccxt.async_support.coinbasepro):