ccxt 4.2.77__py2.py3-none-any.whl → 4.2.79__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 (51) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bingx.py +1 -0
  3. ccxt/abstract/gate.py +1 -0
  4. ccxt/abstract/gateio.py +1 -0
  5. ccxt/async_support/__init__.py +1 -1
  6. ccxt/async_support/base/exchange.py +1 -1
  7. ccxt/async_support/base/ws/functions.py +1 -1
  8. ccxt/async_support/bingx.py +37 -5
  9. ccxt/async_support/bitstamp.py +20 -26
  10. ccxt/async_support/bybit.py +97 -2
  11. ccxt/async_support/coinbase.py +20 -9
  12. ccxt/async_support/coinbaseinternational.py +2 -2
  13. ccxt/async_support/gate.py +4 -1
  14. ccxt/async_support/htx.py +34 -27
  15. ccxt/async_support/hyperliquid.py +6 -4
  16. ccxt/async_support/kucoin.py +52 -0
  17. ccxt/async_support/okcoin.py +27 -1
  18. ccxt/async_support/okx.py +18 -0
  19. ccxt/async_support/woo.py +43 -3
  20. ccxt/base/exchange.py +5 -5
  21. ccxt/bingx.py +37 -5
  22. ccxt/bitstamp.py +20 -26
  23. ccxt/bybit.py +97 -2
  24. ccxt/coinbase.py +20 -9
  25. ccxt/coinbaseinternational.py +2 -2
  26. ccxt/gate.py +4 -1
  27. ccxt/htx.py +34 -27
  28. ccxt/hyperliquid.py +6 -4
  29. ccxt/kucoin.py +52 -0
  30. ccxt/okcoin.py +27 -1
  31. ccxt/okx.py +18 -0
  32. ccxt/pro/__init__.py +1 -1
  33. ccxt/pro/alpaca.py +1 -1
  34. ccxt/pro/bitfinex2.py +1 -1
  35. ccxt/pro/bitget.py +1 -1
  36. ccxt/pro/bitmart.py +1 -1
  37. ccxt/pro/bitmex.py +1 -1
  38. ccxt/pro/blockchaincom.py +1 -1
  39. ccxt/pro/bybit.py +14 -1
  40. ccxt/pro/cex.py +9 -5
  41. ccxt/pro/cryptocom.py +1 -1
  42. ccxt/pro/hitbtc.py +1 -1
  43. ccxt/pro/htx.py +1 -1
  44. ccxt/pro/okcoin.py +1 -1
  45. ccxt/pro/onetrading.py +1 -1
  46. ccxt/pro/woo.py +30 -0
  47. ccxt/woo.py +43 -3
  48. {ccxt-4.2.77.dist-info → ccxt-4.2.79.dist-info}/METADATA +6 -6
  49. {ccxt-4.2.77.dist-info → ccxt-4.2.79.dist-info}/RECORD +51 -51
  50. {ccxt-4.2.77.dist-info → ccxt-4.2.79.dist-info}/WHEEL +0 -0
  51. {ccxt-4.2.77.dist-info → ccxt-4.2.79.dist-info}/top_level.txt +0 -0
ccxt/gate.py CHANGED
@@ -67,6 +67,7 @@ class gate(Exchange, ImplicitAPI):
67
67
  'rebate': 'https://api.gateio.ws/api/v4',
68
68
  'earn': 'https://api.gateio.ws/api/v4',
69
69
  'account': 'https://api.gateio.ws/api/v4',
70
+ 'loan': 'https://api.gateio.ws/api/v4',
70
71
  },
71
72
  },
72
73
  'test': {
@@ -327,6 +328,7 @@ class gate(Exchange, ImplicitAPI):
327
328
  'loan_records': 20 / 15,
328
329
  'interest_records': 20 / 15,
329
330
  'estimate_rate': 20 / 15,
331
+ 'currency_discount_tiers': 20 / 15,
330
332
  },
331
333
  'post': {
332
334
  'account_mode': 20 / 15,
@@ -3957,7 +3959,8 @@ class gate(Exchange, ImplicitAPI):
3957
3959
  'account': account,
3958
3960
  }
3959
3961
  if amount is not None:
3960
- request['amount'] = self.amount_to_precision(symbol, amount)
3962
+ amountKey = 'amount' if (market['spot']) else 'size'
3963
+ request[amountKey] = self.amount_to_precision(symbol, amount)
3961
3964
  if price is not None:
3962
3965
  request['price'] = self.price_to_precision(symbol, price)
3963
3966
  response = None
ccxt/htx.py CHANGED
@@ -2848,63 +2848,68 @@ class htx(Exchange, ImplicitAPI):
2848
2848
  # 'from': int((since / str(1000))), spot only
2849
2849
  # 'to': self.seconds(), spot only
2850
2850
  }
2851
- price = self.safe_string(params, 'price')
2852
- params = self.omit(params, 'price')
2851
+ priceType = self.safe_string_n(params, ['priceType', 'price'])
2852
+ params = self.omit(params, ['priceType', 'price'])
2853
+ until = None
2854
+ until, params = self.handle_param_integer(params, 'until')
2855
+ untilSeconds = self.parse_to_int(until / 1000) if (until is not None) else None
2853
2856
  if market['contract']:
2854
2857
  if limit is not None:
2855
- request['size'] = limit # when using limit from and to are ignored
2858
+ request['size'] = limit # when using limit: from & to are ignored
2856
2859
  # https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
2857
2860
  else:
2858
2861
  limit = 2000 # only used for from/to calculation
2859
- if price is None:
2862
+ if priceType is None:
2860
2863
  duration = self.parse_timeframe(timeframe)
2864
+ calcualtedEnd = None
2861
2865
  if since is None:
2862
2866
  now = self.seconds()
2863
2867
  request['from'] = now - duration * (limit - 1)
2864
- request['to'] = now
2868
+ calcualtedEnd = now
2865
2869
  else:
2866
2870
  start = self.parse_to_int(since / 1000)
2867
2871
  request['from'] = start
2868
- request['to'] = self.sum(start, duration * (limit - 1))
2872
+ calcualtedEnd = self.sum(start, duration * (limit - 1))
2873
+ request['to'] = untilSeconds if (untilSeconds is not None) else calcualtedEnd
2869
2874
  response = None
2870
2875
  if market['future']:
2871
2876
  if market['inverse']:
2872
2877
  request['symbol'] = market['id']
2873
- if price == 'mark':
2878
+ if priceType == 'mark':
2874
2879
  response = self.contractPublicGetIndexMarketHistoryMarkPriceKline(self.extend(request, params))
2875
- elif price == 'index':
2880
+ elif priceType == 'index':
2876
2881
  response = self.contractPublicGetIndexMarketHistoryIndex(self.extend(request, params))
2877
- elif price == 'premiumIndex':
2878
- raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data')
2882
+ elif priceType == 'premiumIndex':
2883
+ raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data')
2879
2884
  else:
2880
2885
  response = self.contractPublicGetMarketHistoryKline(self.extend(request, params))
2881
2886
  elif market['linear']:
2882
2887
  request['contract_code'] = market['id']
2883
- if price == 'mark':
2888
+ if priceType == 'mark':
2884
2889
  response = self.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(self.extend(request, params))
2885
- elif price == 'index':
2886
- raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data')
2887
- elif price == 'premiumIndex':
2890
+ elif priceType == 'index':
2891
+ raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data')
2892
+ elif priceType == 'premiumIndex':
2888
2893
  response = self.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(self.extend(request, params))
2889
2894
  else:
2890
2895
  response = self.contractPublicGetLinearSwapExMarketHistoryKline(self.extend(request, params))
2891
2896
  elif market['swap']:
2892
2897
  request['contract_code'] = market['id']
2893
2898
  if market['inverse']:
2894
- if price == 'mark':
2899
+ if priceType == 'mark':
2895
2900
  response = self.contractPublicGetIndexMarketHistorySwapMarkPriceKline(self.extend(request, params))
2896
- elif price == 'index':
2897
- raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data')
2898
- elif price == 'premiumIndex':
2901
+ elif priceType == 'index':
2902
+ raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data')
2903
+ elif priceType == 'premiumIndex':
2899
2904
  response = self.contractPublicGetIndexMarketHistorySwapPremiumIndexKline(self.extend(request, params))
2900
2905
  else:
2901
2906
  response = self.contractPublicGetSwapExMarketHistoryKline(self.extend(request, params))
2902
2907
  elif market['linear']:
2903
- if price == 'mark':
2908
+ if priceType == 'mark':
2904
2909
  response = self.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(self.extend(request, params))
2905
- elif price == 'index':
2906
- raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data')
2907
- elif price == 'premiumIndex':
2910
+ elif priceType == 'index':
2911
+ raise BadRequest(self.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data')
2912
+ elif priceType == 'premiumIndex':
2908
2913
  response = self.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(self.extend(request, params))
2909
2914
  else:
2910
2915
  response = self.contractPublicGetLinearSwapExMarketHistoryKline(self.extend(request, params))
@@ -2913,15 +2918,17 @@ class htx(Exchange, ImplicitAPI):
2913
2918
  useHistorical = None
2914
2919
  useHistorical, params = self.handle_option_and_params(params, 'fetchOHLCV', 'useHistoricalEndpointForSpot', True)
2915
2920
  if not useHistorical:
2916
- # `limit` only available for the self endpoint
2917
2921
  if limit is not None:
2918
- request['size'] = limit # max 2000
2922
+ request['size'] = min(2000, limit) # max 2000
2919
2923
  response = self.spotPublicGetMarketHistoryKline(self.extend(request, params))
2920
2924
  else:
2921
- # `since` only available for the self endpoint
2925
+ # "from & to" only available for the self endpoint
2922
2926
  if since is not None:
2923
- # default 150 bars
2924
2927
  request['from'] = self.parse_to_int(since / 1000)
2928
+ if untilSeconds is not None:
2929
+ request['to'] = untilSeconds
2930
+ if limit is not None:
2931
+ request['size'] = min(1000, limit) # max 1000, otherwise default returns 150
2925
2932
  response = self.spotPublicGetMarketHistoryCandles(self.extend(request, params))
2926
2933
  #
2927
2934
  # {
@@ -2935,7 +2942,7 @@ class htx(Exchange, ImplicitAPI):
2935
2942
  # ]
2936
2943
  # }
2937
2944
  #
2938
- data = self.safe_value(response, 'data', [])
2945
+ data = self.safe_list(response, 'data', [])
2939
2946
  return self.parse_ohlcvs(data, market, timeframe, since, limit)
2940
2947
 
2941
2948
  def fetch_accounts(self, params={}) -> List[Account]:
ccxt/hyperliquid.py CHANGED
@@ -747,8 +747,9 @@ class hyperliquid(Exchange, ImplicitAPI):
747
747
  :param bool [params.postOnly]: True or False whether the order is post-only
748
748
  :param bool [params.reduceOnly]: True or False whether the order is reduce-only
749
749
  :param float [params.triggerPrice]: The price at which a trigger order is triggered at
750
- :param str [params.clientOrderId]: client order id, optional 128 bit hex string
750
+ :param str [params.clientOrderId]: client order id,(optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
751
751
  :param str [params.slippage]: the slippage for market order
752
+ :param str [params.vaultAddress]: the vault address for order
752
753
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
753
754
  """
754
755
  self.load_markets()
@@ -791,7 +792,7 @@ class hyperliquid(Exchange, ImplicitAPI):
791
792
  clientOrderId = self.safe_string_2(orderParams, 'clientOrderId', 'client_id')
792
793
  if clientOrderId is None:
793
794
  raise ArgumentsRequired(self.id + ' createOrders() all orders must have clientOrderId if at least one has a clientOrderId')
794
- params = self.omit(params, ['slippage', 'clientOrderId', 'client_id', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice'])
795
+ params = self.omit(params, ['slippage', 'clientOrderId', 'client_id', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce'])
795
796
  nonce = self.milliseconds()
796
797
  orderReq = []
797
798
  for i in range(0, len(orders)):
@@ -905,7 +906,7 @@ class hyperliquid(Exchange, ImplicitAPI):
905
906
  :param str id: order id
906
907
  :param str symbol: unified symbol of the market the order was made in
907
908
  :param dict [params]: extra parameters specific to the exchange API endpoint
908
- :param str [params.clientOrderId]: client order id(default None)
909
+ :param str [params.clientOrderId]: client order id,(optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
909
910
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
910
911
  """
911
912
  return self.cancel_orders([id], symbol, params)
@@ -918,7 +919,7 @@ class hyperliquid(Exchange, ImplicitAPI):
918
919
  :param str[] ids: order ids
919
920
  :param str [symbol]: unified market symbol
920
921
  :param dict [params]: extra parameters specific to the exchange API endpoint
921
- :param string|str[] [params.clientOrderId]: client order ids(default None)
922
+ :param string|str[] [params.clientOrderId]: client order ids,(optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
922
923
  :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
923
924
  """
924
925
  self.check_required_credentials()
@@ -993,6 +994,7 @@ class hyperliquid(Exchange, ImplicitAPI):
993
994
  :param bool [params.reduceOnly]: True or False whether the order is reduce-only
994
995
  :param float [params.triggerPrice]: The price at which a trigger order is triggered at
995
996
  :param str [params.clientOrderId]: client order id,(optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
997
+ :param str [params.vaultAddress]: the vault address for order
996
998
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
997
999
  """
998
1000
  self.check_required_credentials()
ccxt/kucoin.py CHANGED
@@ -464,6 +464,56 @@ class kucoin(Exchange, ImplicitAPI):
464
464
  '130202': ExchangeError, # The system is renewing the loan automatically. Please try again later
465
465
  '130203': InsufficientFunds, # Insufficient account balance
466
466
  '130204': BadRequest, # As the total lending amount for platform leverage reaches the platform's maximum position limit, the system suspends the borrowing function of leverage
467
+ '130301': InsufficientFunds, # Insufficient account balance
468
+ '130302': PermissionDenied, # Your relevant permission rights have been restricted, you can contact customer service for processing
469
+ '130303': NotSupported, # The current trading pair does not support isolated positions
470
+ '130304': NotSupported, # The trading function of the current trading pair is not enabled
471
+ '130305': NotSupported, # The current trading pair does not support cross position
472
+ '130306': NotSupported, # The account has not opened leveraged trading
473
+ '130307': NotSupported, # Please reopen the leverage agreement
474
+ '130308': InvalidOrder, # Position renewal freeze
475
+ '130309': InvalidOrder, # Position forced liquidation freeze
476
+ '130310': ExchangeError, # Abnormal leverage account status
477
+ '130311': InvalidOrder, # Failed to place an order, triggering buy limit
478
+ '130312': InvalidOrder, # Trigger global position limit, suspend buying
479
+ '130313': InvalidOrder, # Trigger global position limit, suspend selling
480
+ '130314': InvalidOrder, # Trigger the global position limit and prompt the remaining quantity available for purchase
481
+ '130315': NotSupported, # This feature has been suspended due to country restrictions
482
+ '126000': ExchangeError, # Abnormal margin trading
483
+ '126001': NotSupported, # Users currently do not support high frequency
484
+ '126002': ExchangeError, # There is a risk problem in your account and transactions are temporarily not allowed!
485
+ '126003': InvalidOrder, # The commission amount is less than the minimum transaction amount for a single commission
486
+ '126004': ExchangeError, # Trading pair does not exist or is prohibited
487
+ '126005': PermissionDenied, # This trading pair requires advanced KYC certification before trading
488
+ '126006': ExchangeError, # Trading pair is not available
489
+ '126007': ExchangeError, # Trading pair suspended
490
+ '126009': ExchangeError, # Trading pair is suspended from creating orders
491
+ '126010': ExchangeError, # Trading pair suspended order cancellation
492
+ '126011': ExchangeError, # There are too many orders in the order
493
+ '126013': InsufficientFunds, # Insufficient account balance
494
+ '126015': ExchangeError, # It is prohibited to place orders on self trading pair
495
+ '126021': NotSupported, # This digital asset does not support user participation in your region, thank you for your understanding!
496
+ '126022': InvalidOrder, # The final transaction price of your order will trigger the price protection strategy. To protect the price from deviating too much, please place an order again.
497
+ '126027': InvalidOrder, # Only limit orders are supported
498
+ '126028': InvalidOrder, # Only limit orders are supported before the specified time
499
+ '126029': InvalidOrder, # The maximum order price is: xxx
500
+ '126030': InvalidOrder, # The minimum order price is: xxx
501
+ '126033': InvalidOrder, # Duplicate order
502
+ '126034': InvalidOrder, # Failed to create take profit and stop loss order
503
+ '126036': InvalidOrder, # Failed to create margin order
504
+ '126037': ExchangeError, # Due to country and region restrictions, self function has been suspended!
505
+ '126038': ExchangeError, # Third-party service call failed(internal exception)
506
+ '126039': ExchangeError, # Third-party service call failed, reason: xxx
507
+ '126041': ExchangeError, # clientTimestamp parameter error
508
+ '126042': ExchangeError, # Exceeded maximum position limit
509
+ '126043': OrderNotFound, # Order does not exist
510
+ '126044': InvalidOrder, # clientOid duplicate
511
+ '126045': NotSupported, # This digital asset does not support user participation in your region, thank you for your understanding!
512
+ '126046': NotSupported, # This digital asset does not support your IP region, thank you for your understanding!
513
+ '126047': PermissionDenied, # Please complete identity verification
514
+ '126048': PermissionDenied, # Please complete authentication for the master account
515
+ '135005': ExchangeError, # Margin order query business abnormality
516
+ '135018': ExchangeError, # Margin order query service abnormality
467
517
  '200004': InsufficientFunds,
468
518
  '210014': InvalidOrder, # {"code":"210014","msg":"Exceeds the max. borrowing amount, the remaining amount you can borrow: 0USDT"}
469
519
  '210021': InsufficientFunds, # {"code":"210021","msg":"Balance not enough"}
@@ -485,10 +535,12 @@ class kucoin(Exchange, ImplicitAPI):
485
535
  '400350': InvalidOrder, # {"code":"400350","msg":"Upper limit for holding: 10,000USDT, you can still buy 10,000USDT worth of coin."}
486
536
  '400370': InvalidOrder, # {"code":"400370","msg":"Max. price: 0.02500000000000000000"}
487
537
  '400400': BadRequest, # Parameter error
538
+ '400401': AuthenticationError, # User is not logged in
488
539
  '400500': InvalidOrder, # {"code":"400500","msg":"Your located country/region is currently not supported for the trading of self token"}
489
540
  '400600': BadSymbol, # {"code":"400600","msg":"validation.createOrder.symbolNotAvailable"}
490
541
  '400760': InvalidOrder, # {"code":"400760","msg":"order price should be more than XX"}
491
542
  '401000': BadRequest, # {"code":"401000","msg":"The interface has been deprecated"}
543
+ '408000': BadRequest, # Network timeout, please try again later
492
544
  '411100': AccountSuspended,
493
545
  '415000': BadRequest, # {"code":"415000","msg":"Unsupported Media Type"}
494
546
  '400303': PermissionDenied, # {"msg":"To enjoy the full range of our products and services, we kindly request you complete the identity verification process.","code":"400303"}
ccxt/okcoin.py CHANGED
@@ -266,6 +266,16 @@ class okcoin(Exchange, ImplicitAPI):
266
266
  '50026': ExchangeNotAvailable, # System error, please try again later.
267
267
  '50027': PermissionDenied, # The account is restricted from trading
268
268
  '50028': ExchangeError, # Unable to take the order, please reach out to support center for details
269
+ '50029': ExchangeError, # This instrument({0}) is unavailable at present due to risk management. Please contact customer service for help.
270
+ '50030': PermissionDenied, # No permission to use self API
271
+ '50032': AccountSuspended, # This asset is blocked, allow its trading and try again
272
+ '50033': AccountSuspended, # This instrument is blocked, allow its trading and try again
273
+ '50035': BadRequest, # This endpoint requires that APIKey must be bound to IP
274
+ '50036': BadRequest, # Invalid expTime
275
+ '50037': BadRequest, # Order expired
276
+ '50038': ExchangeError, # This feature is temporarily unavailable in demo trading
277
+ '50039': ExchangeError, # The before parameter is not available for implementing timestamp pagination
278
+ '50041': ExchangeError, # You are not currently on the whitelist, please contact customer service
269
279
  '50044': BadRequest, # Must select one broker type
270
280
  # API Class
271
281
  '50100': ExchangeError, # API frozen, please contact customer service
@@ -309,9 +319,25 @@ class okcoin(Exchange, ImplicitAPI):
309
319
  '51024': AccountSuspended, # Unified accountblocked
310
320
  '51025': ExchangeError, # Order count exceeds the limit
311
321
  '51026': BadSymbol, # Instrument type does not match underlying index
322
+ '51030': InvalidOrder, # Funding fee is being settled.
323
+ '51031': InvalidOrder, # This order price is not within the closing price range
324
+ '51032': InvalidOrder, # Closing all positions at market price.
325
+ '51033': InvalidOrder, # The total amount per order for self pair has reached the upper limit.
326
+ '51037': InvalidOrder, # The current account risk status only supports you to place IOC orders that can reduce the risk of your account.
327
+ '51038': InvalidOrder, # There is already an IOC order under the current risk module that reduces the risk of the account.
328
+ '51044': InvalidOrder, # The order type {0}, {1} is not allowed to set stop loss and take profit
312
329
  '51046': InvalidOrder, # The take profit trigger price must be higher than the order price
313
330
  '51047': InvalidOrder, # The stop loss trigger price must be lower than the order price
314
- '51031': InvalidOrder, # This order price is not within the closing price range
331
+ '51048': InvalidOrder, # The take profit trigger price should be lower than the order price
332
+ '51049': InvalidOrder, # The stop loss trigger price should be higher than the order price
333
+ '51050': InvalidOrder, # The take profit trigger price should be higher than the best ask price
334
+ '51051': InvalidOrder, # The stop loss trigger price should be lower than the best ask price
335
+ '51052': InvalidOrder, # The take profit trigger price should be lower than the best bid price
336
+ '51053': InvalidOrder, # The stop loss trigger price should be higher than the best bid price
337
+ '51054': BadRequest, # Getting information timed out, please try again later
338
+ '51056': InvalidOrder, # Action not allowed
339
+ '51058': InvalidOrder, # No available position for self algo order
340
+ '51059': InvalidOrder, # Strategy for the current state does not support self operation
315
341
  '51100': InvalidOrder, # Trading amount does not meet the min tradable amount
316
342
  '51102': InvalidOrder, # Entered amount exceeds the max pending count
317
343
  '51103': InvalidOrder, # Entered amount exceeds the max pending order count of the underlying asset
ccxt/okx.py CHANGED
@@ -595,6 +595,7 @@ class okx(Exchange, ImplicitAPI):
595
595
  '50027': PermissionDenied, # The account is restricted from trading
596
596
  '50028': ExchangeError, # Unable to take the order, please reach out to support center for details
597
597
  '50044': BadRequest, # Must select one broker type
598
+ '50061': ExchangeError, # You've reached the maximum order rate limit for self account.
598
599
  '50062': ExchangeError, # This feature is currently unavailable.
599
600
  # API Class
600
601
  '50100': ExchangeError, # API frozen, please contact customer service
@@ -782,6 +783,15 @@ class okx(Exchange, ImplicitAPI):
782
783
  # SPOT/MARGIN error codes 54000-54999
783
784
  '54000': ExchangeError, # Margin transactions unavailable
784
785
  '54001': ExchangeError, # Only Multi-currency margin account can be set to borrow coins automatically
786
+ # Trading bot Error Code from 55100 to 55999
787
+ '55100': InvalidOrder, # Take profit % should be within the range of {parameter1}-{parameter2}
788
+ '55101': InvalidOrder, # Stop loss % should be within the range of {parameter1}-{parameter2}
789
+ '55102': InvalidOrder, # Take profit % should be greater than the current bot’s PnL%
790
+ '55103': InvalidOrder, # Stop loss % should be less than the current bot’s PnL%
791
+ '55104': InvalidOrder, # Only futures grid supports take profit or stop loss based on profit percentage
792
+ '55111': InvalidOrder, # This signal name is in use, please try a new name
793
+ '55112': InvalidOrder, # This signal does not exist
794
+ '55113': InvalidOrder, # Create signal strategies with leverage greater than the maximum leverage of the instruments
785
795
  # FUNDING error codes 58000-58999
786
796
  '58000': ExchangeError, # Account type {0} does not supported when getting the sub-account balance
787
797
  '58001': AuthenticationError, # Incorrect trade password
@@ -4699,6 +4709,14 @@ class okx(Exchange, ImplicitAPI):
4699
4709
  '3': 'pending',
4700
4710
  '4': 'pending',
4701
4711
  '5': 'pending',
4712
+ '6': 'pending',
4713
+ '7': 'pending',
4714
+ '8': 'pending',
4715
+ '9': 'pending',
4716
+ '10': 'pending',
4717
+ '12': 'pending',
4718
+ '15': 'pending',
4719
+ '16': 'pending',
4702
4720
  }
4703
4721
  return self.safe_string(statuses, status, status)
4704
4722
 
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.2.77'
7
+ __version__ = '4.2.79'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
ccxt/pro/alpaca.py CHANGED
@@ -562,7 +562,7 @@ class alpaca(ccxt.async_support.alpaca):
562
562
  },
563
563
  }
564
564
  self.watch(url, messageHash, request, messageHash, future)
565
- return future
565
+ return await future
566
566
 
567
567
  def handle_error_message(self, client: Client, message):
568
568
  #
ccxt/pro/bitfinex2.py CHANGED
@@ -812,7 +812,7 @@ class bitfinex2(ccxt.async_support.bitfinex2):
812
812
  }
813
813
  message = self.extend(request, params)
814
814
  self.watch(url, messageHash, message, messageHash)
815
- return future
815
+ return await future
816
816
 
817
817
  def handle_authentication_message(self, client: Client, message):
818
818
  messageHash = 'authenticated'
ccxt/pro/bitget.py CHANGED
@@ -1523,7 +1523,7 @@ class bitget(ccxt.async_support.bitget):
1523
1523
  }
1524
1524
  message = self.extend(request, params)
1525
1525
  self.watch(url, messageHash, message, messageHash)
1526
- return future
1526
+ return await future
1527
1527
 
1528
1528
  async def watch_private(self, messageHash, subscriptionHash, args, params={}):
1529
1529
  await self.authenticate()
ccxt/pro/bitmart.py CHANGED
@@ -1312,7 +1312,7 @@ class bitmart(ccxt.async_support.bitmart):
1312
1312
  }
1313
1313
  message = self.extend(request, params)
1314
1314
  self.watch(url, messageHash, message, messageHash)
1315
- return future
1315
+ return await future
1316
1316
 
1317
1317
  def handle_subscription_status(self, client: Client, message):
1318
1318
  #
ccxt/pro/bitmex.py CHANGED
@@ -599,7 +599,7 @@ class bitmex(ccxt.async_support.bitmex):
599
599
  }
600
600
  message = self.extend(request, params)
601
601
  self.watch(url, messageHash, message, messageHash)
602
- return future
602
+ return await future
603
603
 
604
604
  def handle_authentication_message(self, client: Client, message):
605
605
  authenticated = self.safe_bool(message, 'success', False)
ccxt/pro/blockchaincom.py CHANGED
@@ -735,4 +735,4 @@ class blockchaincom(ccxt.async_support.blockchaincom):
735
735
  'token': self.secret,
736
736
  }
737
737
  return self.watch(url, messageHash, self.extend(request, params), messageHash)
738
- return future
738
+ return await future
ccxt/pro/bybit.py CHANGED
@@ -974,8 +974,21 @@ class bybit(ccxt.async_support.bybit):
974
974
  for i in range(0, len(rawPositions)):
975
975
  rawPosition = rawPositions[i]
976
976
  position = self.parse_position(rawPosition)
977
+ side = self.safe_string(position, 'side')
978
+ # hacky solution to handle closing positions
979
+ # without crashing, we should handle self properly later
977
980
  newPositions.append(position)
978
- cache.append(position)
981
+ if side is None or side == '':
982
+ # closing update, adding both sides to "reset" both sides
983
+ # since we don't know which side is being closed
984
+ position['side'] = 'long'
985
+ cache.append(position)
986
+ position['side'] = 'short'
987
+ cache.append(position)
988
+ position['side'] = None
989
+ else:
990
+ # regular update
991
+ cache.append(position)
979
992
  messageHashes = self.find_message_hashes(client, 'positions::')
980
993
  for i in range(0, len(messageHashes)):
981
994
  messageHash = messageHashes[i]
ccxt/pro/cex.py CHANGED
@@ -157,16 +157,20 @@ class cex(ccxt.async_support.cex):
157
157
  # {
158
158
  # "e": "history",
159
159
  # "data": [
160
- # "sell:1665467367741:3888551:19058.8:14541219",
161
- # "buy:1665467367741:1059339:19071.5:14541218",
160
+ # 'buy:1710255706095:444444:71222.2:14892622'
161
+ # 'sell:1710255658251:42530:71300:14892621'
162
+ # 'buy:1710252424241:87913:72800:14892620'
163
+ # ... timestamp descending
162
164
  # ]
163
165
  # }
164
166
  #
165
- data = self.safe_value(message, 'data', [])
167
+ data = self.safe_list(message, 'data', [])
166
168
  limit = self.safe_integer(self.options, 'tradesLimit', 1000)
167
169
  stored = ArrayCache(limit)
168
- for i in range(0, len(data)):
169
- rawTrade = data[i]
170
+ dataLength = len(data)
171
+ for i in range(0, dataLength):
172
+ index = dataLength - 1 - i
173
+ rawTrade = data[index]
170
174
  parsed = self.parse_ws_old_trade(rawTrade)
171
175
  stored.append(parsed)
172
176
  messageHash = 'trades'
ccxt/pro/cryptocom.py CHANGED
@@ -931,7 +931,7 @@ class cryptocom(ccxt.async_support.cryptocom):
931
931
  }
932
932
  message = self.extend(request, params)
933
933
  self.watch(url, messageHash, message, messageHash)
934
- return future
934
+ return await future
935
935
 
936
936
  def handle_ping(self, client: Client, message):
937
937
  self.spawn(self.pong, client, message)
ccxt/pro/hitbtc.py CHANGED
@@ -119,7 +119,7 @@ class hitbtc(ccxt.async_support.hitbtc):
119
119
  # }
120
120
  # }
121
121
  #
122
- return future
122
+ return await future
123
123
 
124
124
  async def subscribe_public(self, name: str, messageHashPrefix: str, symbols: Strings = None, params={}):
125
125
  """
ccxt/pro/htx.py CHANGED
@@ -2205,4 +2205,4 @@ class htx(ccxt.async_support.htx):
2205
2205
  'params': params,
2206
2206
  }
2207
2207
  self.watch(url, messageHash, request, messageHash, subscription)
2208
- return future
2208
+ return await future
ccxt/pro/okcoin.py CHANGED
@@ -452,7 +452,7 @@ class okcoin(ccxt.async_support.okcoin):
452
452
  ],
453
453
  }
454
454
  self.spawn(self.watch, url, messageHash, request, messageHash, future)
455
- return future
455
+ return await future
456
456
 
457
457
  async def watch_balance(self, params={}) -> Balances:
458
458
  """
ccxt/pro/onetrading.py CHANGED
@@ -1272,4 +1272,4 @@ class onetrading(ccxt.async_support.onetrading):
1272
1272
  'api_token': self.apiKey,
1273
1273
  }
1274
1274
  self.watch(url, messageHash, self.extend(request, params), messageHash)
1275
- return future
1275
+ return await future
ccxt/pro/woo.py CHANGED
@@ -89,6 +89,13 @@ class woo(ccxt.async_support.woo):
89
89
  return await self.watch(url, messageHash, request, messageHash, subscribe)
90
90
 
91
91
  async def watch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
92
+ """
93
+ watches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
94
+ :param str symbol: unified symbol of the market to fetch the order book for
95
+ :param int [limit]: the maximum amount of order book entries to return.
96
+ :param dict [params]: extra parameters specific to the exchange API endpoint
97
+ :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
98
+ """
92
99
  await self.load_markets()
93
100
  name = 'orderbook'
94
101
  market = self.market(symbol)
@@ -137,9 +144,16 @@ class woo(ccxt.async_support.woo):
137
144
  client.resolve(orderbook, topic)
138
145
 
139
146
  async def watch_ticker(self, symbol: str, params={}) -> Ticker:
147
+ """
148
+ watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
149
+ :param str symbol: unified symbol of the market to fetch the ticker for
150
+ :param dict [params]: extra parameters specific to the exchange API endpoint
151
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
152
+ """
140
153
  await self.load_markets()
141
154
  name = 'ticker'
142
155
  market = self.market(symbol)
156
+ symbol = market['symbol']
143
157
  topic = market['id'] + '@' + name
144
158
  request = {
145
159
  'event': 'subscribe',
@@ -214,7 +228,14 @@ class woo(ccxt.async_support.woo):
214
228
  return message
215
229
 
216
230
  async def watch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
231
+ """
232
+ n watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
233
+ :param str[] symbols: unified symbol of the market to fetch the ticker for
234
+ :param dict [params]: extra parameters specific to the exchange API endpoint
235
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
236
+ """
217
237
  await self.load_markets()
238
+ symbols = self.market_symbols(symbols)
218
239
  name = 'tickers'
219
240
  topic = name
220
241
  request = {
@@ -329,8 +350,17 @@ class woo(ccxt.async_support.woo):
329
350
  client.resolve(stored, topic)
330
351
 
331
352
  async def watch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
353
+ """
354
+ watches information on multiple trades made in a market
355
+ :param str symbol: unified market symbol of the market trades were made in
356
+ :param int [since]: the earliest time in ms to fetch trades for
357
+ :param int [limit]: the maximum number of trade structures to retrieve
358
+ :param dict [params]: extra parameters specific to the exchange API endpoint
359
+ :returns dict[]: a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
360
+ """
332
361
  await self.load_markets()
333
362
  market = self.market(symbol)
363
+ symbol = market['symbol']
334
364
  topic = market['id'] + '@trade'
335
365
  request = {
336
366
  'event': 'subscribe',