ccxt 4.3.61 → 4.3.63

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 (104) 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/base/Exchange.js +8 -1
  6. package/dist/cjs/src/base/errors.js +8 -1
  7. package/dist/cjs/src/binance.js +50 -43
  8. package/dist/cjs/src/bingx.js +507 -184
  9. package/dist/cjs/src/bybit.js +1 -1
  10. package/dist/cjs/src/cryptocom.js +18 -2
  11. package/dist/cjs/src/mercado.js +5 -1
  12. package/dist/cjs/src/pro/alpaca.js +3 -3
  13. package/dist/cjs/src/pro/binance.js +60 -38
  14. package/dist/cjs/src/pro/bingx.js +2 -2
  15. package/dist/cjs/src/pro/bitfinex2.js +8 -5
  16. package/dist/cjs/src/pro/bitget.js +5 -2
  17. package/dist/cjs/src/pro/bitmex.js +1 -1
  18. package/dist/cjs/src/pro/bitopro.js +1 -1
  19. package/dist/cjs/src/pro/bitvavo.js +1 -1
  20. package/dist/cjs/src/pro/bybit.js +49 -23
  21. package/dist/cjs/src/pro/coinbaseexchange.js +2 -2
  22. package/dist/cjs/src/pro/coincheck.js +1 -1
  23. package/dist/cjs/src/pro/coinone.js +1 -1
  24. package/dist/cjs/src/pro/cryptocom.js +8 -2
  25. package/dist/cjs/src/pro/deribit.js +1 -1
  26. package/dist/cjs/src/pro/gate.js +8 -4
  27. package/dist/cjs/src/pro/hollaex.js +1 -1
  28. package/dist/cjs/src/pro/htx.js +6 -2
  29. package/dist/cjs/src/pro/hyperliquid.js +3 -3
  30. package/dist/cjs/src/pro/independentreserve.js +5 -3
  31. package/dist/cjs/src/pro/kraken.js +83 -5
  32. package/dist/cjs/src/pro/kucoin.js +1 -1
  33. package/dist/cjs/src/pro/mexc.js +1 -1
  34. package/dist/cjs/src/pro/okx.js +4 -4
  35. package/dist/cjs/src/pro/oxfun.js +1 -1
  36. package/dist/cjs/src/pro/phemex.js +1 -1
  37. package/dist/cjs/src/pro/poloniexfutures.js +5 -1
  38. package/dist/cjs/src/pro/upbit.js +1 -1
  39. package/dist/cjs/src/pro/vertex.js +2 -2
  40. package/dist/cjs/src/pro/whitebit.js +1 -1
  41. package/dist/cjs/src/pro/woo.js +1 -1
  42. package/dist/cjs/src/pro/woofipro.js +1 -1
  43. package/dist/cjs/src/tradeogre.js +1 -1
  44. package/dist/cjs/src/woo.js +313 -81
  45. package/dist/cjs/src/xt.js +1 -1
  46. package/js/ccxt.d.ts +3 -3
  47. package/js/ccxt.js +3 -3
  48. package/js/src/abstract/cryptocom.d.ts +11 -0
  49. package/js/src/abstract/woo.d.ts +3 -0
  50. package/js/src/ace.js +34 -15
  51. package/js/src/base/Exchange.d.ts +1 -0
  52. package/js/src/base/Exchange.js +8 -1
  53. package/js/src/base/errorHierarchy.d.ts +3 -1
  54. package/js/src/base/errorHierarchy.js +3 -1
  55. package/js/src/base/errors.d.ts +5 -1
  56. package/js/src/base/errors.js +8 -2
  57. package/js/src/base/ws/Client.d.ts +1 -1
  58. package/js/src/binance.js +50 -43
  59. package/js/src/bingx.d.ts +1 -0
  60. package/js/src/bingx.js +507 -184
  61. package/js/src/bybit.js +1 -1
  62. package/js/src/coinbaseinternational.d.ts +1 -1
  63. package/js/src/cryptocom.js +18 -2
  64. package/js/src/mercado.js +5 -1
  65. package/js/src/pro/alpaca.js +3 -3
  66. package/js/src/pro/binance.d.ts +1 -0
  67. package/js/src/pro/binance.js +61 -39
  68. package/js/src/pro/bingx.js +2 -2
  69. package/js/src/pro/bitfinex2.js +9 -6
  70. package/js/src/pro/bitget.js +6 -3
  71. package/js/src/pro/bitmex.js +1 -1
  72. package/js/src/pro/bitopro.js +1 -1
  73. package/js/src/pro/bitvavo.js +1 -1
  74. package/js/src/pro/bybit.d.ts +1 -0
  75. package/js/src/pro/bybit.js +49 -23
  76. package/js/src/pro/coinbaseexchange.js +2 -2
  77. package/js/src/pro/coincheck.js +1 -1
  78. package/js/src/pro/coinone.js +1 -1
  79. package/js/src/pro/cryptocom.js +9 -3
  80. package/js/src/pro/deribit.js +1 -1
  81. package/js/src/pro/gate.js +9 -5
  82. package/js/src/pro/hollaex.js +1 -1
  83. package/js/src/pro/htx.js +7 -3
  84. package/js/src/pro/hyperliquid.js +3 -3
  85. package/js/src/pro/independentreserve.js +6 -4
  86. package/js/src/pro/kraken.d.ts +3 -1
  87. package/js/src/pro/kraken.js +84 -6
  88. package/js/src/pro/kucoin.js +1 -1
  89. package/js/src/pro/mexc.js +1 -1
  90. package/js/src/pro/okx.js +5 -5
  91. package/js/src/pro/oxfun.js +1 -1
  92. package/js/src/pro/phemex.js +1 -1
  93. package/js/src/pro/poloniexfutures.js +6 -2
  94. package/js/src/pro/upbit.js +1 -1
  95. package/js/src/pro/vertex.js +2 -2
  96. package/js/src/pro/whitebit.js +1 -1
  97. package/js/src/pro/woo.js +1 -1
  98. package/js/src/pro/woofipro.js +1 -1
  99. package/js/src/tradeogre.js +1 -1
  100. package/js/src/woo.d.ts +5 -1
  101. package/js/src/woo.js +313 -81
  102. package/js/src/xt.d.ts +3 -3
  103. package/js/src/xt.js +1 -1
  104. package/package.json +1 -1
package/js/src/woo.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/woo.js';
2
- import type { TransferEntry, Balances, Conversion, Currency, FundingRateHistory, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Dict, Strings, Trade, Transaction, Leverage, Account, Currencies, TradingFees, TransferEntries, int } from './base/types.js';
2
+ import type { TransferEntry, Balances, Conversion, Currency, FundingRateHistory, Int, Market, MarginModification, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Dict, Strings, Trade, Transaction, Leverage, Account, Currencies, TradingFees, TransferEntries, int } from './base/types.js';
3
3
  /**
4
4
  * @class woo
5
5
  * @augments Exchange
@@ -26,6 +26,7 @@ export default class woo extends Exchange {
26
26
  createTrailingAmountOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, trailingAmount?: any, trailingTriggerPrice?: any, params?: {}): Promise<Order>;
27
27
  createTrailingPercentOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, trailingPercent?: any, trailingTriggerPrice?: any, params?: {}): Promise<Order>;
28
28
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
29
+ encodeMarginMode(mode: any): string;
29
30
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
30
31
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
31
32
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
@@ -163,6 +164,9 @@ export default class woo extends Exchange {
163
164
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
164
165
  parseLeverage(leverage: Dict, market?: Market): Leverage;
165
166
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
167
+ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
168
+ reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
169
+ modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
166
170
  fetchPosition(symbol?: Str, params?: {}): Promise<import("./base/types.js").Position>;
167
171
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
168
172
  parsePosition(position: Dict, market?: Market): import("./base/types.js").Position;
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
@@ -2882,61 +2899,204 @@ export default class woo extends Exchange {
2882
2899
  * @see https://docs.woo.org/#get-account-information-new
2883
2900
  * @param {string} symbol unified market symbol
2884
2901
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2902
+ * @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated'
2903
+ * @param {string} [params.position_mode] *for swap markets only* 'ONE_WAY' or 'HEDGE_MODE'
2885
2904
  * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2886
2905
  */
2887
2906
  await this.loadMarkets();
2888
2907
  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
- //
2908
+ let response = undefined;
2909
+ if (market['spot']) {
2910
+ response = await this.v3PrivateGetAccountinfo(params);
2911
+ //
2912
+ // {
2913
+ // "success": true,
2914
+ // "data": {
2915
+ // "applicationId": "dsa",
2916
+ // "account": "dsa",
2917
+ // "alias": "haha",
2918
+ // "accountMode": "MARGIN",
2919
+ // "leverage": 1,
2920
+ // "takerFeeRate": 1,
2921
+ // "makerFeeRate": 1,
2922
+ // "interestRate": 1,
2923
+ // "futuresTakerFeeRate": 1,
2924
+ // "futuresMakerFeeRate": 1,
2925
+ // "otpauth": true,
2926
+ // "marginRatio": 1,
2927
+ // "openMarginRatio": 1,
2928
+ // "initialMarginRatio": 1,
2929
+ // "maintenanceMarginRatio": 1,
2930
+ // "totalCollateral": 1,
2931
+ // "freeCollateral": 1,
2932
+ // "totalAccountValue": 1,
2933
+ // "totalVaultValue": 1,
2934
+ // "totalStakingValue": 1
2935
+ // },
2936
+ // "timestamp": 1673323685109
2937
+ // }
2938
+ //
2939
+ }
2940
+ else if (market['swap']) {
2941
+ const request = {
2942
+ 'symbol': market['id'],
2943
+ };
2944
+ let marginMode = undefined;
2945
+ [marginMode, params] = this.handleMarginModeAndParams('fetchLeverage', params, 'cross');
2946
+ request['margin_mode'] = this.encodeMarginMode(marginMode);
2947
+ response = await this.v1PrivateGetClientFuturesLeverage(this.extend(request, params));
2948
+ //
2949
+ // HEDGE_MODE
2950
+ // {
2951
+ // "success": true,
2952
+ // "data":
2953
+ // {
2954
+ // "symbol": "PERP_ETH_USDT",
2955
+ // "default_margin_mode": "CROSS",
2956
+ // "position_mode": "HEDGE_MODE",
2957
+ // "details": [
2958
+ // {
2959
+ // "position_side": "LONG",
2960
+ // "leverage": 10
2961
+ // },
2962
+ // {
2963
+ // "position_side": "SHORT",
2964
+ // "leverage": 10
2965
+ // }
2966
+ // ]
2967
+ // },
2968
+ // "timestamp": 1720886470482
2969
+ // }
2970
+ //
2971
+ // ONE_WAY
2972
+ // {
2973
+ // "success": true,
2974
+ // "data": {
2975
+ // "symbol": "PERP_ETH_USDT",
2976
+ // "default_margin_mode": "ISOLATED",
2977
+ // "position_mode": "ONE_WAY",
2978
+ // "details": [
2979
+ // {
2980
+ // "position_side": "BOTH",
2981
+ // "leverage": 10
2982
+ // }
2983
+ // ]
2984
+ // },
2985
+ // "timestamp": 1720886810317
2986
+ // }
2987
+ //
2988
+ }
2989
+ else {
2990
+ throw new NotSupported(this.id + ' fetchLeverage() is not supported for ' + market['type'] + ' markets');
2991
+ }
2918
2992
  const data = this.safeDict(response, 'data', {});
2919
2993
  return this.parseLeverage(data, market);
2920
2994
  }
2921
2995
  parseLeverage(leverage, market = undefined) {
2922
- const leverageValue = this.safeInteger(leverage, 'leverage');
2996
+ const marketId = this.safeString(leverage, 'symbol');
2997
+ market = this.safeMarket(marketId, market);
2998
+ const marginMode = this.safeStringLower(leverage, 'default_margin_mode');
2999
+ const spotLeverage = this.safeInteger(leverage, 'leverage');
3000
+ let longLeverage = spotLeverage;
3001
+ let shortLeverage = spotLeverage;
3002
+ const details = this.safeList(leverage, 'details', []);
3003
+ for (let i = 0; i < details.length; i++) {
3004
+ const position = this.safeDict(details, i, {});
3005
+ const positionLeverage = this.safeInteger(position, 'leverage');
3006
+ const side = this.safeString(position, 'position_side');
3007
+ if (side === 'BOTH') {
3008
+ longLeverage = positionLeverage;
3009
+ shortLeverage = positionLeverage;
3010
+ }
3011
+ else if (side === 'LONG') {
3012
+ longLeverage = positionLeverage;
3013
+ }
3014
+ else if (side === 'SHORT') {
3015
+ shortLeverage = positionLeverage;
3016
+ }
3017
+ }
2923
3018
  return {
2924
3019
  'info': leverage,
2925
3020
  'symbol': market['symbol'],
2926
- 'marginMode': undefined,
2927
- 'longLeverage': leverageValue,
2928
- 'shortLeverage': leverageValue,
3021
+ 'marginMode': marginMode,
3022
+ 'longLeverage': longLeverage,
3023
+ 'shortLeverage': shortLeverage,
2929
3024
  };
2930
3025
  }
2931
3026
  async setLeverage(leverage, symbol = undefined, params = {}) {
3027
+ /**
3028
+ * @method
3029
+ * @name woo#setLeverage
3030
+ * @description set the level of leverage for a market
3031
+ * @see https://docs.woo.org/#update-leverage-setting
3032
+ * @see https://docs.woo.org/#update-futures-leverage-setting
3033
+ * @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)
3034
+ * @param {string} [symbo] unified market symbol (is mandatory for swap markets)
3035
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3036
+ * @param {string} [params.marginMode] *for swap markets only* 'cross' or 'isolated'
3037
+ * @param {string} [params.position_side] *for swap markets only* 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode.
3038
+ * @returns {object} response from the exchange
3039
+ */
2932
3040
  await this.loadMarkets();
2933
- if ((leverage < 1) || (leverage > 20)) {
2934
- throw new BadRequest(this.id + ' leverage should be between 1 and 20');
2935
- }
2936
3041
  const request = {
2937
3042
  'leverage': leverage,
2938
3043
  };
2939
- return await this.v1PrivatePostClientLeverage(this.extend(request, params));
3044
+ let market = undefined;
3045
+ if (symbol !== undefined) {
3046
+ market = this.market(symbol);
3047
+ }
3048
+ if ((symbol === undefined) || market['spot']) {
3049
+ return await this.v1PrivatePostClientLeverage(this.extend(request, params));
3050
+ }
3051
+ else if (market['swap']) {
3052
+ request['symbol'] = market['id'];
3053
+ let marginMode = undefined;
3054
+ [marginMode, params] = this.handleMarginModeAndParams('fetchLeverage', params, 'cross');
3055
+ request['margin_mode'] = this.encodeMarginMode(marginMode);
3056
+ return await this.v1PrivatePostClientFuturesLeverage(this.extend(request, params));
3057
+ }
3058
+ else {
3059
+ throw new NotSupported(this.id + ' fetchLeverage() is not supported for ' + market['type'] + ' markets');
3060
+ }
3061
+ }
3062
+ async addMargin(symbol, amount, params = {}) {
3063
+ /**
3064
+ * @method
3065
+ * @name woo#addMargin
3066
+ * @description add margin
3067
+ * @see https://docs.woo.org/#update-isolated-margin-setting
3068
+ * @param {string} symbol unified market symbol
3069
+ * @param {float} amount amount of margin to add
3070
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3071
+ * @param {string} [params.position_side] 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
3072
+ * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
3073
+ */
3074
+ return await this.modifyMarginHelper(symbol, amount, 'ADD', params);
3075
+ }
3076
+ async reduceMargin(symbol, amount, params = {}) {
3077
+ /**
3078
+ * @method
3079
+ * @name woo#reduceMargin
3080
+ * @description remove margin from a position
3081
+ * @see https://docs.woo.org/#update-isolated-margin-setting
3082
+ * @param {string} symbol unified market symbol
3083
+ * @param {float} amount amount of margin to remove
3084
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3085
+ * @param {string} [params.position_side] 'LONG' or 'SHORT' in hedge mode, 'BOTH' in one way mode
3086
+ * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
3087
+ */
3088
+ return await this.modifyMarginHelper(symbol, amount, 'REDUCE', params);
3089
+ }
3090
+ async modifyMarginHelper(symbol, amount, type, params = {}) {
3091
+ await this.loadMarkets();
3092
+ const market = this.market(symbol);
3093
+ const request = {
3094
+ 'symbol': market['id'],
3095
+ 'adjust_token': 'USDT',
3096
+ 'adjust_amount': amount,
3097
+ 'action': type,
3098
+ };
3099
+ return await this.v1PrivatePostClientIsolatedMargin(this.extend(request, params));
2940
3100
  }
2941
3101
  async fetchPosition(symbol = undefined, params = {}) {
2942
3102
  await this.loadMarkets();
@@ -2947,17 +3107,26 @@ export default class woo extends Exchange {
2947
3107
  const response = await this.v1PrivateGetPositionSymbol(this.extend(request, params));
2948
3108
  //
2949
3109
  // {
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"
3110
+ // "symbol": "PERP_ETH_USDT",
3111
+ // "position_side": "BOTH",
3112
+ // "leverage": 10,
3113
+ // "margin_mode": "CROSS",
3114
+ // "average_open_price": 3139.9,
3115
+ // "isolated_margin_amount": 0.0,
3116
+ // "isolated_margin_token": "",
3117
+ // "opening_time": "1720627963.094",
3118
+ // "mark_price": 3155.19169891,
3119
+ // "pending_short_qty": 0.0,
3120
+ // "pending_long_qty": 0.0,
3121
+ // "holding": -0.7,
3122
+ // "pnl_24_h": 0.0,
3123
+ // "est_liq_price": 9107.40055552,
3124
+ // "settle_price": 3151.0319904,
3125
+ // "success": true,
3126
+ // "fee_24_h": 0.0,
3127
+ // "isolated_frozen_long": 0.0,
3128
+ // "isolated_frozen_short": 0.0,
3129
+ // "timestamp": "1720867502.544"
2961
3130
  // }
2962
3131
  //
2963
3132
  return this.parsePosition(response, market);
@@ -2968,24 +3137,54 @@ export default class woo extends Exchange {
2968
3137
  //
2969
3138
  // {
2970
3139
  // "success": true,
2971
- // "data": {
3140
+ // "data":
3141
+ // {
2972
3142
  // "positions": [
2973
3143
  // {
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
3144
+ // "symbol": "PERP_ETH_USDT",
3145
+ // "holding": -1.0,
3146
+ // "pendingLongQty": 0.0,
3147
+ // "pendingShortQty": 0.0,
3148
+ // "settlePrice": 3143.2,
3149
+ // "averageOpenPrice": 3143.2,
3150
+ // "pnl24H": 0.0,
3151
+ // "fee24H": 1.5716,
3152
+ // "markPrice": 3134.97984158,
3153
+ // "estLiqPrice": 3436.176349,
3154
+ // "timestamp": 1720628031.463,
3155
+ // "adlQuantile": 5,
3156
+ // "positionSide": "BOTH",
3157
+ // "marginMode": "ISOLATED",
3158
+ // "isolatedMarginToken": "USDT",
3159
+ // "isolatedMarginAmount": 314.62426,
3160
+ // "isolatedFrozenLong": 0.0,
3161
+ // "isolatedFrozenShort": 0.0,
3162
+ // "leverage": 10
3163
+ // },
3164
+ // {
3165
+ // "symbol": "PERP_SOL_USDT",
3166
+ // "holding": -1.0,
3167
+ // "pendingLongQty": 0.0,
3168
+ // "pendingShortQty": 0.0,
3169
+ // "settlePrice": 141.89933923,
3170
+ // "averageOpenPrice": 171.38,
3171
+ // "pnl24H": 0.0,
3172
+ // "fee24H": 0.0,
3173
+ // "markPrice": 141.65155427,
3174
+ // "estLiqPrice": 4242.73548551,
3175
+ // "timestamp": 1720616702.68,
3176
+ // "adlQuantile": 5,
3177
+ // "positionSide": "BOTH",
3178
+ // "marginMode": "CROSS",
3179
+ // "isolatedMarginToken": "",
3180
+ // "isolatedMarginAmount": 0.0,
3181
+ // "isolatedFrozenLong": 0.0,
3182
+ // "isolatedFrozenShort": 0.0,
3183
+ // "leverage": 10
2985
3184
  // }
2986
3185
  // ]
2987
3186
  // },
2988
- // "timestamp": 1673323880342
3187
+ // "timestamp": 1720628675078
2989
3188
  // }
2990
3189
  //
2991
3190
  const result = this.safeDict(response, 'data', {});
@@ -2994,18 +3193,51 @@ export default class woo extends Exchange {
2994
3193
  }
2995
3194
  parsePosition(position, market = undefined) {
2996
3195
  //
3196
+ // v1PrivateGetPositionSymbol
3197
+ // {
3198
+ // "symbol": "PERP_ETH_USDT",
3199
+ // "position_side": "BOTH",
3200
+ // "leverage": 10,
3201
+ // "margin_mode": "CROSS",
3202
+ // "average_open_price": 3139.9,
3203
+ // "isolated_margin_amount": 0.0,
3204
+ // "isolated_margin_token": "",
3205
+ // "opening_time": "1720627963.094",
3206
+ // "mark_price": 3155.19169891,
3207
+ // "pending_short_qty": 0.0,
3208
+ // "pending_long_qty": 0.0,
3209
+ // "holding": -0.7,
3210
+ // "pnl_24_h": 0.0,
3211
+ // "est_liq_price": 9107.40055552,
3212
+ // "settle_price": 3151.0319904,
3213
+ // "success": true,
3214
+ // "fee_24_h": 0.0,
3215
+ // "isolated_frozen_long": 0.0,
3216
+ // "isolated_frozen_short": 0.0,
3217
+ // "timestamp": "1720867502.544"
3218
+ // }
3219
+ //
3220
+ // v3PrivateGetPositions
2997
3221
  // {
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
3222
+ // "symbol": "PERP_ETH_USDT",
3223
+ // "holding": -1.0,
3224
+ // "pendingLongQty": 0.0, // todo: check
3225
+ // "pendingShortQty": 0.0, // todo: check
3226
+ // "settlePrice": 3143.2,
3227
+ // "averageOpenPrice": 3143.2,
3228
+ // "pnl24H": 0.0, // todo: check
3229
+ // "fee24H": 1.5716, // todo: check
3230
+ // "markPrice": 3134.97984158,
3231
+ // "estLiqPrice": 3436.176349,
3232
+ // "timestamp": 1720628031.463,
3233
+ // "adlQuantile": 5,
3234
+ // "positionSide": "BOTH",
3235
+ // "marginMode": "ISOLATED",
3236
+ // "isolatedMarginToken": "USDT", // todo: check
3237
+ // "isolatedMarginAmount": 314.62426, // todo: check
3238
+ // "isolatedFrozenLong": 0.0, // todo: check
3239
+ // "isolatedFrozenShort": 0.0, // todo: check
3240
+ // "leverage": 10
3009
3241
  // }
3010
3242
  //
3011
3243
  const contract = this.safeString(position, 'symbol');
@@ -3019,13 +3251,14 @@ export default class woo extends Exchange {
3019
3251
  side = 'short';
3020
3252
  }
3021
3253
  const contractSize = this.safeString(market, 'contractSize');
3022
- const markPrice = this.safeString(position, 'markPrice');
3254
+ const markPrice = this.safeString2(position, 'markPrice', 'mark_price');
3023
3255
  const timestamp = this.safeTimestamp(position, 'timestamp');
3024
- const entryPrice = this.safeString(position, 'averageOpenPrice');
3256
+ const entryPrice = this.safeString2(position, 'averageOpenPrice', 'average_open_price');
3025
3257
  const priceDifference = Precise.stringSub(markPrice, entryPrice);
3026
3258
  const unrealisedPnl = Precise.stringMul(priceDifference, size);
3027
3259
  size = Precise.stringAbs(size);
3028
3260
  const notional = Precise.stringMul(size, markPrice);
3261
+ const positionSide = this.safeString(position, 'positionSide'); // 'SHORT' or 'LONG' for hedged, 'BOTH' for non-hedged
3029
3262
  return this.safePosition({
3030
3263
  'info': position,
3031
3264
  'id': undefined,
@@ -3039,20 +3272,19 @@ export default class woo extends Exchange {
3039
3272
  'maintenanceMarginPercentage': undefined,
3040
3273
  'entryPrice': this.parseNumber(entryPrice),
3041
3274
  'notional': this.parseNumber(notional),
3042
- 'leverage': undefined,
3275
+ 'leverage': this.safeNumber(position, 'leverage'),
3043
3276
  'unrealizedPnl': this.parseNumber(unrealisedPnl),
3044
3277
  'contracts': this.parseNumber(size),
3045
3278
  'contractSize': this.parseNumber(contractSize),
3046
3279
  'marginRatio': undefined,
3047
- 'liquidationPrice': this.safeNumber(position, 'estLiqPrice'),
3280
+ 'liquidationPrice': this.safeNumber2(position, 'estLiqPrice', 'est_liq_price'),
3048
3281
  'markPrice': this.parseNumber(markPrice),
3049
3282
  'lastPrice': undefined,
3050
3283
  'collateral': undefined,
3051
- 'marginMode': 'cross',
3052
- 'marginType': undefined,
3284
+ 'marginMode': this.safeStringLower2(position, 'marginMode', 'margin_mode'),
3053
3285
  'side': side,
3054
3286
  'percentage': undefined,
3055
- 'hedged': undefined,
3287
+ 'hedged': positionSide !== 'BOTH',
3056
3288
  'stopLossPrice': undefined,
3057
3289
  'takeProfitPrice': undefined,
3058
3290
  });
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/xt.js CHANGED
@@ -4784,7 +4784,7 @@ export default class xt extends Exchange {
4784
4784
  if (isUndefinedBody) {
4785
4785
  if (urlencoded) {
4786
4786
  url += '?' + urlencoded;
4787
- payloadString += '#' + method + '#' + payload + '#' + urlencoded;
4787
+ payloadString += '#' + method + '#' + payload + '#' + this.rawencode(this.keysort(query));
4788
4788
  }
4789
4789
  else {
4790
4790
  payloadString += '#' + method + '#' + payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.61",
3
+ "version": "4.3.63",
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",