ccxt 4.4.31 → 4.4.32

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 (92) hide show
  1. package/README.md +9 -3
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/binance.js +1 -0
  5. package/dist/cjs/src/bitvavo.js +0 -4
  6. package/dist/cjs/src/cex.js +1 -1
  7. package/dist/cjs/src/coincatch.js +3 -3
  8. package/dist/cjs/src/coinex.js +1 -1
  9. package/dist/cjs/src/deribit.js +2 -2
  10. package/dist/cjs/src/gate.js +19 -3
  11. package/dist/cjs/src/hitbtc.js +3 -3
  12. package/dist/cjs/src/htx.js +1 -1
  13. package/dist/cjs/src/indodax.js +1 -1
  14. package/dist/cjs/src/kraken.js +4 -2
  15. package/dist/cjs/src/krakenfutures.js +2 -0
  16. package/dist/cjs/src/kucoin.js +5 -3
  17. package/dist/cjs/src/kucoinfutures.js +98 -27
  18. package/dist/cjs/src/okx.js +2 -2
  19. package/dist/cjs/src/phemex.js +19 -23
  20. package/dist/cjs/src/pro/binance.js +8 -8
  21. package/dist/cjs/src/pro/bitget.js +4 -4
  22. package/dist/cjs/src/pro/bitmart.js +2 -2
  23. package/dist/cjs/src/pro/bitmex.js +2 -2
  24. package/dist/cjs/src/pro/bitvavo.js +46 -48
  25. package/dist/cjs/src/pro/blofin.js +2 -2
  26. package/dist/cjs/src/pro/bybit.js +2 -2
  27. package/dist/cjs/src/pro/coincatch.js +1 -1
  28. package/dist/cjs/src/pro/cryptocom.js +4 -4
  29. package/dist/cjs/src/pro/gate.js +4 -4
  30. package/dist/cjs/src/pro/hashkey.js +3 -3
  31. package/dist/cjs/src/pro/mexc.js +1 -2
  32. package/dist/cjs/src/wavesexchange.js +1 -0
  33. package/dist/cjs/src/woofipro.js +2 -2
  34. package/js/ccxt.d.ts +1 -1
  35. package/js/ccxt.js +1 -1
  36. package/js/src/binance.d.ts +1 -0
  37. package/js/src/binance.js +1 -0
  38. package/js/src/bitvavo.js +0 -4
  39. package/js/src/cex.d.ts +1 -1
  40. package/js/src/cex.js +1 -1
  41. package/js/src/coincatch.d.ts +1 -1
  42. package/js/src/coincatch.js +3 -3
  43. package/js/src/coinex.d.ts +1 -1
  44. package/js/src/coinex.js +1 -1
  45. package/js/src/deribit.d.ts +2 -2
  46. package/js/src/deribit.js +2 -2
  47. package/js/src/gate.d.ts +3 -1
  48. package/js/src/gate.js +19 -3
  49. package/js/src/hitbtc.d.ts +3 -3
  50. package/js/src/hitbtc.js +3 -3
  51. package/js/src/htx.d.ts +1 -1
  52. package/js/src/htx.js +1 -1
  53. package/js/src/indodax.js +1 -1
  54. package/js/src/kraken.d.ts +4 -2
  55. package/js/src/kraken.js +4 -2
  56. package/js/src/krakenfutures.d.ts +2 -0
  57. package/js/src/krakenfutures.js +2 -0
  58. package/js/src/kucoin.d.ts +3 -3
  59. package/js/src/kucoin.js +5 -3
  60. package/js/src/kucoinfutures.d.ts +8 -4
  61. package/js/src/kucoinfutures.js +98 -27
  62. package/js/src/okx.d.ts +2 -2
  63. package/js/src/okx.js +2 -2
  64. package/js/src/phemex.js +19 -23
  65. package/js/src/pro/binance.d.ts +8 -8
  66. package/js/src/pro/binance.js +8 -8
  67. package/js/src/pro/bitget.d.ts +3 -3
  68. package/js/src/pro/bitget.js +4 -4
  69. package/js/src/pro/bitmart.d.ts +2 -2
  70. package/js/src/pro/bitmart.js +2 -2
  71. package/js/src/pro/bitmex.d.ts +2 -2
  72. package/js/src/pro/bitmex.js +2 -2
  73. package/js/src/pro/bitvavo.d.ts +1 -1
  74. package/js/src/pro/bitvavo.js +46 -48
  75. package/js/src/pro/blofin.d.ts +2 -2
  76. package/js/src/pro/blofin.js +2 -2
  77. package/js/src/pro/bybit.d.ts +2 -2
  78. package/js/src/pro/bybit.js +2 -2
  79. package/js/src/pro/coincatch.d.ts +1 -1
  80. package/js/src/pro/coincatch.js +1 -1
  81. package/js/src/pro/cryptocom.d.ts +4 -4
  82. package/js/src/pro/cryptocom.js +4 -4
  83. package/js/src/pro/gate.d.ts +4 -4
  84. package/js/src/pro/gate.js +4 -4
  85. package/js/src/pro/hashkey.d.ts +3 -3
  86. package/js/src/pro/hashkey.js +3 -3
  87. package/js/src/pro/mexc.js +1 -2
  88. package/js/src/wavesexchange.d.ts +1 -0
  89. package/js/src/wavesexchange.js +1 -0
  90. package/js/src/woofipro.d.ts +2 -2
  91. package/js/src/woofipro.js +2 -2
  92. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -197,7 +197,7 @@ var xt$1 = require('./src/pro/xt.js');
197
197
 
198
198
  //-----------------------------------------------------------------------------
199
199
  // this is updated by vss.js when building
200
- const version = '4.4.31';
200
+ const version = '4.4.32';
201
201
  Exchange["default"].ccxtVersion = version;
202
202
  const exchanges = {
203
203
  'ace': ace,
@@ -13393,6 +13393,7 @@ class binance extends binance$1 {
13393
13393
  }
13394
13394
  /**
13395
13395
  * @method
13396
+ * @name binance#fetchMarginAdjustmentHistory
13396
13397
  * @description fetches the history of margin added or reduced from contract isolated positions
13397
13398
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Get-Position-Margin-Change-History
13398
13399
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Get-Position-Margin-Change-History
@@ -1114,10 +1114,6 @@ class bitvavo extends bitvavo$1 {
1114
1114
  if (postOnly) {
1115
1115
  request['postOnly'] = true;
1116
1116
  }
1117
- const clientOrderId = this.safeString(params, 'clientOrderId');
1118
- if (clientOrderId === undefined) {
1119
- request['clientOrderId'] = this.uuid22();
1120
- }
1121
1117
  return this.extend(request, params);
1122
1118
  }
1123
1119
  /**
@@ -860,7 +860,7 @@ class cex extends cex$1 {
860
860
  * @name cex#fetchOrders
861
861
  * @description fetches information on multiple orders made by the user
862
862
  * @see https://trade.cex.io/docs/#rest-private-api-calls-orders
863
- * @param status
863
+ * @param {string} status order status to fetch for
864
864
  * @param {string} symbol unified market symbol of the market orders were made in
865
865
  * @param {int} [since] the earliest time in ms to fetch orders for
866
866
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -2272,7 +2272,7 @@ class coincatch extends coincatch$1 {
2272
2272
  /**
2273
2273
  * @method
2274
2274
  * @ignore
2275
- * @name hashkey#createSpotOrderRequest
2275
+ * @name coincatch#createSpotOrderRequest
2276
2276
  * @description helper function to build request
2277
2277
  * @param {string} symbol unified symbol of the market to create an order in
2278
2278
  * @param {string} type 'market' or 'limit'
@@ -2452,7 +2452,7 @@ class coincatch extends coincatch$1 {
2452
2452
  /**
2453
2453
  * @method
2454
2454
  * @ignore
2455
- * @name hashkey#createSwapOrderRequest
2455
+ * @name coincatch#createSwapOrderRequest
2456
2456
  * @description helper function to build request
2457
2457
  * @param {string} symbol unified symbol of the market to create an order in
2458
2458
  * @param {string} type 'market' or 'limit'
@@ -4619,7 +4619,7 @@ class coincatch extends coincatch$1 {
4619
4619
  }
4620
4620
  /**
4621
4621
  * @method
4622
- * @name hashkey#setLeverage
4622
+ * @name coincatch#setLeverage
4623
4623
  * @description set the level of leverage for a market
4624
4624
  * @see https://hashkeyglobal-apidoc.readme.io/reference/change-futures-leverage-trade
4625
4625
  * @param {float} leverage the rate of leverage
@@ -3390,7 +3390,7 @@ class coinex extends coinex$1 {
3390
3390
  * @see https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
3391
3391
  * @see https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
3392
3392
  * @see https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
3393
- * @param status
3393
+ * @param {string} status order status to fetch for
3394
3394
  * @param {string} symbol unified market symbol of the market orders were made in
3395
3395
  * @param {int} [since] the earliest time in ms to fetch orders for
3396
3396
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -3058,8 +3058,8 @@ class deribit extends deribit$1 {
3058
3058
  * @description fetch the current funding rate
3059
3059
  * @see https://docs.deribit.com/#public-get_funding_rate_history
3060
3060
  * @param {string} symbol unified market symbol
3061
- * @param since
3062
- * @param limit
3061
+ * @param {int} [since] the earliest time in ms to fetch funding rate history for
3062
+ * @param {int} [limit] the maximum number of entries to retrieve
3063
3063
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3064
3064
  * @param {int} [params.end_timestamp] fetch funding rate ending at this timestamp
3065
3065
  * @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)
@@ -897,9 +897,9 @@ class gate extends gate$1 {
897
897
  this.options['sandboxMode'] = enable;
898
898
  }
899
899
  /**
900
- * @param {object} [params] extra parameters specific to the exchange API endpoint
901
900
  * @method
902
901
  * @name gate#isUnifiedEnabled
902
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
903
903
  * @description returns unifiedAccount so the user can check if the unified account is enabled
904
904
  * @see https://www.gate.io/docs/developers/apiv4/#get-account-detail
905
905
  * @returns {boolean} true or false if the enabled unified account is enabled or not and sets the unifiedAccount option if it is undefined
@@ -3138,6 +3138,8 @@ class gate extends gate$1 {
3138
3138
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
3139
3139
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
3140
3140
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3141
+ * @param {int} [params.until] timestamp in ms of the latest funding rate to fetch
3142
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3141
3143
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
3142
3144
  */
3143
3145
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3145,15 +3147,29 @@ class gate extends gate$1 {
3145
3147
  throw new errors.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
3146
3148
  }
3147
3149
  await this.loadMarkets();
3150
+ let paginate = false;
3151
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
3152
+ if (paginate) {
3153
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
3154
+ }
3148
3155
  const market = this.market(symbol);
3149
3156
  if (!market['swap']) {
3150
3157
  throw new errors.BadSymbol(this.id + ' fetchFundingRateHistory() supports swap contracts only');
3151
3158
  }
3152
- const [request, query] = this.prepareRequest(market, undefined, params);
3159
+ let request = {};
3160
+ [request, params] = this.prepareRequest(market, undefined, params);
3153
3161
  if (limit !== undefined) {
3154
3162
  request['limit'] = limit;
3155
3163
  }
3156
- const response = await this.publicFuturesGetSettleFundingRate(this.extend(request, query));
3164
+ if (since !== undefined) {
3165
+ request['from'] = this.parseToInt(since / 1000);
3166
+ }
3167
+ const until = this.safeInteger(params, 'until');
3168
+ if (until !== undefined) {
3169
+ params = this.omit(params, 'until');
3170
+ request['to'] = this.parseToInt(until / 1000);
3171
+ }
3172
+ const response = await this.publicFuturesGetSettleFundingRate(this.extend(request, params));
3157
3173
  //
3158
3174
  // {
3159
3175
  // "r": "0.00063521",
@@ -1556,7 +1556,7 @@ class hitbtc extends hitbtc$1 {
1556
1556
  * @name hitbtc#fetchOrderBooks
1557
1557
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
1558
1558
  * @see https://api.hitbtc.com/#order-books
1559
- * @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
1559
+ * @param {string[]} [symbols] list of unified market symbols, all symbols fetched if undefined, default is undefined
1560
1560
  * @param {int} [limit] max number of entries per orderbook to return, default is undefined
1561
1561
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1562
1562
  * @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbol
@@ -3577,8 +3577,8 @@ class hitbtc extends hitbtc$1 {
3577
3577
  * @name hitbtc#closePosition
3578
3578
  * @description closes open positions for a market
3579
3579
  * @see https://api.hitbtc.com/#close-all-futures-margin-positions
3580
- * @param symbol
3581
- * @param side
3580
+ * @param {string} symbol unified ccxt market symbol
3581
+ * @param {string} side 'buy' or 'sell'
3582
3582
  * @param {object} [params] extra parameters specific to the okx api endpoint
3583
3583
  * @param {string} [params.symbol] *required* unified market symbol
3584
3584
  * @param {string} [params.marginMode] 'cross' or 'isolated', default is 'cross'
@@ -3212,7 +3212,7 @@ class htx extends htx$1 {
3212
3212
  * @see https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
3213
3213
  * @param {string} type 'spot', 'swap' or 'future
3214
3214
  * @param {string} [marginMode] 'cross' or 'isolated'
3215
- * @param symbol
3215
+ * @param {string} [symbol] unified ccxt market symbol
3216
3216
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3217
3217
  * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
3218
3218
  */
@@ -20,7 +20,7 @@ class indodax extends indodax$1 {
20
20
  'countries': ['ID'],
21
21
  // 10 requests per second for making trades => 1000ms / 10 = 100ms
22
22
  // 180 requests per minute (public endpoints) = 2 requests per second => cost = (1000ms / rateLimit) / 2 = 5
23
- 'rateLimit': 100,
23
+ 'rateLimit': 50,
24
24
  'has': {
25
25
  'CORS': undefined,
26
26
  'spot': true,
@@ -2144,8 +2144,8 @@ class kraken extends kraken$1 {
2144
2144
  * @name kraken#fetchOrdersByIds
2145
2145
  * @description fetch orders by the list of order id
2146
2146
  * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
2147
- * @param {string[]|undefined} ids list of order id
2148
- * @param symbol
2147
+ * @param {string[]} [ids] list of order id
2148
+ * @param {string} [symbol] unified ccxt market symbol
2149
2149
  * @param {object} [params] extra parameters specific to the kraken api endpoint
2150
2150
  * @returns {object[]} a list of [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2151
2151
  */
@@ -3068,6 +3068,8 @@ class kraken extends kraken$1 {
3068
3068
  return this.safeString(accountByType, account, account);
3069
3069
  }
3070
3070
  /**
3071
+ * @method
3072
+ * @name kraken#transferOut
3071
3073
  * @description transfer from spot wallet to futures wallet
3072
3074
  * @see https://docs.kraken.com/rest/#tag/User-Funding/operation/walletTransfer
3073
3075
  * @param {str} code Unified currency code
@@ -2574,6 +2574,8 @@ class krakenfutures extends krakenfutures$1 {
2574
2574
  }
2575
2575
  }
2576
2576
  /**
2577
+ * @method
2578
+ * @name krakenfutures#transferOut
2577
2579
  * @description transfer from futures wallet to spot wallet
2578
2580
  * @param {str} code Unified currency code
2579
2581
  * @param {float} amount Size of the transfer
@@ -571,6 +571,8 @@ class kucoin extends kucoin$1 {
571
571
  '400303': errors.PermissionDenied,
572
572
  '500000': errors.ExchangeNotAvailable,
573
573
  '260220': errors.InvalidAddress,
574
+ '600100': errors.InsufficientFunds,
575
+ '600101': errors.InvalidOrder,
574
576
  '900014': errors.BadRequest, // {"code":"900014","msg":"Invalid chainId"}
575
577
  },
576
578
  'broad': {
@@ -1228,9 +1230,9 @@ class kucoin extends kucoin$1 {
1228
1230
  return result;
1229
1231
  }
1230
1232
  /**
1231
- * @param force
1232
1233
  * @method
1233
1234
  * @name kucoin#loadMigrationStatus
1235
+ * @param {boolean} force load account state for non hf
1234
1236
  * @description loads the migration status for the account (hf or not)
1235
1237
  * @see https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/get-user-type
1236
1238
  */
@@ -4947,8 +4949,8 @@ class kucoin extends kucoin$1 {
4947
4949
  * @name kucoin#setLeverage
4948
4950
  * @description set the level of leverage for a market
4949
4951
  * @see https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/modify-leverage-multiplier
4950
- * @param leverage
4951
- * @param {string} symbol unified market symbol
4952
+ * @param {int } [leverage] New leverage multiplier. Must be greater than 1 and up to two decimal places, and cannot be less than the user's current debt leverage or greater than the system's maximum leverage
4953
+ * @param {string} [symbol] unified market symbol
4952
4954
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4953
4955
  * @returns {object} response from the exchange
4954
4956
  */
@@ -1223,8 +1223,8 @@ class kucoinfutures extends kucoinfutures$1 {
1223
1223
  * @description fetches historical positions
1224
1224
  * @see https://www.kucoin.com/docs/rest/futures-trading/positions/get-positions-history
1225
1225
  * @param {string[]} [symbols] list of unified market symbols
1226
- * @param since
1227
- * @param limit
1226
+ * @param {int} [since] the earliest time in ms to fetch position history for
1227
+ * @param {int} [limit] the maximum number of entries to retrieve
1228
1228
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1229
1229
  * @param {int} [params.until] closing end time
1230
1230
  * @param {int} [params.pageId] page id
@@ -1426,7 +1426,7 @@ class kucoinfutures extends kucoinfutures$1 {
1426
1426
  * @method
1427
1427
  * @name kucoinfutures#createOrder
1428
1428
  * @description Create an order on the exchange
1429
- * @see https://docs.kucoin.com/futures/#place-an-order
1429
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/place-order
1430
1430
  * @see https://www.kucoin.com/docs/rest/futures-trading/orders/place-take-profit-and-stop-loss-order#http-request
1431
1431
  * @param {string} symbol Unified CCXT market symbol
1432
1432
  * @param {string} type 'limit' or 'market'
@@ -1442,6 +1442,7 @@ class kucoinfutures extends kucoinfutures$1 {
1442
1442
  * @param {bool} [params.reduceOnly] A mark to reduce the position size only. Set to false by default. Need to set the position size when reduceOnly is true.
1443
1443
  * @param {string} [params.timeInForce] GTC, GTT, IOC, or FOK, default is GTC, limit orders only
1444
1444
  * @param {string} [params.postOnly] Post only flag, invalid when timeInForce is IOC or FOK
1445
+ * @param {float} [params.cost] the cost of the order in units of USDT
1445
1446
  * ----------------- Exchange Specific Parameters -----------------
1446
1447
  * @param {float} [params.leverage] Leverage size of the order
1447
1448
  * @param {string} [params.clientOid] client order id, defaults to uuid if not passed
@@ -1537,18 +1538,24 @@ class kucoinfutures extends kucoinfutures$1 {
1537
1538
  // required param, cannot be used twice
1538
1539
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId', this.uuid());
1539
1540
  params = this.omit(params, ['clientOid', 'clientOrderId']);
1540
- if (amount < 1) {
1541
- throw new errors.InvalidOrder(this.id + ' createOrder() minimum contract order amount is 1');
1542
- }
1543
- const preciseAmount = parseInt(this.amountToPrecision(symbol, amount));
1544
1541
  const request = {
1545
1542
  'clientOid': clientOrderId,
1546
1543
  'side': side,
1547
1544
  'symbol': market['id'],
1548
1545
  'type': type,
1549
- 'size': preciseAmount,
1550
1546
  'leverage': 1,
1551
1547
  };
1548
+ const cost = this.safeString(params, 'cost');
1549
+ params = this.omit(params, 'cost');
1550
+ if (cost !== undefined) {
1551
+ request['valueQty'] = this.costToPrecision(symbol, cost);
1552
+ }
1553
+ else {
1554
+ if (amount < 1) {
1555
+ throw new errors.InvalidOrder(this.id + ' createOrder() minimum contract order amount is 1');
1556
+ }
1557
+ request['size'] = parseInt(this.amountToPrecision(symbol, amount));
1558
+ }
1552
1559
  const [triggerPrice, stopLossPrice, takeProfitPrice] = this.handleTriggerPrices(params);
1553
1560
  const stopLoss = this.safeDict(params, 'stopLoss');
1554
1561
  const takeProfit = this.safeDict(params, 'takeProfit');
@@ -2423,6 +2430,8 @@ class kucoinfutures extends kucoinfutures$1 {
2423
2430
  * @method
2424
2431
  * @name kucoinfutures#transfer
2425
2432
  * @description transfer currency internally between wallets on the same account
2433
+ * @see https://www.kucoin.com/docs/rest/funding/transfer/transfer-to-main-or-trade-account
2434
+ * @see https://www.kucoin.com/docs/rest/funding/transfer/transfer-to-futures-account
2426
2435
  * @param {string} code unified currency code
2427
2436
  * @param {float} amount amount to transfer
2428
2437
  * @param {string} fromAccount account to transfer from
@@ -2431,9 +2440,6 @@ class kucoinfutures extends kucoinfutures$1 {
2431
2440
  * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
2432
2441
  */
2433
2442
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
2434
- if ((toAccount !== 'main' && toAccount !== 'funding') || (fromAccount !== 'futures' && fromAccount !== 'future' && fromAccount !== 'contract')) {
2435
- throw new errors.BadRequest(this.id + ' transfer() only supports transfers from contract(future) account to main(funding) account');
2436
- }
2437
2443
  await this.loadMarkets();
2438
2444
  const currency = this.currency(code);
2439
2445
  const amountToPrecision = this.currencyToPrecision(code, amount);
@@ -2441,38 +2447,95 @@ class kucoinfutures extends kucoinfutures$1 {
2441
2447
  'currency': this.safeString(currency, 'id'),
2442
2448
  'amount': amountToPrecision,
2443
2449
  };
2444
- // transfer from usdm futures wallet to spot wallet
2445
- const response = await this.futuresPrivatePostTransferOut(this.extend(request, params));
2446
- //
2447
- // {
2448
- // "code": "200000",
2449
- // "data": {
2450
- // "applyId": "5bffb63303aa675e8bbe18f9" // Transfer-out request ID
2451
- // }
2452
- // }
2453
- //
2454
- const data = this.safeValue(response, 'data');
2450
+ const toAccountString = this.parseTransferType(toAccount);
2451
+ let response = undefined;
2452
+ if (toAccountString === 'TRADE' || toAccountString === 'MAIN') {
2453
+ request['recAccountType'] = toAccountString;
2454
+ response = await this.futuresPrivatePostTransferOut(this.extend(request, params));
2455
+ //
2456
+ // {
2457
+ // "code": "200000",
2458
+ // "data": {
2459
+ // "applyId": "6738754373ceee00011ec3f8",
2460
+ // "bizNo": "6738754373ceee00011ec3f7",
2461
+ // "payAccountType": "CONTRACT",
2462
+ // "payTag": "DEFAULT",
2463
+ // "remark": "",
2464
+ // "recAccountType": "MAIN",
2465
+ // "recTag": "DEFAULT",
2466
+ // "recRemark": "",
2467
+ // "recSystem": "KUCOIN",
2468
+ // "status": "PROCESSING",
2469
+ // "currency": "USDT",
2470
+ // "amount": "5",
2471
+ // "fee": "0",
2472
+ // "sn": 1519769124846692,
2473
+ // "reason": "",
2474
+ // "createdAt": 1731753283000,
2475
+ // "updatedAt": 1731753283000
2476
+ // }
2477
+ // }
2478
+ //
2479
+ }
2480
+ else if (toAccount === 'future' || toAccount === 'swap' || toAccount === 'contract') {
2481
+ request['payAccountType'] = this.parseTransferType(fromAccount);
2482
+ response = await this.futuresPrivatePostTransferIn(this.extend(request, params));
2483
+ //
2484
+ // {
2485
+ // "code": "200000",
2486
+ // "data": {
2487
+ // "applyId": "5bffb63303aa675e8bbe18f9" // Transfer-out request ID
2488
+ // }
2489
+ // }
2490
+ //
2491
+ }
2492
+ else {
2493
+ throw new errors.BadRequest(this.id + ' transfer() only supports transfers between future/swap, spot and funding accounts');
2494
+ }
2495
+ const data = this.safeDict(response, 'data', {});
2455
2496
  return this.extend(this.parseTransfer(data, currency), {
2456
2497
  'amount': this.parseNumber(amountToPrecision),
2457
- 'fromAccount': 'future',
2458
- 'toAccount': 'spot',
2498
+ 'fromAccount': fromAccount,
2499
+ 'toAccount': toAccount,
2459
2500
  });
2460
2501
  }
2461
2502
  parseTransfer(transfer, currency = undefined) {
2462
2503
  //
2463
- // transfer
2504
+ // transfer to spot or funding account
2464
2505
  //
2465
2506
  // {
2466
2507
  // "applyId": "5bffb63303aa675e8bbe18f9" // Transfer-out request ID
2467
2508
  // }
2468
2509
  //
2510
+ // transfer to future account
2511
+ //
2512
+ // {
2513
+ // "applyId": "6738754373ceee00011ec3f8",
2514
+ // "bizNo": "6738754373ceee00011ec3f7",
2515
+ // "payAccountType": "CONTRACT",
2516
+ // "payTag": "DEFAULT",
2517
+ // "remark": "",
2518
+ // "recAccountType": "MAIN",
2519
+ // "recTag": "DEFAULT",
2520
+ // "recRemark": "",
2521
+ // "recSystem": "KUCOIN",
2522
+ // "status": "PROCESSING",
2523
+ // "currency": "USDT",
2524
+ // "amount": "5",
2525
+ // "fee": "0",
2526
+ // "sn": 1519769124846692,
2527
+ // "reason": "",
2528
+ // "createdAt": 1731753283000,
2529
+ // "updatedAt": 1731753283000
2530
+ // }
2531
+ //
2469
2532
  const timestamp = this.safeInteger(transfer, 'updatedAt');
2470
2533
  return {
2471
2534
  'id': this.safeString(transfer, 'applyId'),
2472
2535
  'timestamp': timestamp,
2473
2536
  'datetime': this.iso8601(timestamp),
2474
2537
  'currency': this.safeCurrencyCode(undefined, currency),
2475
- 'amount': undefined,
2538
+ 'amount': this.safeNumber(transfer, 'amount'),
2476
2539
  'fromAccount': undefined,
2477
2540
  'toAccount': undefined,
2478
2541
  'status': this.safeString(transfer, 'status'),
@@ -2485,6 +2548,13 @@ class kucoinfutures extends kucoinfutures$1 {
2485
2548
  };
2486
2549
  return this.safeString(statuses, status, status);
2487
2550
  }
2551
+ parseTransferType(transferType) {
2552
+ const transferTypes = {
2553
+ 'spot': 'TRADE',
2554
+ 'funding': 'MAIN',
2555
+ };
2556
+ return this.safeStringUpper(transferTypes, transferType, transferType);
2557
+ }
2488
2558
  /**
2489
2559
  * @method
2490
2560
  * @name kucoinfutures#fetchMyTrades
@@ -2886,6 +2956,7 @@ class kucoinfutures extends kucoinfutures$1 {
2886
2956
  /**
2887
2957
  * @ignore
2888
2958
  * @method
2959
+ * @name kucoinfutures#parseMarketLeverageTiers
2889
2960
  * @param {object} info Exchange market response for 1 market
2890
2961
  * @param {object} market CCXT market
2891
2962
  */
@@ -3127,7 +3198,7 @@ class kucoinfutures extends kucoinfutures$1 {
3127
3198
  }
3128
3199
  /**
3129
3200
  * @method
3130
- * @name kucoin#fetchLeverage
3201
+ * @name kucoinfutures#fetchLeverage
3131
3202
  * @description fetch the set leverage for a market
3132
3203
  * @see https://www.kucoin.com/docs/rest/futures-trading/positions/get-cross-margin-leverage
3133
3204
  * @param {string} symbol unified market symbol
@@ -8329,8 +8329,8 @@ class okx extends okx$1 {
8329
8329
  * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-3-months
8330
8330
  * @param {string} [symbol] not used by okx fetchMarginAdjustmentHistory
8331
8331
  * @param {string} [type] "add" or "reduce"
8332
- * @param since
8333
- * @param limit
8332
+ * @param {int} [since] the earliest time in ms to fetch margin adjustment history for
8333
+ * @param {int} [limit] the maximum number of entries to retrieve
8334
8334
  * @param {object} params extra parameters specific to the exchange api endpoint
8335
8335
  * @param {boolean} [params.auto] true if fetching auto margin increases
8336
8336
  * @returns {object[]} a list of [margin structures]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
@@ -488,6 +488,13 @@ class phemex extends phemex$1 {
488
488
  'transfer': {
489
489
  'fillResponseFromRequest': true,
490
490
  },
491
+ 'triggerPriceTypesMap': {
492
+ 'last': 'ByLastPrice',
493
+ 'mark': 'ByMarkPrice',
494
+ 'index': 'ByIndexPrice',
495
+ 'ask': 'ByAskPrice',
496
+ 'bid': 'ByBidPrice',
497
+ },
491
498
  },
492
499
  });
493
500
  }
@@ -2137,6 +2144,7 @@ class phemex extends phemex$1 {
2137
2144
  'PartiallyFilled': 'open',
2138
2145
  'Filled': 'closed',
2139
2146
  'Canceled': 'canceled',
2147
+ 'Suspended': 'canceled',
2140
2148
  '1': 'open',
2141
2149
  '2': 'canceled',
2142
2150
  '3': 'closed',
@@ -2643,17 +2651,11 @@ class phemex extends phemex$1 {
2643
2651
  }
2644
2652
  const stopLossTriggerPriceType = this.safeString2(stopLoss, 'triggerPriceType', 'slTrigger');
2645
2653
  if (stopLossTriggerPriceType !== undefined) {
2646
- if (market['settle'] === 'USDT') {
2647
- if ((stopLossTriggerPriceType !== 'ByMarkPrice') && (stopLossTriggerPriceType !== 'ByLastPrice') && (stopLossTriggerPriceType !== 'ByIndexPrice') && (stopLossTriggerPriceType !== 'ByAskPrice') && (stopLossTriggerPriceType !== 'ByBidPrice') && (stopLossTriggerPriceType !== 'ByMarkPriceLimit') && (stopLossTriggerPriceType !== 'ByLastPriceLimit')) {
2648
- throw new errors.InvalidOrder(this.id + ' createOrder() take profit trigger price type must be one of "ByMarkPrice", "ByIndexPrice", "ByAskPrice", "ByBidPrice", "ByMarkPriceLimit", "ByLastPriceLimit" or "ByLastPrice"');
2649
- }
2650
- }
2651
- else {
2652
- if ((stopLossTriggerPriceType !== 'ByMarkPrice') && (stopLossTriggerPriceType !== 'ByLastPrice')) {
2653
- throw new errors.InvalidOrder(this.id + ' createOrder() take profit trigger price type must be one of "ByMarkPrice", or "ByLastPrice"');
2654
- }
2655
- }
2656
- request['slTrigger'] = stopLossTriggerPriceType;
2654
+ request['slTrigger'] = this.safeString(this.options['triggerPriceTypesMap'], stopLossTriggerPriceType, stopLossTriggerPriceType);
2655
+ }
2656
+ const slLimitPrice = this.safeString(stopLoss, 'price');
2657
+ if (slLimitPrice !== undefined) {
2658
+ request['slPxRp'] = this.priceToPrecision(symbol, slLimitPrice);
2657
2659
  }
2658
2660
  }
2659
2661
  if (takeProfitDefined) {
@@ -2667,19 +2669,13 @@ class phemex extends phemex$1 {
2667
2669
  else {
2668
2670
  request['takeProfitEp'] = this.toEp(takeProfitTriggerPrice, market);
2669
2671
  }
2670
- const takeProfitTriggerPriceType = this.safeString2(stopLoss, 'triggerPriceType', 'tpTrigger');
2672
+ const takeProfitTriggerPriceType = this.safeString2(takeProfit, 'triggerPriceType', 'tpTrigger');
2671
2673
  if (takeProfitTriggerPriceType !== undefined) {
2672
- if (market['settle'] === 'USDT') {
2673
- if ((takeProfitTriggerPriceType !== 'ByMarkPrice') && (takeProfitTriggerPriceType !== 'ByLastPrice') && (takeProfitTriggerPriceType !== 'ByIndexPrice') && (takeProfitTriggerPriceType !== 'ByAskPrice') && (takeProfitTriggerPriceType !== 'ByBidPrice') && (takeProfitTriggerPriceType !== 'ByMarkPriceLimit') && (takeProfitTriggerPriceType !== 'ByLastPriceLimit')) {
2674
- throw new errors.InvalidOrder(this.id + ' createOrder() take profit trigger price type must be one of "ByMarkPrice", "ByIndexPrice", "ByAskPrice", "ByBidPrice", "ByMarkPriceLimit", "ByLastPriceLimit" or "ByLastPrice"');
2675
- }
2676
- }
2677
- else {
2678
- if ((takeProfitTriggerPriceType !== 'ByMarkPrice') && (takeProfitTriggerPriceType !== 'ByLastPrice')) {
2679
- throw new errors.InvalidOrder(this.id + ' createOrder() take profit trigger price type must be one of "ByMarkPrice", or "ByLastPrice"');
2680
- }
2681
- }
2682
- request['tpTrigger'] = takeProfitTriggerPriceType;
2674
+ request['tpTrigger'] = this.safeString(this.options['triggerPriceTypesMap'], takeProfitTriggerPriceType, takeProfitTriggerPriceType);
2675
+ }
2676
+ const tpLimitPrice = this.safeString(takeProfit, 'price');
2677
+ if (tpLimitPrice !== undefined) {
2678
+ request['tpPxRp'] = this.priceToPrecision(symbol, tpLimitPrice);
2683
2679
  }
2684
2680
  }
2685
2681
  }
@@ -218,7 +218,7 @@ class binance extends binance$1 {
218
218
  * @description watch the public liquidations of a trading pair
219
219
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/websocket-market-streams/All-Market-Liquidation-Order-Streams
220
220
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/websocket-market-streams/All-Market-Liquidation-Order-Streams
221
- * @param {string[]} symbols
221
+ * @param {string[]} symbols list of unified market symbols
222
222
  * @param {int} [since] the earliest time in ms to fetch liquidations for
223
223
  * @param {int} [limit] the maximum number of liquidation structures to retrieve
224
224
  * @param {object} [params] exchange specific parameters for the bitmex api endpoint
@@ -439,7 +439,7 @@ class binance extends binance$1 {
439
439
  * @description watch the private liquidations of a trading pair
440
440
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/user-data-streams/Event-Order-Update
441
441
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/user-data-streams/Event-Order-Update
442
- * @param symbols
442
+ * @param {string[]} symbols list of unified market symbols
443
443
  * @param {int} [since] the earliest time in ms to fetch liquidations for
444
444
  * @param {int} [limit] the maximum number of liquidation structures to retrieve
445
445
  * @param {object} [params] exchange specific parameters for the bitmex api endpoint
@@ -3170,7 +3170,7 @@ class binance extends binance$1 {
3170
3170
  * @see https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#cancel-order-trade
3171
3171
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Cancel-Order
3172
3172
  * @param {string} id order id
3173
- * @param {string} symbol unified market symbol, default is undefined
3173
+ * @param {string} [symbol] unified market symbol, default is undefined
3174
3174
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3175
3175
  * @param {string|undefined} [params.cancelRestrictions] Supported values: ONLY_NEW - Cancel will succeed if the order status is NEW. ONLY_PARTIALLY_FILLED - Cancel will succeed if order status is PARTIALLY_FILLED.
3176
3176
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -3214,7 +3214,7 @@ class binance extends binance$1 {
3214
3214
  * @name binance#cancelAllOrdersWs
3215
3215
  * @description cancel all open orders in a market
3216
3216
  * @see https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#cancel-open-orders-trade
3217
- * @param {string} symbol unified market symbol of the market to cancel orders in
3217
+ * @param {string} [symbol] unified market symbol of the market to cancel orders in
3218
3218
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3219
3219
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
3220
3220
  */
@@ -3251,8 +3251,8 @@ class binance extends binance$1 {
3251
3251
  * @see https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#query-order-user_data
3252
3252
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/websocket-api/Query-Order
3253
3253
  * @param {string} id order id
3254
- * @param {string} symbol unified symbol of the market the order was made in
3255
- * @param {object} params extra parameters specific to the exchange API endpoint
3254
+ * @param {string} [symbol] unified symbol of the market the order was made in
3255
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3256
3256
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3257
3257
  */
3258
3258
  async fetchOrderWs(id, symbol = undefined, params = {}) {
@@ -3702,8 +3702,8 @@ class binance extends binance$1 {
3702
3702
  * @name binance#watchPositions
3703
3703
  * @description watch all open positions
3704
3704
  * @param {string[]|undefined} symbols list of unified market symbols
3705
- * @param since
3706
- * @param limit
3705
+ * @param {number} [since] since timestamp
3706
+ * @param {number} [limit] limit
3707
3707
  * @param {object} params extra parameters specific to the exchange API endpoint
3708
3708
  * @param {boolean} [params.portfolioMargin] set to true if you would like to watch positions in a portfolio margin account
3709
3709
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}