ccxt 4.3.62__py2.py3-none-any.whl → 4.3.64__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 (74) hide show
  1. ccxt/__init__.py +2 -1
  2. ccxt/abstract/binance.py +5 -5
  3. ccxt/abstract/binancecoinm.py +5 -5
  4. ccxt/abstract/binanceus.py +5 -5
  5. ccxt/abstract/binanceusdm.py +5 -5
  6. ccxt/abstract/cryptocom.py +11 -0
  7. ccxt/abstract/kucoin.py +1 -0
  8. ccxt/abstract/kucoinfutures.py +1 -0
  9. ccxt/abstract/woo.py +3 -0
  10. ccxt/ace.py +33 -15
  11. ccxt/alpaca.py +1 -0
  12. ccxt/async_support/__init__.py +2 -1
  13. ccxt/async_support/ace.py +33 -15
  14. ccxt/async_support/alpaca.py +1 -0
  15. ccxt/async_support/base/exchange.py +4 -4
  16. ccxt/async_support/binance.py +6 -9
  17. ccxt/async_support/bingx.py +534 -152
  18. ccxt/async_support/bitfinex.py +1 -1
  19. ccxt/async_support/bitfinex2.py +1 -1
  20. ccxt/async_support/coinbaseinternational.py +1 -1
  21. ccxt/async_support/cryptocom.py +17 -2
  22. ccxt/async_support/independentreserve.py +103 -1
  23. ccxt/async_support/kucoin.py +2 -0
  24. ccxt/async_support/mercado.py +5 -1
  25. ccxt/async_support/whitebit.py +1 -1
  26. ccxt/async_support/woo.py +321 -81
  27. ccxt/async_support/xt.py +3 -3
  28. ccxt/async_support/yobit.py +1 -1
  29. ccxt/async_support/zonda.py +1 -1
  30. ccxt/base/errors.py +8 -1
  31. ccxt/base/exchange.py +11 -5
  32. ccxt/binance.py +6 -9
  33. ccxt/bingx.py +534 -152
  34. ccxt/bitfinex.py +1 -1
  35. ccxt/bitfinex2.py +1 -1
  36. ccxt/coinbaseinternational.py +1 -1
  37. ccxt/cryptocom.py +17 -2
  38. ccxt/independentreserve.py +103 -1
  39. ccxt/kucoin.py +2 -0
  40. ccxt/mercado.py +5 -1
  41. ccxt/pro/__init__.py +1 -1
  42. ccxt/pro/binance.py +56 -35
  43. ccxt/pro/bitfinex2.py +6 -4
  44. ccxt/pro/bitget.py +5 -2
  45. ccxt/pro/bitmart.py +3 -3
  46. ccxt/pro/bitvavo.py +1 -1
  47. ccxt/pro/bybit.py +41 -18
  48. ccxt/pro/cryptocom.py +7 -2
  49. ccxt/pro/gate.py +7 -4
  50. ccxt/pro/gemini.py +4 -2
  51. ccxt/pro/htx.py +5 -1
  52. ccxt/pro/independentreserve.py +6 -4
  53. ccxt/pro/kraken.py +79 -6
  54. ccxt/pro/okx.py +5 -5
  55. ccxt/pro/onetrading.py +3 -2
  56. ccxt/pro/oxfun.py +1 -1
  57. ccxt/pro/poloniexfutures.py +5 -2
  58. ccxt/pro/vertex.py +3 -2
  59. ccxt/pro/woo.py +2 -1
  60. ccxt/pro/woofipro.py +3 -2
  61. ccxt/test/tests_async.py +3 -3
  62. ccxt/test/tests_helpers.py +1 -1
  63. ccxt/test/tests_init.py +3 -3
  64. ccxt/test/tests_sync.py +3 -3
  65. ccxt/whitebit.py +1 -1
  66. ccxt/woo.py +321 -81
  67. ccxt/xt.py +3 -3
  68. ccxt/yobit.py +1 -1
  69. ccxt/zonda.py +1 -1
  70. {ccxt-4.3.62.dist-info → ccxt-4.3.64.dist-info}/METADATA +4 -4
  71. {ccxt-4.3.62.dist-info → ccxt-4.3.64.dist-info}/RECORD +74 -74
  72. {ccxt-4.3.62.dist-info → ccxt-4.3.64.dist-info}/LICENSE.txt +0 -0
  73. {ccxt-4.3.62.dist-info → ccxt-4.3.64.dist-info}/WHEEL +0 -0
  74. {ccxt-4.3.62.dist-info → ccxt-4.3.64.dist-info}/top_level.txt +0 -0
ccxt/woo.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.woo import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Bool, Conversion, Currencies, Currency, Int, Leverage, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Trade, TradingFees, Transaction, TransferEntry, TransferEntries
9
+ from ccxt.base.types import Account, Balances, Bool, Conversion, Currencies, Currency, Int, Leverage, MarginModification, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Trade, TradingFees, Transaction, TransferEntry, TransferEntries
10
10
  from typing import List
11
11
  from typing import Any
12
12
  from ccxt.base.errors import ExchangeError
@@ -41,7 +41,7 @@ class woo(Exchange, ImplicitAPI):
41
41
  'swap': True,
42
42
  'future': False,
43
43
  'option': False,
44
- 'addMargin': False,
44
+ 'addMargin': True,
45
45
  'cancelAllOrders': True,
46
46
  'cancelAllOrdersAfter': True,
47
47
  'cancelOrder': True,
@@ -211,6 +211,7 @@ class woo(Exchange, ImplicitAPI):
211
211
  'positions': 3.33, # 30 requests per 10 seconds
212
212
  'position/{symbol}': 3.33,
213
213
  'client/transaction_history': 60,
214
+ 'client/futures_leverage': 60,
214
215
  },
215
216
  'post': {
216
217
  'order': 5, # 2 requests per 1 second per symbol
@@ -223,6 +224,8 @@ class woo(Exchange, ImplicitAPI):
223
224
  'client/account_mode': 120,
224
225
  'client/position_mode': 5,
225
226
  'client/leverage': 120,
227
+ 'client/futures_leverage': 30,
228
+ 'client/isolated_margin': 30,
226
229
  },
227
230
  'delete': {
228
231
  'order': 1,
@@ -905,16 +908,18 @@ class woo(Exchange, ImplicitAPI):
905
908
  :param float amount: how much of currency you want to trade in units of base currency
906
909
  :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
907
910
  :param dict [params]: extra parameters specific to the exchange API endpoint
911
+ :param str [params.marginMode]: *for swap markets only* 'cross' or 'isolated', default 'cross'
908
912
  :param float [params.triggerPrice]: The price a trigger order is triggered at
909
913
  :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only)
910
914
  :param float [params.takeProfit.triggerPrice]: take profit trigger price
911
915
  :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only)
912
916
  :param float [params.stopLoss.triggerPrice]: stop loss trigger price
913
- :param float [params.algoType]: 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
917
+ :param float [params.algoType]: 'STOP' or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
914
918
  :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
915
919
  :param str [params.trailingAmount]: the quote amount to trail away from the current market price
916
920
  :param str [params.trailingPercent]: the percent to trail away from the current market price
917
921
  :param str [params.trailingTriggerPrice]: the price to trigger a trailing order, default uses the price argument
922
+ :param str [params.position_side]: 'SHORT' or 'LONG' - if position mode is HEDGE_MODE and the trading involves futures, then is required, otherwise self parameter is not required
918
923
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
919
924
  """
920
925
  reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only')
@@ -927,6 +932,10 @@ class woo(Exchange, ImplicitAPI):
927
932
  'symbol': market['id'],
928
933
  'side': orderSide,
929
934
  }
935
+ marginMode: Str = None
936
+ marginMode, params = self.handle_margin_mode_and_params('createOrder', params)
937
+ if marginMode is not None:
938
+ request['margin_mode'] = self.encode_margin_mode(marginMode)
930
939
  stopPrice = self.safe_number_2(params, 'triggerPrice', 'stopPrice')
931
940
  stopLoss = self.safe_value(params, 'stopLoss')
932
941
  takeProfit = self.safe_value(params, 'takeProfit')
@@ -1063,6 +1072,13 @@ class woo(Exchange, ImplicitAPI):
1063
1072
  order['type'] = type
1064
1073
  return order
1065
1074
 
1075
+ def encode_margin_mode(self, mode):
1076
+ modes = {
1077
+ 'cross': 'CROSS',
1078
+ 'isolated': 'ISOLATED',
1079
+ }
1080
+ return self.safe_string(modes, mode, mode)
1081
+
1066
1082
  def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
1067
1083
  """
1068
1084
  edit a trade order
@@ -2465,7 +2481,21 @@ class woo(Exchange, ImplicitAPI):
2465
2481
  }
2466
2482
 
2467
2483
  def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2484
+ """
2485
+ fetch the history of funding payments paid and received on self account
2486
+ :see: https://docs.woo.org/#get-funding-fee-history
2487
+ :param str [symbol]: unified market symbol
2488
+ :param int [since]: the earliest time in ms to fetch funding history for
2489
+ :param int [limit]: the maximum number of funding history structures to retrieve
2490
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2491
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2492
+ :returns dict: a `funding history structure <https://docs.ccxt.com/#/?id=funding-history-structure>`
2493
+ """
2468
2494
  self.load_markets()
2495
+ paginate = False
2496
+ paginate, params = self.handle_option_and_params(params, 'fetchFundingHistory', 'paginate')
2497
+ if paginate:
2498
+ return self.fetch_paginated_call_cursor('fetchFundingHistory', symbol, since, limit, params, 'page', 'page', 1, 500)
2469
2499
  request: dict = {}
2470
2500
  market: Market = None
2471
2501
  if symbol is not None:
@@ -2473,6 +2503,10 @@ class woo(Exchange, ImplicitAPI):
2473
2503
  request['symbol'] = market['id']
2474
2504
  if since is not None:
2475
2505
  request['start_t'] = since
2506
+ if limit is not None:
2507
+ request['size'] = limit
2508
+ else:
2509
+ request['size'] = 5000
2476
2510
  response = self.v1PrivateGetFundingFeeHistory(self.extend(request, params))
2477
2511
  #
2478
2512
  # {
@@ -2497,7 +2531,14 @@ class woo(Exchange, ImplicitAPI):
2497
2531
  # "success":true
2498
2532
  # }
2499
2533
  #
2534
+ meta = self.safe_dict(response, 'meta', {})
2535
+ cursor = self.safe_integer(meta, 'current_page')
2500
2536
  result = self.safe_list(response, 'rows', [])
2537
+ resultLength = len(result)
2538
+ if resultLength > 0:
2539
+ lastItem = result[resultLength - 1]
2540
+ lastItem['page'] = cursor
2541
+ result[resultLength - 1] = lastItem
2501
2542
  return self.parse_incomes(result, market, since, limit)
2502
2543
 
2503
2544
  def parse_funding_rate(self, fundingRate, market: Market = None):
@@ -2676,60 +2717,187 @@ class woo(Exchange, ImplicitAPI):
2676
2717
  :see: https://docs.woo.org/#get-account-information-new
2677
2718
  :param str symbol: unified market symbol
2678
2719
  :param dict [params]: extra parameters specific to the exchange API endpoint
2720
+ :param str [params.marginMode]: *for swap markets only* 'cross' or 'isolated'
2721
+ :param str [params.position_mode]: *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE'
2679
2722
  :returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
2680
2723
  """
2681
2724
  self.load_markets()
2682
2725
  market = self.market(symbol)
2683
- response = self.v3PrivateGetAccountinfo(params)
2684
- #
2685
- # {
2686
- # "success": True,
2687
- # "data": {
2688
- # "applicationId": "dsa",
2689
- # "account": "dsa",
2690
- # "alias": "haha",
2691
- # "accountMode": "MARGIN",
2692
- # "leverage": 1,
2693
- # "takerFeeRate": 1,
2694
- # "makerFeeRate": 1,
2695
- # "interestRate": 1,
2696
- # "futuresTakerFeeRate": 1,
2697
- # "futuresMakerFeeRate": 1,
2698
- # "otpauth": True,
2699
- # "marginRatio": 1,
2700
- # "openMarginRatio": 1,
2701
- # "initialMarginRatio": 1,
2702
- # "maintenanceMarginRatio": 1,
2703
- # "totalCollateral": 1,
2704
- # "freeCollateral": 1,
2705
- # "totalAccountValue": 1,
2706
- # "totalVaultValue": 1,
2707
- # "totalStakingValue": 1
2708
- # },
2709
- # "timestamp": 1673323685109
2710
- # }
2711
- #
2726
+ response: dict = None
2727
+ if market['spot']:
2728
+ response = self.v3PrivateGetAccountinfo(params)
2729
+ #
2730
+ # {
2731
+ # "success": True,
2732
+ # "data": {
2733
+ # "applicationId": "dsa",
2734
+ # "account": "dsa",
2735
+ # "alias": "haha",
2736
+ # "accountMode": "MARGIN",
2737
+ # "leverage": 1,
2738
+ # "takerFeeRate": 1,
2739
+ # "makerFeeRate": 1,
2740
+ # "interestRate": 1,
2741
+ # "futuresTakerFeeRate": 1,
2742
+ # "futuresMakerFeeRate": 1,
2743
+ # "otpauth": True,
2744
+ # "marginRatio": 1,
2745
+ # "openMarginRatio": 1,
2746
+ # "initialMarginRatio": 1,
2747
+ # "maintenanceMarginRatio": 1,
2748
+ # "totalCollateral": 1,
2749
+ # "freeCollateral": 1,
2750
+ # "totalAccountValue": 1,
2751
+ # "totalVaultValue": 1,
2752
+ # "totalStakingValue": 1
2753
+ # },
2754
+ # "timestamp": 1673323685109
2755
+ # }
2756
+ #
2757
+ elif market['swap']:
2758
+ request: dict = {
2759
+ 'symbol': market['id'],
2760
+ }
2761
+ marginMode: Str = None
2762
+ marginMode, params = self.handle_margin_mode_and_params('fetchLeverage', params, 'cross')
2763
+ request['margin_mode'] = self.encode_margin_mode(marginMode)
2764
+ response = self.v1PrivateGetClientFuturesLeverage(self.extend(request, params))
2765
+ #
2766
+ # HEDGE_MODE
2767
+ # {
2768
+ # "success": True,
2769
+ # "data":
2770
+ # {
2771
+ # "symbol": "PERP_ETH_USDT",
2772
+ # "default_margin_mode": "CROSS",
2773
+ # "position_mode": "HEDGE_MODE",
2774
+ # "details": [
2775
+ # {
2776
+ # "position_side": "LONG",
2777
+ # "leverage": 10
2778
+ # },
2779
+ # {
2780
+ # "position_side": "SHORT",
2781
+ # "leverage": 10
2782
+ # }
2783
+ # ]
2784
+ # },
2785
+ # "timestamp": 1720886470482
2786
+ # }
2787
+ #
2788
+ # ONE_WAY
2789
+ # {
2790
+ # "success": True,
2791
+ # "data": {
2792
+ # "symbol": "PERP_ETH_USDT",
2793
+ # "default_margin_mode": "ISOLATED",
2794
+ # "position_mode": "ONE_WAY",
2795
+ # "details": [
2796
+ # {
2797
+ # "position_side": "BOTH",
2798
+ # "leverage": 10
2799
+ # }
2800
+ # ]
2801
+ # },
2802
+ # "timestamp": 1720886810317
2803
+ # }
2804
+ #
2805
+ else:
2806
+ raise NotSupported(self.id + ' fetchLeverage() is not supported for ' + market['type'] + ' markets')
2712
2807
  data = self.safe_dict(response, 'data', {})
2713
2808
  return self.parse_leverage(data, market)
2714
2809
 
2715
2810
  def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
2716
- leverageValue = self.safe_integer(leverage, 'leverage')
2811
+ marketId = self.safe_string(leverage, 'symbol')
2812
+ market = self.safe_market(marketId, market)
2813
+ marginMode = self.safe_string_lower(leverage, 'default_margin_mode')
2814
+ spotLeverage = self.safe_integer(leverage, 'leverage')
2815
+ longLeverage = spotLeverage
2816
+ shortLeverage = spotLeverage
2817
+ details = self.safe_list(leverage, 'details', [])
2818
+ for i in range(0, len(details)):
2819
+ position = self.safe_dict(details, i, {})
2820
+ positionLeverage = self.safe_integer(position, 'leverage')
2821
+ side = self.safe_string(position, 'position_side')
2822
+ if side == 'BOTH':
2823
+ longLeverage = positionLeverage
2824
+ shortLeverage = positionLeverage
2825
+ elif side == 'LONG':
2826
+ longLeverage = positionLeverage
2827
+ elif side == 'SHORT':
2828
+ shortLeverage = positionLeverage
2717
2829
  return {
2718
2830
  'info': leverage,
2719
2831
  'symbol': market['symbol'],
2720
- 'marginMode': None,
2721
- 'longLeverage': leverageValue,
2722
- 'shortLeverage': leverageValue,
2832
+ 'marginMode': marginMode,
2833
+ 'longLeverage': longLeverage,
2834
+ 'shortLeverage': shortLeverage,
2723
2835
  }
2724
2836
 
2725
2837
  def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
2838
+ """
2839
+ set the level of leverage for a market
2840
+ :see: https://docs.woo.org/#update-leverage-setting
2841
+ :see: https://docs.woo.org/#update-futures-leverage-setting
2842
+ :param float leverage: the rate of leverage(1, 2, 3, 4 or 5 for spot markets, 1, 2, 3, 4, 5, 10, 15, 20 for swap markets)
2843
+ :param str [symbo]: unified market symbol(is mandatory for swap markets)
2844
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2845
+ :param str [params.marginMode]: *for swap markets only* 'cross' or 'isolated'
2846
+ :param str [params.position_side]: *for swap markets only* 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode.
2847
+ :returns dict: response from the exchange
2848
+ """
2726
2849
  self.load_markets()
2727
- if (leverage < 1) or (leverage > 20):
2728
- raise BadRequest(self.id + ' leverage should be between 1 and 20')
2729
2850
  request: dict = {
2730
2851
  'leverage': leverage,
2731
2852
  }
2732
- return self.v1PrivatePostClientLeverage(self.extend(request, params))
2853
+ market: Market = None
2854
+ if symbol is not None:
2855
+ market = self.market(symbol)
2856
+ if (symbol is None) or market['spot']:
2857
+ return self.v1PrivatePostClientLeverage(self.extend(request, params))
2858
+ elif market['swap']:
2859
+ request['symbol'] = market['id']
2860
+ marginMode: Str = None
2861
+ marginMode, params = self.handle_margin_mode_and_params('fetchLeverage', params, 'cross')
2862
+ request['margin_mode'] = self.encode_margin_mode(marginMode)
2863
+ return self.v1PrivatePostClientFuturesLeverage(self.extend(request, params))
2864
+ else:
2865
+ raise NotSupported(self.id + ' fetchLeverage() is not supported for ' + market['type'] + ' markets')
2866
+
2867
+ def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
2868
+ """
2869
+ add margin
2870
+ :see: https://docs.woo.org/#update-isolated-margin-setting
2871
+ :param str symbol: unified market symbol
2872
+ :param float amount: amount of margin to add
2873
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2874
+ :param str [params.position_side]: 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
2875
+ :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=add-margin-structure>`
2876
+ """
2877
+ return self.modify_margin_helper(symbol, amount, 'ADD', params)
2878
+
2879
+ def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
2880
+ """
2881
+ remove margin from a position
2882
+ :see: https://docs.woo.org/#update-isolated-margin-setting
2883
+ :param str symbol: unified market symbol
2884
+ :param float amount: amount of margin to remove
2885
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2886
+ :param str [params.position_side]: 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
2887
+ :returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
2888
+ """
2889
+ return self.modify_margin_helper(symbol, amount, 'REDUCE', params)
2890
+
2891
+ def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
2892
+ self.load_markets()
2893
+ market = self.market(symbol)
2894
+ request: dict = {
2895
+ 'symbol': market['id'],
2896
+ 'adjust_token': 'USDT', # todo check
2897
+ 'adjust_amount': amount,
2898
+ 'action': type,
2899
+ }
2900
+ return self.v1PrivatePostClientIsolatedMargin(self.extend(request, params))
2733
2901
 
2734
2902
  def fetch_position(self, symbol: Str = None, params={}):
2735
2903
  self.load_markets()
@@ -2740,17 +2908,26 @@ class woo(Exchange, ImplicitAPI):
2740
2908
  response = self.v1PrivateGetPositionSymbol(self.extend(request, params))
2741
2909
  #
2742
2910
  # {
2743
- # "symbol":"PERP_ETC_USDT",
2744
- # "holding":0.0,
2745
- # "pnl_24_h":0,
2746
- # "settle_price":0.0,
2747
- # "average_open_price":0,
2748
- # "success":true,
2749
- # "mark_price":22.6955,
2750
- # "pending_short_qty":0.0,
2751
- # "pending_long_qty":0.0,
2752
- # "fee_24_h":0,
2753
- # "timestamp":"1652231044.920"
2911
+ # "symbol": "PERP_ETH_USDT",
2912
+ # "position_side": "BOTH",
2913
+ # "leverage": 10,
2914
+ # "margin_mode": "CROSS",
2915
+ # "average_open_price": 3139.9,
2916
+ # "isolated_margin_amount": 0.0,
2917
+ # "isolated_margin_token": "",
2918
+ # "opening_time": "1720627963.094",
2919
+ # "mark_price": 3155.19169891,
2920
+ # "pending_short_qty": 0.0,
2921
+ # "pending_long_qty": 0.0,
2922
+ # "holding": -0.7,
2923
+ # "pnl_24_h": 0.0,
2924
+ # "est_liq_price": 9107.40055552,
2925
+ # "settle_price": 3151.0319904,
2926
+ # "success": True,
2927
+ # "fee_24_h": 0.0,
2928
+ # "isolated_frozen_long": 0.0,
2929
+ # "isolated_frozen_short": 0.0,
2930
+ # "timestamp": "1720867502.544"
2754
2931
  # }
2755
2932
  #
2756
2933
  return self.parse_position(response, market)
@@ -2761,24 +2938,54 @@ class woo(Exchange, ImplicitAPI):
2761
2938
  #
2762
2939
  # {
2763
2940
  # "success": True,
2764
- # "data": {
2941
+ # "data":
2942
+ # {
2765
2943
  # "positions": [
2766
2944
  # {
2767
- # "symbol": "0_symbol",
2768
- # "holding": 1,
2769
- # "pendingLongQty": 0,
2770
- # "pendingShortQty": 1,
2771
- # "settlePrice": 1,
2772
- # "averageOpenPrice": 1,
2773
- # "pnl24H": 1,
2774
- # "fee24H": 1,
2775
- # "markPrice": 1,
2776
- # "estLiqPrice": 1,
2777
- # "timestamp": 12321321
2945
+ # "symbol": "PERP_ETH_USDT",
2946
+ # "holding": -1.0,
2947
+ # "pendingLongQty": 0.0,
2948
+ # "pendingShortQty": 0.0,
2949
+ # "settlePrice": 3143.2,
2950
+ # "averageOpenPrice": 3143.2,
2951
+ # "pnl24H": 0.0,
2952
+ # "fee24H": 1.5716,
2953
+ # "markPrice": 3134.97984158,
2954
+ # "estLiqPrice": 3436.176349,
2955
+ # "timestamp": 1720628031.463,
2956
+ # "adlQuantile": 5,
2957
+ # "positionSide": "BOTH",
2958
+ # "marginMode": "ISOLATED",
2959
+ # "isolatedMarginToken": "USDT",
2960
+ # "isolatedMarginAmount": 314.62426,
2961
+ # "isolatedFrozenLong": 0.0,
2962
+ # "isolatedFrozenShort": 0.0,
2963
+ # "leverage": 10
2964
+ # },
2965
+ # {
2966
+ # "symbol": "PERP_SOL_USDT",
2967
+ # "holding": -1.0,
2968
+ # "pendingLongQty": 0.0,
2969
+ # "pendingShortQty": 0.0,
2970
+ # "settlePrice": 141.89933923,
2971
+ # "averageOpenPrice": 171.38,
2972
+ # "pnl24H": 0.0,
2973
+ # "fee24H": 0.0,
2974
+ # "markPrice": 141.65155427,
2975
+ # "estLiqPrice": 4242.73548551,
2976
+ # "timestamp": 1720616702.68,
2977
+ # "adlQuantile": 5,
2978
+ # "positionSide": "BOTH",
2979
+ # "marginMode": "CROSS",
2980
+ # "isolatedMarginToken": "",
2981
+ # "isolatedMarginAmount": 0.0,
2982
+ # "isolatedFrozenLong": 0.0,
2983
+ # "isolatedFrozenShort": 0.0,
2984
+ # "leverage": 10
2778
2985
  # }
2779
2986
  # ]
2780
2987
  # },
2781
- # "timestamp": 1673323880342
2988
+ # "timestamp": 1720628675078
2782
2989
  # }
2783
2990
  #
2784
2991
  result = self.safe_dict(response, 'data', {})
@@ -2787,18 +2994,51 @@ class woo(Exchange, ImplicitAPI):
2787
2994
 
2788
2995
  def parse_position(self, position: dict, market: Market = None):
2789
2996
  #
2997
+ # v1PrivateGetPositionSymbol
2998
+ # {
2999
+ # "symbol": "PERP_ETH_USDT",
3000
+ # "position_side": "BOTH",
3001
+ # "leverage": 10,
3002
+ # "margin_mode": "CROSS",
3003
+ # "average_open_price": 3139.9,
3004
+ # "isolated_margin_amount": 0.0,
3005
+ # "isolated_margin_token": "",
3006
+ # "opening_time": "1720627963.094",
3007
+ # "mark_price": 3155.19169891,
3008
+ # "pending_short_qty": 0.0,
3009
+ # "pending_long_qty": 0.0,
3010
+ # "holding": -0.7,
3011
+ # "pnl_24_h": 0.0,
3012
+ # "est_liq_price": 9107.40055552,
3013
+ # "settle_price": 3151.0319904,
3014
+ # "success": True,
3015
+ # "fee_24_h": 0.0,
3016
+ # "isolated_frozen_long": 0.0,
3017
+ # "isolated_frozen_short": 0.0,
3018
+ # "timestamp": "1720867502.544"
3019
+ # }
3020
+ #
3021
+ # v3PrivateGetPositions
2790
3022
  # {
2791
- # "symbol": "0_symbol",
2792
- # "holding": 1,
2793
- # "pendingLongQty": 0,
2794
- # "pendingShortQty": 1,
2795
- # "settlePrice": 1,
2796
- # "averageOpenPrice": 1,
2797
- # "pnl24H": 1,
2798
- # "fee24H": 1,
2799
- # "markPrice": 1,
2800
- # "estLiqPrice": 1,
2801
- # "timestamp": 12321321
3023
+ # "symbol": "PERP_ETH_USDT",
3024
+ # "holding": -1.0,
3025
+ # "pendingLongQty": 0.0, # todo: check
3026
+ # "pendingShortQty": 0.0, # todo: check
3027
+ # "settlePrice": 3143.2,
3028
+ # "averageOpenPrice": 3143.2,
3029
+ # "pnl24H": 0.0, # todo: check
3030
+ # "fee24H": 1.5716, # todo: check
3031
+ # "markPrice": 3134.97984158,
3032
+ # "estLiqPrice": 3436.176349,
3033
+ # "timestamp": 1720628031.463,
3034
+ # "adlQuantile": 5,
3035
+ # "positionSide": "BOTH",
3036
+ # "marginMode": "ISOLATED",
3037
+ # "isolatedMarginToken": "USDT", # todo: check
3038
+ # "isolatedMarginAmount": 314.62426, # todo: check
3039
+ # "isolatedFrozenLong": 0.0, # todo: check
3040
+ # "isolatedFrozenShort": 0.0, # todo: check
3041
+ # "leverage": 10
2802
3042
  # }
2803
3043
  #
2804
3044
  contract = self.safe_string(position, 'symbol')
@@ -2810,13 +3050,14 @@ class woo(Exchange, ImplicitAPI):
2810
3050
  else:
2811
3051
  side = 'short'
2812
3052
  contractSize = self.safe_string(market, 'contractSize')
2813
- markPrice = self.safe_string(position, 'markPrice')
3053
+ markPrice = self.safe_string_2(position, 'markPrice', 'mark_price')
2814
3054
  timestamp = self.safe_timestamp(position, 'timestamp')
2815
- entryPrice = self.safe_string(position, 'averageOpenPrice')
3055
+ entryPrice = self.safe_string_2(position, 'averageOpenPrice', 'average_open_price')
2816
3056
  priceDifference = Precise.string_sub(markPrice, entryPrice)
2817
3057
  unrealisedPnl = Precise.string_mul(priceDifference, size)
2818
3058
  size = Precise.string_abs(size)
2819
3059
  notional = Precise.string_mul(size, markPrice)
3060
+ positionSide = self.safe_string(position, 'positionSide') # 'SHORT' or 'LONG' for hedged, 'BOTH' for non-hedged
2820
3061
  return self.safe_position({
2821
3062
  'info': position,
2822
3063
  'id': None,
@@ -2830,20 +3071,19 @@ class woo(Exchange, ImplicitAPI):
2830
3071
  'maintenanceMarginPercentage': None,
2831
3072
  'entryPrice': self.parse_number(entryPrice),
2832
3073
  'notional': self.parse_number(notional),
2833
- 'leverage': None,
3074
+ 'leverage': self.safe_number(position, 'leverage'),
2834
3075
  'unrealizedPnl': self.parse_number(unrealisedPnl),
2835
3076
  'contracts': self.parse_number(size),
2836
3077
  'contractSize': self.parse_number(contractSize),
2837
3078
  'marginRatio': None,
2838
- 'liquidationPrice': self.safe_number(position, 'estLiqPrice'),
3079
+ 'liquidationPrice': self.safe_number_2(position, 'estLiqPrice', 'est_liq_price'),
2839
3080
  'markPrice': self.parse_number(markPrice),
2840
3081
  'lastPrice': None,
2841
3082
  'collateral': None,
2842
- 'marginMode': 'cross',
2843
- 'marginType': None,
3083
+ 'marginMode': self.safe_string_lower_2(position, 'marginMode', 'margin_mode'),
2844
3084
  'side': side,
2845
3085
  'percentage': None,
2846
- 'hedged': None,
3086
+ 'hedged': positionSide != 'BOTH',
2847
3087
  'stopLossPrice': None,
2848
3088
  'takeProfitPrice': None,
2849
3089
  })
ccxt/xt.py CHANGED
@@ -3307,7 +3307,7 @@ class xt(Exchange, ImplicitAPI):
3307
3307
  }
3308
3308
  return self.safe_string(statuses, status, status)
3309
3309
 
3310
- def fetch_ledger(self, code: str = None, since: Int = None, limit: Int = None, params={}):
3310
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
3311
3311
  """
3312
3312
  fetch the history of changes, actions done by the user or operations that altered the balance of the user
3313
3313
  :see: https://doc.xt.com/#futures_usergetBalanceBill
@@ -3466,7 +3466,7 @@ class xt(Exchange, ImplicitAPI):
3466
3466
  'info': depositAddress,
3467
3467
  }
3468
3468
 
3469
- def fetch_deposits(self, code: str = None, since: Int = None, limit: Int = None, params={}):
3469
+ def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
3470
3470
  """
3471
3471
  fetch all deposits made to an account
3472
3472
  :see: https://doc.xt.com/#deposit_withdrawalhistoryDepositGet
@@ -3517,7 +3517,7 @@ class xt(Exchange, ImplicitAPI):
3517
3517
  deposits = self.safe_value(data, 'items', [])
3518
3518
  return self.parse_transactions(deposits, currency, since, limit, params)
3519
3519
 
3520
- def fetch_withdrawals(self, code: str = None, since: Int = None, limit: Int = None, params={}):
3520
+ def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
3521
3521
  """
3522
3522
  fetch all withdrawals made from an account
3523
3523
  :see: https://doc.xt.com/#deposit_withdrawalwithdrawHistory
ccxt/yobit.py CHANGED
@@ -558,7 +558,7 @@ class yobit(Exchange, ImplicitAPI):
558
558
  ids = self.ids
559
559
  else:
560
560
  ids = self.market_ids(symbols)
561
- idsLength = len(ids)
561
+ idsLength: number = len(ids)
562
562
  idsString = '-'.join(ids)
563
563
  maxLength = self.safe_integer(self.options, 'maxUrlLength', 2048)
564
564
  # max URL length is 2048 symbols, including http schema, hostname, tld, etc...
ccxt/zonda.py CHANGED
@@ -1467,7 +1467,7 @@ class zonda(Exchange, ImplicitAPI):
1467
1467
  # {status: "Ok", errors: []}
1468
1468
  return self.parse_order(response)
1469
1469
 
1470
- def is_fiat(self, currency):
1470
+ def is_fiat(self, currency: str):
1471
1471
  fiatCurrencies: dict = {
1472
1472
  'USD': True,
1473
1473
  'EUR': True,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ccxt
3
- Version: 4.3.62
3
+ Version: 4.3.64
4
4
  Summary: A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges
5
5
  Home-page: https://ccxt.com
6
6
  Author: Igor Kroitor
@@ -268,13 +268,13 @@ console.log(version, Object.keys(exchanges));
268
268
 
269
269
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
270
270
 
271
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.62/dist/ccxt.browser.min.js
272
- * unpkg: https://unpkg.com/ccxt@4.3.62/dist/ccxt.browser.min.js
271
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.64/dist/ccxt.browser.min.js
272
+ * unpkg: https://unpkg.com/ccxt@4.3.64/dist/ccxt.browser.min.js
273
273
 
274
274
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
275
275
 
276
276
  ```HTML
277
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.62/dist/ccxt.browser.min.js"></script>
277
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.64/dist/ccxt.browser.min.js"></script>
278
278
  ```
279
279
 
280
280
  Creates a global `ccxt` object: