ccxt 4.3.52__py2.py3-none-any.whl → 4.3.54__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 (44) hide show
  1. ccxt/__init__.py +3 -1
  2. ccxt/abstract/vertex.py +19 -0
  3. ccxt/async_support/__init__.py +3 -1
  4. ccxt/async_support/base/exchange.py +1 -1
  5. ccxt/async_support/base/ws/cache.py +2 -2
  6. ccxt/async_support/binance.py +1 -1
  7. ccxt/async_support/bingx.py +1 -1
  8. ccxt/async_support/bitget.py +1 -1
  9. ccxt/async_support/bitmart.py +1 -1
  10. ccxt/async_support/coinex.py +1 -1
  11. ccxt/async_support/htx.py +1 -1
  12. ccxt/async_support/hyperliquid.py +27 -25
  13. ccxt/async_support/phemex.py +28 -1
  14. ccxt/async_support/poloniex.py +2 -1
  15. ccxt/async_support/probit.py +9 -5
  16. ccxt/async_support/vertex.py +2811 -0
  17. ccxt/async_support/woo.py +26 -18
  18. ccxt/base/exchange.py +2 -2
  19. ccxt/base/precise.py +10 -0
  20. ccxt/binance.py +1 -1
  21. ccxt/bingx.py +1 -1
  22. ccxt/bitget.py +1 -1
  23. ccxt/bitmart.py +1 -1
  24. ccxt/coinex.py +1 -1
  25. ccxt/htx.py +1 -1
  26. ccxt/hyperliquid.py +27 -25
  27. ccxt/phemex.py +28 -1
  28. ccxt/poloniex.py +2 -1
  29. ccxt/pro/__init__.py +3 -1
  30. ccxt/pro/binance.py +1 -1
  31. ccxt/pro/bybit.py +18 -12
  32. ccxt/pro/kucoin.py +63 -26
  33. ccxt/pro/probit.py +6 -4
  34. ccxt/pro/vertex.py +916 -0
  35. ccxt/probit.py +9 -5
  36. ccxt/test/test_async.py +37 -3
  37. ccxt/test/test_sync.py +37 -3
  38. ccxt/vertex.py +2811 -0
  39. ccxt/woo.py +26 -18
  40. {ccxt-4.3.52.dist-info → ccxt-4.3.54.dist-info}/METADATA +7 -6
  41. {ccxt-4.3.52.dist-info → ccxt-4.3.54.dist-info}/RECORD +44 -40
  42. {ccxt-4.3.52.dist-info → ccxt-4.3.54.dist-info}/LICENSE.txt +0 -0
  43. {ccxt-4.3.52.dist-info → ccxt-4.3.54.dist-info}/WHEEL +0 -0
  44. {ccxt-4.3.52.dist-info → ccxt-4.3.54.dist-info}/top_level.txt +0 -0
ccxt/async_support/woo.py CHANGED
@@ -52,7 +52,7 @@ class woo(Exchange, ImplicitAPI):
52
52
  'createMarketBuyOrderWithCost': True,
53
53
  'createMarketOrder': False,
54
54
  'createMarketOrderWithCost': False,
55
- 'createMarketSellOrderWithCost': False,
55
+ 'createMarketSellOrderWithCost': True,
56
56
  'createOrder': True,
57
57
  'createOrderWithTakeProfitAndStopLoss': True,
58
58
  'createReduceOnlyOrder': True,
@@ -832,8 +832,22 @@ class woo(Exchange, ImplicitAPI):
832
832
  market = self.market(symbol)
833
833
  if not market['spot']:
834
834
  raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
835
- params['createMarketBuyOrderRequiresPrice'] = False
836
- return await self.create_order(symbol, 'market', 'buy', cost, None, params)
835
+ return await self.create_order(symbol, 'market', 'buy', cost, 1, params)
836
+
837
+ async def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
838
+ """
839
+ create a market sell order by providing the symbol and cost
840
+ :see: https://docs.woo.org/#send-order
841
+ :param str symbol: unified symbol of the market to create an order in
842
+ :param float cost: how much you want to trade in units of the quote currency
843
+ :param dict [params]: extra parameters specific to the exchange API endpoint
844
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
845
+ """
846
+ await self.load_markets()
847
+ market = self.market(symbol)
848
+ if not market['spot']:
849
+ raise NotSupported(self.id + ' createMarketSellOrderWithCost() supports spot orders only')
850
+ return await self.create_order(symbol, 'market', 'sell', cost, 1, params)
837
851
 
838
852
  async def create_trailing_amount_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingAmount=None, trailingTriggerPrice=None, params={}) -> Order:
839
853
  """
@@ -941,28 +955,22 @@ class woo(Exchange, ImplicitAPI):
941
955
  request['order_type'] = 'IOC'
942
956
  if reduceOnly:
943
957
  request[reduceOnlyKey] = reduceOnly
944
- if price is not None:
958
+ if not isMarket and price is not None:
945
959
  request[priceKey] = self.price_to_precision(symbol, price)
946
960
  if isMarket and not isStop:
947
961
  # for market buy it requires the amount of quote currency to spend
948
- if market['spot'] and orderSide == 'BUY':
962
+ cost = self.safe_string_2(params, 'cost', 'order_amount')
963
+ params = self.omit(params, ['cost', 'order_amount'])
964
+ isPriceProvided = price is not None
965
+ if market['spot'] and (isPriceProvided or (cost is not None)):
949
966
  quoteAmount = None
950
- createMarketBuyOrderRequiresPrice = True
951
- createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
952
- cost = self.safe_number_2(params, 'cost', 'order_amount')
953
- params = self.omit(params, ['cost', 'order_amount'])
954
967
  if cost is not None:
955
968
  quoteAmount = self.cost_to_precision(symbol, cost)
956
- elif createMarketBuyOrderRequiresPrice:
957
- if price is None:
958
- raise InvalidOrder(self.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend(quote quantity) in the amount argument')
959
- else:
960
- amountString = self.number_to_string(amount)
961
- priceString = self.number_to_string(price)
962
- costRequest = Precise.string_mul(amountString, priceString)
963
- quoteAmount = self.cost_to_precision(symbol, costRequest)
964
969
  else:
965
- quoteAmount = self.cost_to_precision(symbol, amount)
970
+ amountString = self.number_to_string(amount)
971
+ priceString = self.number_to_string(price)
972
+ costRequest = Precise.string_mul(amountString, priceString)
973
+ quoteAmount = self.cost_to_precision(symbol, costRequest)
966
974
  request['order_amount'] = quoteAmount
967
975
  else:
968
976
  request['order_quantity'] = self.amount_to_precision(symbol, amount)
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.3.52'
7
+ __version__ = '4.3.54'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2255,7 +2255,7 @@ class Exchange(object):
2255
2255
  def parse_borrow_interest(self, info: dict, market: Market = None):
2256
2256
  raise NotSupported(self.id + ' parseBorrowInterest() is not supported yet')
2257
2257
 
2258
- def parse_isolated_borrow_rate(self, info, market: Market = None):
2258
+ def parse_isolated_borrow_rate(self, info: dict, market: Market = None):
2259
2259
  raise NotSupported(self.id + ' parseIsolatedBorrowRate() is not supported yet')
2260
2260
 
2261
2261
  def parse_ws_trade(self, trade, market: Market = None):
ccxt/base/precise.py CHANGED
@@ -126,6 +126,10 @@ class Precise:
126
126
  result = numerator % denominator
127
127
  return Precise(result, rationizerDenominator + other.decimals)
128
128
 
129
+ def orn(self, other):
130
+ integer_result = self.integer | other.integer
131
+ return Precise(integer_result, self.decimals)
132
+
129
133
  def min(self, other):
130
134
  return self if self.lt(other) else other
131
135
 
@@ -238,6 +242,12 @@ class Precise:
238
242
  return None
239
243
  return str(Precise(string1).mod(Precise(string2)))
240
244
 
245
+ @staticmethod
246
+ def string_or(string1, string2):
247
+ if string1 is None or string2 is None:
248
+ return None
249
+ return str(Precise(string1).orn(Precise(string2)))
250
+
241
251
  @staticmethod
242
252
  def string_equals(string1, string2):
243
253
  if string1 is None or string2 is None:
ccxt/binance.py CHANGED
@@ -10681,7 +10681,7 @@ class binance(Exchange, ImplicitAPI):
10681
10681
  'info': info,
10682
10682
  }
10683
10683
 
10684
- def parse_isolated_borrow_rate(self, info, market: Market = None):
10684
+ def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
10685
10685
  #
10686
10686
  # {
10687
10687
  # "vipLevel": 0,
ccxt/bingx.py CHANGED
@@ -703,7 +703,7 @@ class bingx(Exchange, ImplicitAPI):
703
703
  'limits': {
704
704
  'leverage': {
705
705
  'min': None,
706
- 'max': self.safe_integer(market, 'maxLongLeverage'),
706
+ 'max': None,
707
707
  },
708
708
  'amount': {
709
709
  'min': self.safe_number_2(market, 'minQty', 'tradeMinQuantity'),
ccxt/bitget.py CHANGED
@@ -7450,7 +7450,7 @@ class bitget(Exchange, ImplicitAPI):
7450
7450
  first['timestamp'] = timestamp
7451
7451
  return self.parse_isolated_borrow_rate(first, market)
7452
7452
 
7453
- def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
7453
+ def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
7454
7454
  #
7455
7455
  # {
7456
7456
  # "symbol": "BTCUSDT",
ccxt/bitmart.py CHANGED
@@ -3601,7 +3601,7 @@ class bitmart(Exchange, ImplicitAPI):
3601
3601
  borrowRate = self.safe_value(symbols, 0)
3602
3602
  return self.parse_isolated_borrow_rate(borrowRate, market)
3603
3603
 
3604
- def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
3604
+ def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
3605
3605
  #
3606
3606
  # {
3607
3607
  # "symbol": "BTC_USDT",
ccxt/coinex.py CHANGED
@@ -4837,7 +4837,7 @@ class coinex(Exchange, ImplicitAPI):
4837
4837
  data = self.safe_list(response, 'data', [])
4838
4838
  return self.parse_transactions(data, currency, since, limit)
4839
4839
 
4840
- def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
4840
+ def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
4841
4841
  #
4842
4842
  # {
4843
4843
  # "market": "BTCUSDT",
ccxt/htx.py CHANGED
@@ -6180,7 +6180,7 @@ class htx(Exchange, ImplicitAPI):
6180
6180
  data = self.safe_value(response, 'data', [])
6181
6181
  return self.parse_isolated_borrow_rates(data)
6182
6182
 
6183
- def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
6183
+ def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
6184
6184
  #
6185
6185
  # {
6186
6186
  # "symbol": "1inchusdt",
ccxt/hyperliquid.py CHANGED
@@ -444,23 +444,26 @@ class hyperliquid(Exchange, ImplicitAPI):
444
444
  for i in range(0, len(meta)):
445
445
  market = self.safe_dict(meta, i, {})
446
446
  marketName = self.safe_string(market, 'name')
447
- if marketName.find('/') < 0:
448
- # there are some weird spot markets in testnet, eg @2
449
- continue
450
- marketParts = marketName.split('/')
451
- baseName = self.safe_string(marketParts, 0)
452
- quoteId = self.safe_string(marketParts, 1)
453
- base = self.safe_currency_code(baseName)
454
- quote = self.safe_currency_code(quoteId)
455
- symbol = base + '/' + quote
447
+ # if marketName.find('/') < 0:
448
+ # # there are some weird spot markets in testnet, eg @2
449
+ # continue
450
+ # }
451
+ # marketParts = marketName.split('/')
452
+ # baseName = self.safe_string(marketParts, 0)
453
+ # quoteId = self.safe_string(marketParts, 1)
456
454
  fees = self.safe_dict(self.fees, 'spot', {})
457
455
  taker = self.safe_number(fees, 'taker')
458
456
  maker = self.safe_number(fees, 'maker')
459
457
  tokensPos = self.safe_list(market, 'tokens', [])
460
458
  baseTokenPos = self.safe_integer(tokensPos, 0)
461
- # quoteTokenPos = self.safe_integer(tokensPos, 1)
459
+ quoteTokenPos = self.safe_integer(tokensPos, 1)
462
460
  baseTokenInfo = self.safe_dict(tokens, baseTokenPos, {})
463
- # quoteTokenInfo = self.safe_dict(tokens, quoteTokenPos, {})
461
+ quoteTokenInfo = self.safe_dict(tokens, quoteTokenPos, {})
462
+ baseName = self.safe_string(baseTokenInfo, 'name')
463
+ quoteId = self.safe_string(quoteTokenInfo, 'name')
464
+ base = self.safe_currency_code(baseName)
465
+ quote = self.safe_currency_code(quoteId)
466
+ symbol = base + '/' + quote
464
467
  innerBaseTokenInfo = self.safe_dict(baseTokenInfo, 'spec', baseTokenInfo)
465
468
  # innerQuoteTokenInfo = self.safe_dict(quoteTokenInfo, 'spec', quoteTokenInfo)
466
469
  amountPrecision = self.parse_number(self.parse_precision(self.safe_string(innerBaseTokenInfo, 'szDecimals')))
@@ -1114,7 +1117,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1114
1117
  }
1115
1118
  if clientOrderId is not None:
1116
1119
  orderObj['c'] = clientOrderId
1117
- orderReq.append(self.extend(orderObj, orderParams))
1120
+ orderReq.append(orderObj)
1118
1121
  vaultAddress = self.format_vault_address(self.safe_string(params, 'vaultAddress'))
1119
1122
  orderAction: dict = {
1120
1123
  'type': 'order',
@@ -1134,7 +1137,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1134
1137
  if vaultAddress is not None:
1135
1138
  params = self.omit(params, 'vaultAddress')
1136
1139
  request['vaultAddress'] = vaultAddress
1137
- response = self.privatePostExchange(self.extend(request, params))
1140
+ response = self.privatePostExchange(request)
1138
1141
  #
1139
1142
  # {
1140
1143
  # "status": "ok",
@@ -1226,7 +1229,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1226
1229
  if vaultAddress is not None:
1227
1230
  params = self.omit(params, 'vaultAddress')
1228
1231
  request['vaultAddress'] = vaultAddress
1229
- response = self.privatePostExchange(self.extend(request, params))
1232
+ response = self.privatePostExchange(request)
1230
1233
  #
1231
1234
  # {
1232
1235
  # "status":"ok",
@@ -1302,7 +1305,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1302
1305
  if vaultAddress is not None:
1303
1306
  params = self.omit(params, 'vaultAddress')
1304
1307
  request['vaultAddress'] = vaultAddress
1305
- response = self.privatePostExchange(self.extend(request, params))
1308
+ response = self.privatePostExchange(request)
1306
1309
  #
1307
1310
  # {
1308
1311
  # "status":"ok",
@@ -1345,7 +1348,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1345
1348
  if vaultAddress is not None:
1346
1349
  params = self.omit(params, 'vaultAddress')
1347
1350
  request['vaultAddress'] = vaultAddress
1348
- response = self.privatePostExchange(self.extend(request, params))
1351
+ response = self.privatePostExchange(request)
1349
1352
  #
1350
1353
  # {
1351
1354
  # "status":"err",
@@ -1454,7 +1457,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1454
1457
  if vaultAddress is not None:
1455
1458
  params = self.omit(params, 'vaultAddress')
1456
1459
  request['vaultAddress'] = vaultAddress
1457
- response = self.privatePostExchange(self.extend(request, params))
1460
+ response = self.privatePostExchange(request)
1458
1461
  #
1459
1462
  # {
1460
1463
  # "status": "ok",
@@ -2096,10 +2099,9 @@ class hyperliquid(Exchange, ImplicitAPI):
2096
2099
  params = self.omit(params, 'vaultAddress')
2097
2100
  if vaultAddress.startswith('0x'):
2098
2101
  vaultAddress = vaultAddress.replace('0x', '')
2099
- extendedAction = self.extend(updateAction, params)
2100
- signature = self.sign_l1_action(extendedAction, nonce, vaultAddress)
2102
+ signature = self.sign_l1_action(updateAction, nonce, vaultAddress)
2101
2103
  request: dict = {
2102
- 'action': extendedAction,
2104
+ 'action': updateAction,
2103
2105
  'nonce': nonce,
2104
2106
  'signature': signature,
2105
2107
  # 'vaultAddress': vaultAddress,
@@ -2152,7 +2154,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2152
2154
  if vaultAddress is not None:
2153
2155
  params = self.omit(params, 'vaultAddress')
2154
2156
  request['vaultAddress'] = vaultAddress
2155
- response = self.privatePostExchange(self.extend(request, params))
2157
+ response = self.privatePostExchange(request)
2156
2158
  #
2157
2159
  # {
2158
2160
  # 'response': {
@@ -2210,7 +2212,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2210
2212
  if vaultAddress is not None:
2211
2213
  params = self.omit(params, 'vaultAddress')
2212
2214
  request['vaultAddress'] = vaultAddress
2213
- response = self.privatePostExchange(self.extend(request, params))
2215
+ response = self.privatePostExchange(request)
2214
2216
  #
2215
2217
  # {
2216
2218
  # 'response': {
@@ -2274,7 +2276,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2274
2276
  }
2275
2277
  signature = self.sign_l1_action(action, nonce, vaultAddress)
2276
2278
  innerRequest: dict = {
2277
- 'action': self.extend(action, params),
2279
+ 'action': action,
2278
2280
  'nonce': nonce,
2279
2281
  'signature': signature,
2280
2282
  }
@@ -2307,7 +2309,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2307
2309
  'nonce': nonce,
2308
2310
  'signature': sig,
2309
2311
  }
2310
- response = self.privatePostExchange(self.extend(request, params))
2312
+ response = self.privatePostExchange(request)
2311
2313
  return response
2312
2314
 
2313
2315
  def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
@@ -2349,7 +2351,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2349
2351
  'nonce': nonce,
2350
2352
  'signature': sig,
2351
2353
  }
2352
- response = self.privatePostExchange(self.extend(request, params))
2354
+ response = self.privatePostExchange(request)
2353
2355
  return self.parse_transaction(response)
2354
2356
 
2355
2357
  def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
ccxt/phemex.py CHANGED
@@ -2763,11 +2763,38 @@ class phemex(Exchange, ImplicitAPI):
2763
2763
  response = None
2764
2764
  if market['settle'] == 'USDT':
2765
2765
  response = self.privateDeleteGOrdersAll(self.extend(request, params))
2766
+ #
2767
+ # {
2768
+ # code: '0',
2769
+ # msg: '',
2770
+ # data: '1'
2771
+ # }
2772
+ #
2766
2773
  elif market['swap']:
2767
2774
  response = self.privateDeleteOrdersAll(self.extend(request, params))
2775
+ #
2776
+ # {
2777
+ # code: '0',
2778
+ # msg: '',
2779
+ # data: '1'
2780
+ # }
2781
+ #
2768
2782
  else:
2769
2783
  response = self.privateDeleteSpotOrdersAll(self.extend(request, params))
2770
- return response
2784
+ #
2785
+ # {
2786
+ # code: '0',
2787
+ # msg: '',
2788
+ # data: {
2789
+ # total: '1'
2790
+ # }
2791
+ # }
2792
+ #
2793
+ return [
2794
+ self.safe_order({
2795
+ 'info': response,
2796
+ }),
2797
+ ]
2771
2798
 
2772
2799
  def fetch_order(self, id: str, symbol: Str = None, params={}):
2773
2800
  """
ccxt/poloniex.py CHANGED
@@ -1255,7 +1255,8 @@ class poloniex(Exchange, ImplicitAPI):
1255
1255
  # }
1256
1256
  #
1257
1257
  response = self.extend(response, {
1258
- 'type': side,
1258
+ 'type': type,
1259
+ 'side': side,
1259
1260
  })
1260
1261
  return self.parse_order(response, market)
1261
1262
 
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.3.52'
7
+ __version__ = '4.3.54'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
@@ -74,6 +74,7 @@ from ccxt.pro.poloniex import poloniex # noqa
74
74
  from ccxt.pro.poloniexfutures import poloniexfutures # noqa: F401
75
75
  from ccxt.pro.probit import probit # noqa: F401
76
76
  from ccxt.pro.upbit import upbit # noqa: F401
77
+ from ccxt.pro.vertex import vertex # noqa: F401
77
78
  from ccxt.pro.wazirx import wazirx # noqa: F401
78
79
  from ccxt.pro.whitebit import whitebit # noqa: F401
79
80
  from ccxt.pro.woo import woo # noqa: F401
@@ -142,6 +143,7 @@ exchanges = [
142
143
  'poloniexfutures',
143
144
  'probit',
144
145
  'upbit',
146
+ 'vertex',
145
147
  'wazirx',
146
148
  'whitebit',
147
149
  'woo',
ccxt/pro/binance.py CHANGED
@@ -3409,7 +3409,7 @@ class binance(ccxt.async_support.binance):
3409
3409
  rejected = True
3410
3410
  # private endpoint uses id
3411
3411
  client.reject(e, id)
3412
- # public endpoint stores messageHash in subscriptios
3412
+ # public endpoint stores messageHash in subscriptions
3413
3413
  subscriptionKeys = list(client.subscriptions.keys())
3414
3414
  for i in range(0, len(subscriptionKeys)):
3415
3415
  subscriptionHash = subscriptionKeys[i]
ccxt/pro/bybit.py CHANGED
@@ -142,7 +142,7 @@ class bybit(ccxt.async_support.bybit):
142
142
  self.options['requestId'] = requestId
143
143
  return requestId
144
144
 
145
- def get_url_by_market_type(self, symbol: Str = None, isPrivate=False, method: Str = None, params={}):
145
+ async def get_url_by_market_type(self, symbol: Str = None, isPrivate=False, method: Str = None, params={}):
146
146
  accessibility = 'private' if isPrivate else 'public'
147
147
  isUsdcSettled = None
148
148
  isSpot = None
@@ -160,7 +160,13 @@ class bybit(ccxt.async_support.bybit):
160
160
  isUsdcSettled = (defaultSettle == 'USDC')
161
161
  isSpot = (type == 'spot')
162
162
  if isPrivate:
163
- url = url[accessibility]['usdc'] if (isUsdcSettled) else url[accessibility]['contract']
163
+ unified = await self.isUnifiedEnabled()
164
+ isUnifiedMargin = self.safe_bool(unified, 0, False)
165
+ isUnifiedAccount = self.safe_bool(unified, 1, False)
166
+ if isUsdcSettled and not isUnifiedMargin and not isUnifiedAccount:
167
+ url = url[accessibility]['usdc']
168
+ else:
169
+ url = url[accessibility]['contract']
164
170
  else:
165
171
  if isSpot:
166
172
  url = url[accessibility]['spot']
@@ -313,7 +319,7 @@ class bybit(ccxt.async_support.bybit):
313
319
  market = self.market(symbol)
314
320
  symbol = market['symbol']
315
321
  messageHash = 'ticker:' + symbol
316
- url = self.get_url_by_market_type(symbol, False, 'watchTicker', params)
322
+ url = await self.get_url_by_market_type(symbol, False, 'watchTicker', params)
317
323
  params = self.clean_params(params)
318
324
  options = self.safe_value(self.options, 'watchTicker', {})
319
325
  topic = self.safe_string(options, 'name', 'tickers')
@@ -335,7 +341,7 @@ class bybit(ccxt.async_support.bybit):
335
341
  await self.load_markets()
336
342
  symbols = self.market_symbols(symbols, None, False)
337
343
  messageHashes = []
338
- url = self.get_url_by_market_type(symbols[0], False, 'watchTickers', params)
344
+ url = await self.get_url_by_market_type(symbols[0], False, 'watchTickers', params)
339
345
  params = self.clean_params(params)
340
346
  options = self.safe_value(self.options, 'watchTickers', {})
341
347
  topic = self.safe_string(options, 'name', 'tickers')
@@ -510,7 +516,7 @@ class bybit(ccxt.async_support.bybit):
510
516
  await self.load_markets()
511
517
  market = self.market(symbol)
512
518
  symbol = market['symbol']
513
- url = self.get_url_by_market_type(symbol, False, 'watchOHLCV', params)
519
+ url = await self.get_url_by_market_type(symbol, False, 'watchOHLCV', params)
514
520
  params = self.clean_params(params)
515
521
  ohlcv = None
516
522
  timeframeId = self.safe_string(self.timeframes, timeframe, timeframe)
@@ -619,7 +625,7 @@ class bybit(ccxt.async_support.bybit):
619
625
  if symbolsLength == 0:
620
626
  raise ArgumentsRequired(self.id + ' watchOrderBookForSymbols() requires a non-empty array of symbols')
621
627
  symbols = self.market_symbols(symbols)
622
- url = self.get_url_by_market_type(symbols[0], False, 'watchOrderBook', params)
628
+ url = await self.get_url_by_market_type(symbols[0], False, 'watchOrderBook', params)
623
629
  params = self.clean_params(params)
624
630
  market = self.market(symbols[0])
625
631
  if limit is None:
@@ -737,7 +743,7 @@ class bybit(ccxt.async_support.bybit):
737
743
  if symbolsLength == 0:
738
744
  raise ArgumentsRequired(self.id + ' watchTradesForSymbols() requires a non-empty array of symbols')
739
745
  params = self.clean_params(params)
740
- url = self.get_url_by_market_type(symbols[0], False, 'watchTrades', params)
746
+ url = await self.get_url_by_market_type(symbols[0], False, 'watchTrades', params)
741
747
  topics = []
742
748
  messageHashes = []
743
749
  for i in range(0, len(symbols)):
@@ -887,7 +893,7 @@ class bybit(ccxt.async_support.bybit):
887
893
  if symbol is not None:
888
894
  symbol = self.symbol(symbol)
889
895
  messageHash += ':' + symbol
890
- url = self.get_url_by_market_type(symbol, True, method, params)
896
+ url = await self.get_url_by_market_type(symbol, True, method, params)
891
897
  await self.authenticate(url)
892
898
  topicByMarket: dict = {
893
899
  'spot': 'ticketInfo',
@@ -1006,7 +1012,7 @@ class bybit(ccxt.async_support.bybit):
1006
1012
  symbols = self.market_symbols(symbols)
1007
1013
  messageHash = '::' + ','.join(symbols)
1008
1014
  firstSymbol = self.safe_string(symbols, 0)
1009
- url = self.get_url_by_market_type(firstSymbol, True, method, params)
1015
+ url = await self.get_url_by_market_type(firstSymbol, True, method, params)
1010
1016
  messageHash = 'positions' + messageHash
1011
1017
  client = self.client(url)
1012
1018
  await self.authenticate(url)
@@ -1141,7 +1147,7 @@ class bybit(ccxt.async_support.bybit):
1141
1147
  await self.load_markets()
1142
1148
  market = self.market(symbol)
1143
1149
  symbol = market['symbol']
1144
- url = self.get_url_by_market_type(symbol, False, 'watchLiquidations', params)
1150
+ url = await self.get_url_by_market_type(symbol, False, 'watchLiquidations', params)
1145
1151
  params = self.clean_params(params)
1146
1152
  messageHash = 'liquidations::' + symbol
1147
1153
  topic = 'liquidation.' + market['id']
@@ -1220,7 +1226,7 @@ class bybit(ccxt.async_support.bybit):
1220
1226
  if symbol is not None:
1221
1227
  symbol = self.symbol(symbol)
1222
1228
  messageHash += ':' + symbol
1223
- url = self.get_url_by_market_type(symbol, True, method, params)
1229
+ url = await self.get_url_by_market_type(symbol, True, method, params)
1224
1230
  await self.authenticate(url)
1225
1231
  topicsByMarket: dict = {
1226
1232
  'spot': ['order', 'stopOrder'],
@@ -1518,7 +1524,7 @@ class bybit(ccxt.async_support.bybit):
1518
1524
  unified = await self.isUnifiedEnabled()
1519
1525
  isUnifiedMargin = self.safe_bool(unified, 0, False)
1520
1526
  isUnifiedAccount = self.safe_bool(unified, 1, False)
1521
- url = self.get_url_by_market_type(None, True, method, params)
1527
+ url = await self.get_url_by_market_type(None, True, method, params)
1522
1528
  await self.authenticate(url)
1523
1529
  topicByMarket: dict = {
1524
1530
  'spot': 'outboundAccountInfo',