ccxt 4.3.62 → 4.3.64

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 (86) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +2 -1
  4. package/dist/cjs/src/ace.js +34 -15
  5. package/dist/cjs/src/alpaca.js +1 -0
  6. package/dist/cjs/src/base/Exchange.js +11 -4
  7. package/dist/cjs/src/base/errors.js +8 -1
  8. package/dist/cjs/src/binance.js +6 -9
  9. package/dist/cjs/src/bingx.js +554 -151
  10. package/dist/cjs/src/bitfinex.js +1 -1
  11. package/dist/cjs/src/bitfinex2.js +1 -1
  12. package/dist/cjs/src/cryptocom.js +18 -2
  13. package/dist/cjs/src/independentreserve.js +107 -0
  14. package/dist/cjs/src/kucoin.js +2 -0
  15. package/dist/cjs/src/mercado.js +5 -1
  16. package/dist/cjs/src/pro/binance.js +58 -34
  17. package/dist/cjs/src/pro/bitfinex2.js +6 -3
  18. package/dist/cjs/src/pro/bitget.js +4 -1
  19. package/dist/cjs/src/pro/bitmart.js +3 -3
  20. package/dist/cjs/src/pro/bitvavo.js +1 -1
  21. package/dist/cjs/src/pro/bybit.js +44 -18
  22. package/dist/cjs/src/pro/cryptocom.js +7 -1
  23. package/dist/cjs/src/pro/gate.js +7 -3
  24. package/dist/cjs/src/pro/gemini.js +4 -2
  25. package/dist/cjs/src/pro/htx.js +5 -1
  26. package/dist/cjs/src/pro/independentreserve.js +5 -3
  27. package/dist/cjs/src/pro/kraken.js +82 -4
  28. package/dist/cjs/src/pro/okx.js +3 -3
  29. package/dist/cjs/src/pro/onetrading.js +3 -2
  30. package/dist/cjs/src/pro/poloniexfutures.js +5 -1
  31. package/dist/cjs/src/pro/vertex.js +3 -2
  32. package/dist/cjs/src/pro/woo.js +2 -1
  33. package/dist/cjs/src/pro/woofipro.js +3 -2
  34. package/dist/cjs/src/woo.js +344 -81
  35. package/js/ccxt.d.ts +3 -3
  36. package/js/ccxt.js +3 -3
  37. package/js/src/abstract/cryptocom.d.ts +11 -0
  38. package/js/src/abstract/kucoin.d.ts +1 -0
  39. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  40. package/js/src/abstract/woo.d.ts +3 -0
  41. package/js/src/ace.js +34 -15
  42. package/js/src/alpaca.js +1 -0
  43. package/js/src/base/Exchange.d.ts +1 -0
  44. package/js/src/base/Exchange.js +11 -4
  45. package/js/src/base/errorHierarchy.d.ts +3 -1
  46. package/js/src/base/errorHierarchy.js +3 -1
  47. package/js/src/base/errors.d.ts +5 -1
  48. package/js/src/base/errors.js +8 -2
  49. package/js/src/binance.js +6 -9
  50. package/js/src/bingx.d.ts +4 -1
  51. package/js/src/bingx.js +554 -151
  52. package/js/src/bitfinex.js +1 -1
  53. package/js/src/bitfinex2.js +1 -1
  54. package/js/src/coinbaseinternational.d.ts +1 -1
  55. package/js/src/cryptocom.js +18 -2
  56. package/js/src/independentreserve.d.ts +3 -1
  57. package/js/src/independentreserve.js +106 -0
  58. package/js/src/kucoin.js +2 -0
  59. package/js/src/mercado.js +5 -1
  60. package/js/src/pro/binance.d.ts +1 -0
  61. package/js/src/pro/binance.js +59 -35
  62. package/js/src/pro/bitfinex2.js +7 -4
  63. package/js/src/pro/bitget.js +5 -2
  64. package/js/src/pro/bitmart.js +3 -3
  65. package/js/src/pro/bitvavo.js +1 -1
  66. package/js/src/pro/bybit.d.ts +1 -0
  67. package/js/src/pro/bybit.js +44 -18
  68. package/js/src/pro/cryptocom.js +8 -2
  69. package/js/src/pro/gate.js +8 -4
  70. package/js/src/pro/gemini.js +4 -2
  71. package/js/src/pro/htx.js +6 -2
  72. package/js/src/pro/independentreserve.js +6 -4
  73. package/js/src/pro/kraken.d.ts +3 -1
  74. package/js/src/pro/kraken.js +83 -5
  75. package/js/src/pro/okx.js +4 -4
  76. package/js/src/pro/onetrading.js +3 -2
  77. package/js/src/pro/poloniexfutures.js +6 -2
  78. package/js/src/pro/vertex.js +3 -2
  79. package/js/src/pro/woo.js +2 -1
  80. package/js/src/pro/woofipro.js +3 -2
  81. package/js/src/whitebit.d.ts +1 -1
  82. package/js/src/woo.d.ts +6 -2
  83. package/js/src/woo.js +344 -81
  84. package/js/src/xt.d.ts +3 -3
  85. package/js/src/zonda.d.ts +1 -1
  86. package/package.json +1 -1
package/js/src/woo.js CHANGED
@@ -33,7 +33,7 @@ export default class woo extends Exchange {
33
33
  'swap': true,
34
34
  'future': false,
35
35
  'option': false,
36
- 'addMargin': false,
36
+ 'addMargin': true,
37
37
  'cancelAllOrders': true,
38
38
  'cancelAllOrdersAfter': true,
39
39
  'cancelOrder': true,
@@ -203,6 +203,7 @@ export default class woo extends Exchange {
203
203
  'positions': 3.33,
204
204
  'position/{symbol}': 3.33,
205
205
  'client/transaction_history': 60,
206
+ 'client/futures_leverage': 60,
206
207
  },
207
208
  'post': {
208
209
  'order': 5,
@@ -215,6 +216,8 @@ export default class woo extends Exchange {
215
216
  'client/account_mode': 120,
216
217
  'client/position_mode': 5,
217
218
  'client/leverage': 120,
219
+ 'client/futures_leverage': 30,
220
+ 'client/isolated_margin': 30,
218
221
  },
219
222
  'delete': {
220
223
  'order': 1,
@@ -938,16 +941,18 @@ export default class woo extends Exchange {
938
941
  * @param {float} amount how much of currency you want to trade in units of base currency
939
942
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
940
943
  * @param {object} [params] extra parameters specific to the exchange API endpoint
944
+ * @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated', default 'cross'
941
945
  * @param {float} [params.triggerPrice] The price a trigger order is triggered at
942
946
  * @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
943
947
  * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
944
948
  * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
945
949
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
946
- * @param {float} [params.algoType] 'STOP'or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
950
+ * @param {float} [params.algoType] 'STOP' or 'TRAILING_STOP' or 'OCO' or 'CLOSE_POSITION'
947
951
  * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
948
952
  * @param {string} [params.trailingAmount] the quote amount to trail away from the current market price
949
953
  * @param {string} [params.trailingPercent] the percent to trail away from the current market price
950
954
  * @param {string} [params.trailingTriggerPrice] the price to trigger a trailing order, default uses the price argument
955
+ * @param {string} [params.position_side] 'SHORT' or 'LONG' - if position mode is HEDGE_MODE and the trading involves futures, then is required, otherwise this parameter is not required
951
956
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
952
957
  */
953
958
  const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only');
@@ -960,6 +965,11 @@ export default class woo extends Exchange {
960
965
  'symbol': market['id'],
961
966
  'side': orderSide,
962
967
  };
968
+ let marginMode = undefined;
969
+ [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
970
+ if (marginMode !== undefined) {
971
+ request['margin_mode'] = this.encodeMarginMode(marginMode);
972
+ }
963
973
  const stopPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
964
974
  const stopLoss = this.safeValue(params, 'stopLoss');
965
975
  const takeProfit = this.safeValue(params, 'takeProfit');
@@ -1121,6 +1131,13 @@ export default class woo extends Exchange {
1121
1131
  order['type'] = type;
1122
1132
  return order;
1123
1133
  }
1134
+ encodeMarginMode(mode) {
1135
+ const modes = {
1136
+ 'cross': 'CROSS',
1137
+ 'isolated': 'ISOLATED',
1138
+ };
1139
+ return this.safeString(modes, mode, mode);
1140
+ }
1124
1141
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1125
1142
  /**
1126
1143
  * @method
@@ -2657,7 +2674,24 @@ export default class woo extends Exchange {
2657
2674
  };
2658
2675
  }
2659
2676
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2677
+ /**
2678
+ * @method
2679
+ * @name woo#fetchFundingHistory
2680
+ * @description fetch the history of funding payments paid and received on this account
2681
+ * @see https://docs.woo.org/#get-funding-fee-history
2682
+ * @param {string} [symbol] unified market symbol
2683
+ * @param {int} [since] the earliest time in ms to fetch funding history for
2684
+ * @param {int} [limit] the maximum number of funding history structures to retrieve
2685
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2686
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2687
+ * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
2688
+ */
2660
2689
  await this.loadMarkets();
2690
+ let paginate = false;
2691
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingHistory', 'paginate');
2692
+ if (paginate) {
2693
+ return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'page', 'page', 1, 500);
2694
+ }
2661
2695
  const request = {};
2662
2696
  let market = undefined;
2663
2697
  if (symbol !== undefined) {
@@ -2667,6 +2701,12 @@ export default class woo extends Exchange {
2667
2701
  if (since !== undefined) {
2668
2702
  request['start_t'] = since;
2669
2703
  }
2704
+ if (limit !== undefined) {
2705
+ request['size'] = limit;
2706
+ }
2707
+ else {
2708
+ request['size'] = 5000;
2709
+ }
2670
2710
  const response = await this.v1PrivateGetFundingFeeHistory(this.extend(request, params));
2671
2711
  //
2672
2712
  // {
@@ -2691,7 +2731,15 @@ export default class woo extends Exchange {
2691
2731
  // "success":true
2692
2732
  // }
2693
2733
  //
2734
+ const meta = this.safeDict(response, 'meta', {});
2735
+ const cursor = this.safeInteger(meta, 'current_page');
2694
2736
  const result = this.safeList(response, 'rows', []);
2737
+ const resultLength = result.length;
2738
+ if (resultLength > 0) {
2739
+ const lastItem = result[resultLength - 1];
2740
+ lastItem['page'] = cursor;
2741
+ result[resultLength - 1] = lastItem;
2742
+ }
2695
2743
  return this.parseIncomes(result, market, since, limit);
2696
2744
  }
2697
2745
  parseFundingRate(fundingRate, market = undefined) {
@@ -2882,61 +2930,204 @@ export default class woo extends Exchange {
2882
2930
  * @see https://docs.woo.org/#get-account-information-new
2883
2931
  * @param {string} symbol unified market symbol
2884
2932
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2933
+ * @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated'
2934
+ * @param {string} [params.position_mode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE'
2885
2935
  * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2886
2936
  */
2887
2937
  await this.loadMarkets();
2888
2938
  const market = this.market(symbol);
2889
- const response = await this.v3PrivateGetAccountinfo(params);
2890
- //
2891
- // {
2892
- // "success": true,
2893
- // "data": {
2894
- // "applicationId": "dsa",
2895
- // "account": "dsa",
2896
- // "alias": "haha",
2897
- // "accountMode": "MARGIN",
2898
- // "leverage": 1,
2899
- // "takerFeeRate": 1,
2900
- // "makerFeeRate": 1,
2901
- // "interestRate": 1,
2902
- // "futuresTakerFeeRate": 1,
2903
- // "futuresMakerFeeRate": 1,
2904
- // "otpauth": true,
2905
- // "marginRatio": 1,
2906
- // "openMarginRatio": 1,
2907
- // "initialMarginRatio": 1,
2908
- // "maintenanceMarginRatio": 1,
2909
- // "totalCollateral": 1,
2910
- // "freeCollateral": 1,
2911
- // "totalAccountValue": 1,
2912
- // "totalVaultValue": 1,
2913
- // "totalStakingValue": 1
2914
- // },
2915
- // "timestamp": 1673323685109
2916
- // }
2917
- //
2939
+ let response = undefined;
2940
+ if (market['spot']) {
2941
+ response = await this.v3PrivateGetAccountinfo(params);
2942
+ //
2943
+ // {
2944
+ // "success": true,
2945
+ // "data": {
2946
+ // "applicationId": "dsa",
2947
+ // "account": "dsa",
2948
+ // "alias": "haha",
2949
+ // "accountMode": "MARGIN",
2950
+ // "leverage": 1,
2951
+ // "takerFeeRate": 1,
2952
+ // "makerFeeRate": 1,
2953
+ // "interestRate": 1,
2954
+ // "futuresTakerFeeRate": 1,
2955
+ // "futuresMakerFeeRate": 1,
2956
+ // "otpauth": true,
2957
+ // "marginRatio": 1,
2958
+ // "openMarginRatio": 1,
2959
+ // "initialMarginRatio": 1,
2960
+ // "maintenanceMarginRatio": 1,
2961
+ // "totalCollateral": 1,
2962
+ // "freeCollateral": 1,
2963
+ // "totalAccountValue": 1,
2964
+ // "totalVaultValue": 1,
2965
+ // "totalStakingValue": 1
2966
+ // },
2967
+ // "timestamp": 1673323685109
2968
+ // }
2969
+ //
2970
+ }
2971
+ else if (market['swap']) {
2972
+ const request = {
2973
+ 'symbol': market['id'],
2974
+ };
2975
+ let marginMode = undefined;
2976
+ [marginMode, params] = this.handleMarginModeAndParams('fetchLeverage', params, 'cross');
2977
+ request['margin_mode'] = this.encodeMarginMode(marginMode);
2978
+ response = await this.v1PrivateGetClientFuturesLeverage(this.extend(request, params));
2979
+ //
2980
+ // HEDGE_MODE
2981
+ // {
2982
+ // "success": true,
2983
+ // "data":
2984
+ // {
2985
+ // "symbol": "PERP_ETH_USDT",
2986
+ // "default_margin_mode": "CROSS",
2987
+ // "position_mode": "HEDGE_MODE",
2988
+ // "details": [
2989
+ // {
2990
+ // "position_side": "LONG",
2991
+ // "leverage": 10
2992
+ // },
2993
+ // {
2994
+ // "position_side": "SHORT",
2995
+ // "leverage": 10
2996
+ // }
2997
+ // ]
2998
+ // },
2999
+ // "timestamp": 1720886470482
3000
+ // }
3001
+ //
3002
+ // ONE_WAY
3003
+ // {
3004
+ // "success": true,
3005
+ // "data": {
3006
+ // "symbol": "PERP_ETH_USDT",
3007
+ // "default_margin_mode": "ISOLATED",
3008
+ // "position_mode": "ONE_WAY",
3009
+ // "details": [
3010
+ // {
3011
+ // "position_side": "BOTH",
3012
+ // "leverage": 10
3013
+ // }
3014
+ // ]
3015
+ // },
3016
+ // "timestamp": 1720886810317
3017
+ // }
3018
+ //
3019
+ }
3020
+ else {
3021
+ throw new NotSupported(this.id + ' fetchLeverage() is not supported for ' + market['type'] + ' markets');
3022
+ }
2918
3023
  const data = this.safeDict(response, 'data', {});
2919
3024
  return this.parseLeverage(data, market);
2920
3025
  }
2921
3026
  parseLeverage(leverage, market = undefined) {
2922
- const leverageValue = this.safeInteger(leverage, 'leverage');
3027
+ const marketId = this.safeString(leverage, 'symbol');
3028
+ market = this.safeMarket(marketId, market);
3029
+ const marginMode = this.safeStringLower(leverage, 'default_margin_mode');
3030
+ const spotLeverage = this.safeInteger(leverage, 'leverage');
3031
+ let longLeverage = spotLeverage;
3032
+ let shortLeverage = spotLeverage;
3033
+ const details = this.safeList(leverage, 'details', []);
3034
+ for (let i = 0; i < details.length; i++) {
3035
+ const position = this.safeDict(details, i, {});
3036
+ const positionLeverage = this.safeInteger(position, 'leverage');
3037
+ const side = this.safeString(position, 'position_side');
3038
+ if (side === 'BOTH') {
3039
+ longLeverage = positionLeverage;
3040
+ shortLeverage = positionLeverage;
3041
+ }
3042
+ else if (side === 'LONG') {
3043
+ longLeverage = positionLeverage;
3044
+ }
3045
+ else if (side === 'SHORT') {
3046
+ shortLeverage = positionLeverage;
3047
+ }
3048
+ }
2923
3049
  return {
2924
3050
  'info': leverage,
2925
3051
  'symbol': market['symbol'],
2926
- 'marginMode': undefined,
2927
- 'longLeverage': leverageValue,
2928
- 'shortLeverage': leverageValue,
3052
+ 'marginMode': marginMode,
3053
+ 'longLeverage': longLeverage,
3054
+ 'shortLeverage': shortLeverage,
2929
3055
  };
2930
3056
  }
2931
3057
  async setLeverage(leverage, symbol = undefined, params = {}) {
3058
+ /**
3059
+ * @method
3060
+ * @name woo#setLeverage
3061
+ * @description set the level of leverage for a market
3062
+ * @see https://docs.woo.org/#update-leverage-setting
3063
+ * @see https://docs.woo.org/#update-futures-leverage-setting
3064
+ * @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)
3065
+ * @param {string} [symbo] unified market symbol (is mandatory for swap markets)
3066
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3067
+ * @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated'
3068
+ * @param {string} [params.position_side] *for swap markets only* 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode.
3069
+ * @returns {object} response from the exchange
3070
+ */
2932
3071
  await this.loadMarkets();
2933
- if ((leverage < 1) || (leverage > 20)) {
2934
- throw new BadRequest(this.id + ' leverage should be between 1 and 20');
2935
- }
2936
3072
  const request = {
2937
3073
  'leverage': leverage,
2938
3074
  };
2939
- return await this.v1PrivatePostClientLeverage(this.extend(request, params));
3075
+ let market = undefined;
3076
+ if (symbol !== undefined) {
3077
+ market = this.market(symbol);
3078
+ }
3079
+ if ((symbol === undefined) || market['spot']) {
3080
+ return await this.v1PrivatePostClientLeverage(this.extend(request, params));
3081
+ }
3082
+ else if (market['swap']) {
3083
+ request['symbol'] = market['id'];
3084
+ let marginMode = undefined;
3085
+ [marginMode, params] = this.handleMarginModeAndParams('fetchLeverage', params, 'cross');
3086
+ request['margin_mode'] = this.encodeMarginMode(marginMode);
3087
+ return await this.v1PrivatePostClientFuturesLeverage(this.extend(request, params));
3088
+ }
3089
+ else {
3090
+ throw new NotSupported(this.id + ' fetchLeverage() is not supported for ' + market['type'] + ' markets');
3091
+ }
3092
+ }
3093
+ async addMargin(symbol, amount, params = {}) {
3094
+ /**
3095
+ * @method
3096
+ * @name woo#addMargin
3097
+ * @description add margin
3098
+ * @see https://docs.woo.org/#update-isolated-margin-setting
3099
+ * @param {string} symbol unified market symbol
3100
+ * @param {float} amount amount of margin to add
3101
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3102
+ * @param {string} [params.position_side] 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
3103
+ * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
3104
+ */
3105
+ return await this.modifyMarginHelper(symbol, amount, 'ADD', params);
3106
+ }
3107
+ async reduceMargin(symbol, amount, params = {}) {
3108
+ /**
3109
+ * @method
3110
+ * @name woo#reduceMargin
3111
+ * @description remove margin from a position
3112
+ * @see https://docs.woo.org/#update-isolated-margin-setting
3113
+ * @param {string} symbol unified market symbol
3114
+ * @param {float} amount amount of margin to remove
3115
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3116
+ * @param {string} [params.position_side] 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
3117
+ * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
3118
+ */
3119
+ return await this.modifyMarginHelper(symbol, amount, 'REDUCE', params);
3120
+ }
3121
+ async modifyMarginHelper(symbol, amount, type, params = {}) {
3122
+ await this.loadMarkets();
3123
+ const market = this.market(symbol);
3124
+ const request = {
3125
+ 'symbol': market['id'],
3126
+ 'adjust_token': 'USDT',
3127
+ 'adjust_amount': amount,
3128
+ 'action': type,
3129
+ };
3130
+ return await this.v1PrivatePostClientIsolatedMargin(this.extend(request, params));
2940
3131
  }
2941
3132
  async fetchPosition(symbol = undefined, params = {}) {
2942
3133
  await this.loadMarkets();
@@ -2947,17 +3138,26 @@ export default class woo extends Exchange {
2947
3138
  const response = await this.v1PrivateGetPositionSymbol(this.extend(request, params));
2948
3139
  //
2949
3140
  // {
2950
- // "symbol":"PERP_ETC_USDT",
2951
- // "holding":0.0,
2952
- // "pnl_24_h":0,
2953
- // "settle_price":0.0,
2954
- // "average_open_price":0,
2955
- // "success":true,
2956
- // "mark_price":22.6955,
2957
- // "pending_short_qty":0.0,
2958
- // "pending_long_qty":0.0,
2959
- // "fee_24_h":0,
2960
- // "timestamp":"1652231044.920"
3141
+ // "symbol": "PERP_ETH_USDT",
3142
+ // "position_side": "BOTH",
3143
+ // "leverage": 10,
3144
+ // "margin_mode": "CROSS",
3145
+ // "average_open_price": 3139.9,
3146
+ // "isolated_margin_amount": 0.0,
3147
+ // "isolated_margin_token": "",
3148
+ // "opening_time": "1720627963.094",
3149
+ // "mark_price": 3155.19169891,
3150
+ // "pending_short_qty": 0.0,
3151
+ // "pending_long_qty": 0.0,
3152
+ // "holding": -0.7,
3153
+ // "pnl_24_h": 0.0,
3154
+ // "est_liq_price": 9107.40055552,
3155
+ // "settle_price": 3151.0319904,
3156
+ // "success": true,
3157
+ // "fee_24_h": 0.0,
3158
+ // "isolated_frozen_long": 0.0,
3159
+ // "isolated_frozen_short": 0.0,
3160
+ // "timestamp": "1720867502.544"
2961
3161
  // }
2962
3162
  //
2963
3163
  return this.parsePosition(response, market);
@@ -2968,24 +3168,54 @@ export default class woo extends Exchange {
2968
3168
  //
2969
3169
  // {
2970
3170
  // "success": true,
2971
- // "data": {
3171
+ // "data":
3172
+ // {
2972
3173
  // "positions": [
2973
3174
  // {
2974
- // "symbol": "0_symbol",
2975
- // "holding": 1,
2976
- // "pendingLongQty": 0,
2977
- // "pendingShortQty": 1,
2978
- // "settlePrice": 1,
2979
- // "averageOpenPrice": 1,
2980
- // "pnl24H": 1,
2981
- // "fee24H": 1,
2982
- // "markPrice": 1,
2983
- // "estLiqPrice": 1,
2984
- // "timestamp": 12321321
3175
+ // "symbol": "PERP_ETH_USDT",
3176
+ // "holding": -1.0,
3177
+ // "pendingLongQty": 0.0,
3178
+ // "pendingShortQty": 0.0,
3179
+ // "settlePrice": 3143.2,
3180
+ // "averageOpenPrice": 3143.2,
3181
+ // "pnl24H": 0.0,
3182
+ // "fee24H": 1.5716,
3183
+ // "markPrice": 3134.97984158,
3184
+ // "estLiqPrice": 3436.176349,
3185
+ // "timestamp": 1720628031.463,
3186
+ // "adlQuantile": 5,
3187
+ // "positionSide": "BOTH",
3188
+ // "marginMode": "ISOLATED",
3189
+ // "isolatedMarginToken": "USDT",
3190
+ // "isolatedMarginAmount": 314.62426,
3191
+ // "isolatedFrozenLong": 0.0,
3192
+ // "isolatedFrozenShort": 0.0,
3193
+ // "leverage": 10
3194
+ // },
3195
+ // {
3196
+ // "symbol": "PERP_SOL_USDT",
3197
+ // "holding": -1.0,
3198
+ // "pendingLongQty": 0.0,
3199
+ // "pendingShortQty": 0.0,
3200
+ // "settlePrice": 141.89933923,
3201
+ // "averageOpenPrice": 171.38,
3202
+ // "pnl24H": 0.0,
3203
+ // "fee24H": 0.0,
3204
+ // "markPrice": 141.65155427,
3205
+ // "estLiqPrice": 4242.73548551,
3206
+ // "timestamp": 1720616702.68,
3207
+ // "adlQuantile": 5,
3208
+ // "positionSide": "BOTH",
3209
+ // "marginMode": "CROSS",
3210
+ // "isolatedMarginToken": "",
3211
+ // "isolatedMarginAmount": 0.0,
3212
+ // "isolatedFrozenLong": 0.0,
3213
+ // "isolatedFrozenShort": 0.0,
3214
+ // "leverage": 10
2985
3215
  // }
2986
3216
  // ]
2987
3217
  // },
2988
- // "timestamp": 1673323880342
3218
+ // "timestamp": 1720628675078
2989
3219
  // }
2990
3220
  //
2991
3221
  const result = this.safeDict(response, 'data', {});
@@ -2994,18 +3224,51 @@ export default class woo extends Exchange {
2994
3224
  }
2995
3225
  parsePosition(position, market = undefined) {
2996
3226
  //
3227
+ // v1PrivateGetPositionSymbol
3228
+ // {
3229
+ // "symbol": "PERP_ETH_USDT",
3230
+ // "position_side": "BOTH",
3231
+ // "leverage": 10,
3232
+ // "margin_mode": "CROSS",
3233
+ // "average_open_price": 3139.9,
3234
+ // "isolated_margin_amount": 0.0,
3235
+ // "isolated_margin_token": "",
3236
+ // "opening_time": "1720627963.094",
3237
+ // "mark_price": 3155.19169891,
3238
+ // "pending_short_qty": 0.0,
3239
+ // "pending_long_qty": 0.0,
3240
+ // "holding": -0.7,
3241
+ // "pnl_24_h": 0.0,
3242
+ // "est_liq_price": 9107.40055552,
3243
+ // "settle_price": 3151.0319904,
3244
+ // "success": true,
3245
+ // "fee_24_h": 0.0,
3246
+ // "isolated_frozen_long": 0.0,
3247
+ // "isolated_frozen_short": 0.0,
3248
+ // "timestamp": "1720867502.544"
3249
+ // }
3250
+ //
3251
+ // v3PrivateGetPositions
2997
3252
  // {
2998
- // "symbol": "0_symbol",
2999
- // "holding": 1,
3000
- // "pendingLongQty": 0,
3001
- // "pendingShortQty": 1,
3002
- // "settlePrice": 1,
3003
- // "averageOpenPrice": 1,
3004
- // "pnl24H": 1,
3005
- // "fee24H": 1,
3006
- // "markPrice": 1,
3007
- // "estLiqPrice": 1,
3008
- // "timestamp": 12321321
3253
+ // "symbol": "PERP_ETH_USDT",
3254
+ // "holding": -1.0,
3255
+ // "pendingLongQty": 0.0, // todo: check
3256
+ // "pendingShortQty": 0.0, // todo: check
3257
+ // "settlePrice": 3143.2,
3258
+ // "averageOpenPrice": 3143.2,
3259
+ // "pnl24H": 0.0, // todo: check
3260
+ // "fee24H": 1.5716, // todo: check
3261
+ // "markPrice": 3134.97984158,
3262
+ // "estLiqPrice": 3436.176349,
3263
+ // "timestamp": 1720628031.463,
3264
+ // "adlQuantile": 5,
3265
+ // "positionSide": "BOTH",
3266
+ // "marginMode": "ISOLATED",
3267
+ // "isolatedMarginToken": "USDT", // todo: check
3268
+ // "isolatedMarginAmount": 314.62426, // todo: check
3269
+ // "isolatedFrozenLong": 0.0, // todo: check
3270
+ // "isolatedFrozenShort": 0.0, // todo: check
3271
+ // "leverage": 10
3009
3272
  // }
3010
3273
  //
3011
3274
  const contract = this.safeString(position, 'symbol');
@@ -3019,13 +3282,14 @@ export default class woo extends Exchange {
3019
3282
  side = 'short';
3020
3283
  }
3021
3284
  const contractSize = this.safeString(market, 'contractSize');
3022
- const markPrice = this.safeString(position, 'markPrice');
3285
+ const markPrice = this.safeString2(position, 'markPrice', 'mark_price');
3023
3286
  const timestamp = this.safeTimestamp(position, 'timestamp');
3024
- const entryPrice = this.safeString(position, 'averageOpenPrice');
3287
+ const entryPrice = this.safeString2(position, 'averageOpenPrice', 'average_open_price');
3025
3288
  const priceDifference = Precise.stringSub(markPrice, entryPrice);
3026
3289
  const unrealisedPnl = Precise.stringMul(priceDifference, size);
3027
3290
  size = Precise.stringAbs(size);
3028
3291
  const notional = Precise.stringMul(size, markPrice);
3292
+ const positionSide = this.safeString(position, 'positionSide'); // 'SHORT' or 'LONG' for hedged, 'BOTH' for non-hedged
3029
3293
  return this.safePosition({
3030
3294
  'info': position,
3031
3295
  'id': undefined,
@@ -3039,20 +3303,19 @@ export default class woo extends Exchange {
3039
3303
  'maintenanceMarginPercentage': undefined,
3040
3304
  'entryPrice': this.parseNumber(entryPrice),
3041
3305
  'notional': this.parseNumber(notional),
3042
- 'leverage': undefined,
3306
+ 'leverage': this.safeNumber(position, 'leverage'),
3043
3307
  'unrealizedPnl': this.parseNumber(unrealisedPnl),
3044
3308
  'contracts': this.parseNumber(size),
3045
3309
  'contractSize': this.parseNumber(contractSize),
3046
3310
  'marginRatio': undefined,
3047
- 'liquidationPrice': this.safeNumber(position, 'estLiqPrice'),
3311
+ 'liquidationPrice': this.safeNumber2(position, 'estLiqPrice', 'est_liq_price'),
3048
3312
  'markPrice': this.parseNumber(markPrice),
3049
3313
  'lastPrice': undefined,
3050
3314
  'collateral': undefined,
3051
- 'marginMode': 'cross',
3052
- 'marginType': undefined,
3315
+ 'marginMode': this.safeStringLower2(position, 'marginMode', 'margin_mode'),
3053
3316
  'side': side,
3054
3317
  'percentage': undefined,
3055
- 'hedged': undefined,
3318
+ 'hedged': positionSide !== 'BOTH',
3056
3319
  'stopLossPrice': undefined,
3057
3320
  'takeProfitPrice': undefined,
3058
3321
  });
package/js/src/xt.d.ts CHANGED
@@ -37,7 +37,7 @@ export default class xt extends Exchange {
37
37
  cancelOrders(ids: string[], symbol?: string, params?: {}): Promise<Order[]>;
38
38
  parseOrder(order: any, market?: any): Order;
39
39
  parseOrderStatus(status: any): string;
40
- fetchLedger(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
40
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
41
41
  parseLedgerEntry(item: any, currency?: any): {
42
42
  id: string;
43
43
  direction: string;
@@ -73,8 +73,8 @@ export default class xt extends Exchange {
73
73
  network: any;
74
74
  info: any;
75
75
  };
76
- fetchDeposits(code?: string, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
77
- fetchWithdrawals(code?: string, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
76
+ fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
77
+ fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
78
78
  withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
79
79
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
80
80
  parseTransactionStatus(status: any): string;
package/js/src/zonda.d.ts CHANGED
@@ -42,7 +42,7 @@ export default class zonda extends Exchange {
42
42
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
43
43
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
44
44
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
45
- isFiat(currency: any): boolean;
45
+ isFiat(currency: string): boolean;
46
46
  parseDepositAddress(depositAddress: any, currency?: Currency): {
47
47
  currency: string;
48
48
  address: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.62",
3
+ "version": "4.3.64",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",