ccxt 4.3.19__py2.py3-none-any.whl → 4.3.21__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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

Files changed (49) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/binance.py +1 -0
  3. ccxt/abstract/binancecoinm.py +1 -0
  4. ccxt/abstract/binanceus.py +1 -0
  5. ccxt/abstract/binanceusdm.py +1 -0
  6. ccxt/abstract/bitget.py +3 -0
  7. ccxt/abstract/coinex.py +1 -1
  8. ccxt/abstract/okx.py +3 -0
  9. ccxt/ascendex.py +1 -1
  10. ccxt/async_support/__init__.py +1 -1
  11. ccxt/async_support/ascendex.py +1 -1
  12. ccxt/async_support/base/exchange.py +3 -1
  13. ccxt/async_support/binance.py +8 -2
  14. ccxt/async_support/bingx.py +1 -1
  15. ccxt/async_support/bitget.py +4 -1
  16. ccxt/async_support/bitmex.py +1 -0
  17. ccxt/async_support/bybit.py +35 -9
  18. ccxt/async_support/coinex.py +177 -200
  19. ccxt/async_support/delta.py +1 -1
  20. ccxt/async_support/digifinex.py +1 -1
  21. ccxt/async_support/exmo.py +1 -1
  22. ccxt/async_support/gate.py +1 -1
  23. ccxt/async_support/hitbtc.py +1 -1
  24. ccxt/async_support/hyperliquid.py +25 -3
  25. ccxt/async_support/okx.py +4 -1
  26. ccxt/async_support/phemex.py +15 -7
  27. ccxt/base/exchange.py +4 -2
  28. ccxt/binance.py +8 -2
  29. ccxt/bingx.py +1 -1
  30. ccxt/bitget.py +4 -1
  31. ccxt/bitmex.py +1 -0
  32. ccxt/bybit.py +35 -9
  33. ccxt/coinex.py +177 -200
  34. ccxt/delta.py +1 -1
  35. ccxt/digifinex.py +1 -1
  36. ccxt/exmo.py +1 -1
  37. ccxt/gate.py +1 -1
  38. ccxt/hitbtc.py +1 -1
  39. ccxt/hyperliquid.py +25 -3
  40. ccxt/okx.py +4 -1
  41. ccxt/phemex.py +15 -7
  42. ccxt/pro/__init__.py +1 -1
  43. ccxt/pro/htx.py +12 -6
  44. ccxt/pro/kucoinfutures.py +89 -1
  45. ccxt/pro/woo.py +46 -22
  46. {ccxt-4.3.19.dist-info → ccxt-4.3.21.dist-info}/METADATA +4 -4
  47. {ccxt-4.3.19.dist-info → ccxt-4.3.21.dist-info}/RECORD +49 -49
  48. {ccxt-4.3.19.dist-info → ccxt-4.3.21.dist-info}/WHEEL +0 -0
  49. {ccxt-4.3.19.dist-info → ccxt-4.3.21.dist-info}/top_level.txt +0 -0
@@ -2347,12 +2347,14 @@ class phemex(Exchange, ImplicitAPI):
2347
2347
  """
2348
2348
  create a trade order
2349
2349
  :see: https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#place-order
2350
+ :see: https://phemex-docs.github.io/#place-order-http-put-prefered-3
2350
2351
  :param str symbol: unified symbol of the market to create an order in
2351
2352
  :param str type: 'market' or 'limit'
2352
2353
  :param str side: 'buy' or 'sell'
2353
2354
  :param float amount: how much of currency you want to trade in units of base currency
2354
2355
  :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2355
2356
  :param dict [params]: extra parameters specific to the exchange API endpoint
2357
+ :param float [params.trigger]: trigger price for conditional orders
2356
2358
  :param dict [params.takeProfit]: *swap only* *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only)
2357
2359
  :param float [params.takeProfit.triggerPrice]: take profit trigger price
2358
2360
  :param dict [params.stopLoss]: *swap only* *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only)
@@ -2363,7 +2365,7 @@ class phemex(Exchange, ImplicitAPI):
2363
2365
  market = self.market(symbol)
2364
2366
  requestSide = self.capitalize(side)
2365
2367
  type = self.capitalize(type)
2366
- reduceOnly = self.safe_value(params, 'reduceOnly')
2368
+ reduceOnly = self.safe_bool(params, 'reduceOnly')
2367
2369
  request = {
2368
2370
  # common
2369
2371
  'symbol': market['id'],
@@ -2404,18 +2406,24 @@ class phemex(Exchange, ImplicitAPI):
2404
2406
  else:
2405
2407
  request['clOrdID'] = clientOrderId
2406
2408
  params = self.omit(params, ['clOrdID', 'clientOrderId'])
2407
- stopPrice = self.safe_string_n(params, ['stopPx', 'stopPrice', 'triggerPrice'])
2408
- if stopPrice is not None:
2409
+ triggerPrice = self.safe_string_n(params, ['stopPx', 'stopPrice', 'triggerPrice'])
2410
+ if triggerPrice is not None:
2409
2411
  if market['settle'] == 'USDT':
2410
- request['stopPxRp'] = self.price_to_precision(symbol, stopPrice)
2412
+ request['stopPxRp'] = self.price_to_precision(symbol, triggerPrice)
2411
2413
  else:
2412
- request['stopPxEp'] = self.to_ep(stopPrice, market)
2414
+ request['stopPxEp'] = self.to_ep(triggerPrice, market)
2413
2415
  params = self.omit(params, ['stopPx', 'stopPrice', 'stopLoss', 'takeProfit', 'triggerPrice'])
2414
2416
  if market['spot']:
2415
2417
  qtyType = self.safe_value(params, 'qtyType', 'ByBase')
2416
2418
  if (type == 'Market') or (type == 'Stop') or (type == 'MarketIfTouched'):
2417
2419
  if price is not None:
2418
2420
  qtyType = 'ByQuote'
2421
+ if triggerPrice is not None:
2422
+ if type == 'Limit':
2423
+ request['ordType'] = 'StopLimit'
2424
+ elif type == 'Market':
2425
+ request['ordType'] = 'Stop'
2426
+ request['trigger'] = 'ByLastPrice'
2419
2427
  request['qtyType'] = qtyType
2420
2428
  if qtyType == 'ByQuote':
2421
2429
  cost = self.safe_number(params, 'cost')
@@ -2446,7 +2454,7 @@ class phemex(Exchange, ImplicitAPI):
2446
2454
  request['orderQtyRq'] = amount
2447
2455
  else:
2448
2456
  request['orderQty'] = self.parse_to_int(amount)
2449
- if stopPrice is not None:
2457
+ if triggerPrice is not None:
2450
2458
  triggerType = self.safe_string(params, 'triggerType', 'ByMarkPrice')
2451
2459
  request['triggerType'] = triggerType
2452
2460
  if stopLossDefined or takeProfitDefined:
@@ -3782,7 +3790,7 @@ class phemex(Exchange, ImplicitAPI):
3782
3790
  }
3783
3791
  return self.safe_string(statuses, status, status)
3784
3792
 
3785
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
3793
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
3786
3794
  #
3787
3795
  # {
3788
3796
  # "code": 0,
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.3.19'
7
+ __version__ = '4.3.21'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -5559,6 +5559,8 @@ class Exchange(object):
5559
5559
  response = None
5560
5560
  if method == 'fetchAccounts':
5561
5561
  response = getattr(self, method)(params)
5562
+ elif method == 'getLeverageTiersPaginated':
5563
+ response = getattr(self, method)(symbol, params)
5562
5564
  else:
5563
5565
  response = getattr(self, method)(symbol, since, maxEntriesPerRequest, params)
5564
5566
  errors = 0
@@ -5852,7 +5854,7 @@ class Exchange(object):
5852
5854
  """
5853
5855
  raise NotSupported(self.id + ' fetchPositionsHistory() is not supported yet')
5854
5856
 
5855
- def parse_margin_modification(self, data, market: Market = None):
5857
+ def parse_margin_modification(self, data: dict, market: Market = None):
5856
5858
  raise NotSupported(self.id + ' parseMarginModification() is not supported yet')
5857
5859
 
5858
5860
  def parse_margin_modifications(self, response: List[object], symbols: List[str] = None, symbolKey: Str = None, marketType: MarketType = None):
ccxt/binance.py CHANGED
@@ -153,7 +153,7 @@ class binance(Exchange, ImplicitAPI):
153
153
  'fetchPositions': True,
154
154
  'fetchPositionsHistory': False,
155
155
  'fetchPositionsRisk': True,
156
- 'fetchPremiumIndexOHLCV': False,
156
+ 'fetchPremiumIndexOHLCV': True,
157
157
  'fetchSettlementHistory': True,
158
158
  'fetchStatus': True,
159
159
  'fetchTicker': True,
@@ -802,6 +802,7 @@ class binance(Exchange, ImplicitAPI):
802
802
  'continuousKlines': {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]},
803
803
  'markPriceKlines': {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]},
804
804
  'indexPriceKlines': {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]},
805
+ 'premiumIndexKlines': {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]},
805
806
  'fundingRate': 1,
806
807
  'fundingInfo': 1,
807
808
  'premiumIndex': 1,
@@ -4155,6 +4156,11 @@ class binance(Exchange, ImplicitAPI):
4155
4156
  response = self.dapiPublicGetIndexPriceKlines(self.extend(request, params))
4156
4157
  else:
4157
4158
  response = self.fapiPublicGetIndexPriceKlines(self.extend(request, params))
4159
+ elif price == 'premiumIndex':
4160
+ if market['inverse']:
4161
+ response = self.dapiPublicGetPremiumIndexKlines(self.extend(request, params))
4162
+ else:
4163
+ response = self.fapiPublicGetPremiumIndexKlines(self.extend(request, params))
4158
4164
  elif market['linear']:
4159
4165
  response = self.fapiPublicGetKlines(self.extend(request, params))
4160
4166
  elif market['inverse']:
@@ -10356,7 +10362,7 @@ class binance(Exchange, ImplicitAPI):
10356
10362
  'code': code,
10357
10363
  })
10358
10364
 
10359
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
10365
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
10360
10366
  #
10361
10367
  # add/reduce margin
10362
10368
  #
ccxt/bingx.py CHANGED
@@ -3436,7 +3436,7 @@ class bingx(Exchange, ImplicitAPI):
3436
3436
  #
3437
3437
  return self.parse_margin_modification(response, market)
3438
3438
 
3439
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
3439
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
3440
3440
  #
3441
3441
  # {
3442
3442
  # "code": 0,
ccxt/bitget.py CHANGED
@@ -331,6 +331,9 @@ class bitget(Exchange, ImplicitAPI):
331
331
  'v2/spot/account/subaccount-assets': 2,
332
332
  'v2/spot/account/bills': 2,
333
333
  'v2/spot/account/transferRecords': 1,
334
+ 'v2/account/funding-assets': 2,
335
+ 'v2/account/bot-assets': 2,
336
+ 'v2/account/all-account-balance': 20,
334
337
  'v2/spot/wallet/deposit-address': 2,
335
338
  'v2/spot/wallet/deposit-records': 2,
336
339
  'v2/spot/wallet/withdrawal-records': 2,
@@ -6475,7 +6478,7 @@ class bitget(Exchange, ImplicitAPI):
6475
6478
  'type': type,
6476
6479
  })
6477
6480
 
6478
- def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
6481
+ def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
6479
6482
  #
6480
6483
  # addMargin/reduceMargin
6481
6484
  #
ccxt/bitmex.py CHANGED
@@ -253,6 +253,7 @@ class bitmex(Exchange, ImplicitAPI):
253
253
  'orderQty is invalid': InvalidOrder,
254
254
  'Invalid price': InvalidOrder,
255
255
  'Invalid stopPx for ordType': InvalidOrder,
256
+ 'Account is restricted': PermissionDenied, # {"error":{"message":"Account is restricted","name":"HTTPError"}}
256
257
  },
257
258
  'broad': {
258
259
  'Signature not valid': AuthenticationError,
ccxt/bybit.py CHANGED
@@ -7581,6 +7581,33 @@ class bybit(Exchange, ImplicitAPI):
7581
7581
  'datetime': self.iso8601(timestamp),
7582
7582
  })
7583
7583
 
7584
+ def get_leverage_tiers_paginated(self, symbol: Str = None, params={}):
7585
+ self.load_markets()
7586
+ market = None
7587
+ if symbol is not None:
7588
+ market = self.market(symbol)
7589
+ paginate = False
7590
+ paginate, params = self.handle_option_and_params(params, 'getLeverageTiersPaginated', 'paginate')
7591
+ if paginate:
7592
+ return self.fetch_paginated_call_cursor('getLeverageTiersPaginated', symbol, None, None, params, 'nextPageCursor', 'cursor', None, 100)
7593
+ subType = None
7594
+ subType, params = self.handle_sub_type_and_params('getLeverageTiersPaginated', market, params, 'linear')
7595
+ request = {
7596
+ 'category': subType,
7597
+ }
7598
+ response = self.publicGetV5MarketRiskLimit(self.extend(request, params))
7599
+ result = self.add_pagination_cursor_to_result(response)
7600
+ first = self.safe_dict(result, 0)
7601
+ total = len(result)
7602
+ lastIndex = total - 1
7603
+ last = self.safe_dict(result, lastIndex)
7604
+ cursorValue = self.safe_string(first, 'nextPageCursor')
7605
+ last['info'] = {
7606
+ 'nextPageCursor': cursorValue,
7607
+ }
7608
+ result[lastIndex] = last
7609
+ return result
7610
+
7584
7611
  def fetch_leverage_tiers(self, symbols: Strings = None, params={}):
7585
7612
  """
7586
7613
  :see: https://bybit-exchange.github.io/docs/v5/market/risk-limit
@@ -7588,22 +7615,18 @@ class bybit(Exchange, ImplicitAPI):
7588
7615
  :param str[] [symbols]: a list of unified market symbols
7589
7616
  :param dict [params]: extra parameters specific to the exchange API endpoint
7590
7617
  :param str [params.subType]: market subType, ['linear', 'inverse'], default is 'linear'
7618
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
7591
7619
  :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
7592
7620
  """
7593
7621
  self.load_markets()
7594
7622
  market = None
7623
+ symbol = None
7595
7624
  if symbols is not None:
7596
7625
  market = self.market(symbols[0])
7597
7626
  if market['spot']:
7598
7627
  raise NotSupported(self.id + ' fetchLeverageTiers() is not supported for spot market')
7599
- subType = None
7600
- subType, params = self.handle_sub_type_and_params('fetchTickers', market, params, 'linear')
7601
- request = {
7602
- 'category': subType,
7603
- }
7604
- response = self.publicGetV5MarketRiskLimit(self.extend(request, params))
7605
- result = self.safe_dict(response, 'result', {})
7606
- data = self.safe_list(result, 'list', [])
7628
+ symbol = market['symbol']
7629
+ data = self.get_leverage_tiers_paginated(symbol, self.extend({'paginate': True, 'paginationCalls': 20}, params))
7607
7630
  symbols = self.market_symbols(symbols)
7608
7631
  return self.parse_leverage_tiers(data, symbols, 'symbol')
7609
7632
 
@@ -7629,9 +7652,12 @@ class bybit(Exchange, ImplicitAPI):
7629
7652
  for i in range(0, len(keys)):
7630
7653
  marketId = keys[i]
7631
7654
  entry = grouped[marketId]
7655
+ for j in range(0, len(entry)):
7656
+ id = self.safe_integer(entry[j], 'id')
7657
+ entry[j]['id'] = id
7632
7658
  market = self.safe_market(marketId, None, None, 'contract')
7633
7659
  symbol = market['symbol']
7634
- tiers[symbol] = self.parse_market_leverage_tiers(entry, market)
7660
+ tiers[symbol] = self.parse_market_leverage_tiers(self.sort_by(entry, 'id'), market)
7635
7661
  return tiers
7636
7662
 
7637
7663
  def parse_market_leverage_tiers(self, info, market: Market = None):