ccxt 4.2.12 → 4.2.14

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 (81) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1338 -366
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/js/ccxt.js +1 -1
  6. package/dist/cjs/js/src/base/Exchange.js +148 -1
  7. package/dist/cjs/js/src/bigone.js +125 -54
  8. package/dist/cjs/js/src/binance.js +142 -27
  9. package/dist/cjs/js/src/binanceus.js +8 -0
  10. package/dist/cjs/js/src/bingx.js +110 -36
  11. package/dist/cjs/js/src/bitget.js +17 -6
  12. package/dist/cjs/js/src/bitmart.js +3 -3
  13. package/dist/cjs/js/src/bybit.js +5 -1
  14. package/dist/cjs/js/src/coinbase.js +176 -26
  15. package/dist/cjs/js/src/coinex.js +3 -0
  16. package/dist/cjs/js/src/coinlist.js +1 -1
  17. package/dist/cjs/js/src/coinone.js +1 -1
  18. package/dist/cjs/js/src/delta.js +7 -1
  19. package/dist/cjs/js/src/deribit.js +1 -1
  20. package/dist/cjs/js/src/gate.js +79 -56
  21. package/dist/cjs/js/src/gemini.js +1 -1
  22. package/dist/cjs/js/src/htx.js +151 -1
  23. package/dist/cjs/js/src/independentreserve.js +7 -5
  24. package/dist/cjs/js/src/kraken.js +22 -14
  25. package/dist/cjs/js/src/kucoin.js +5 -0
  26. package/dist/cjs/js/src/kucoinfutures.js +131 -77
  27. package/dist/cjs/js/src/lbank.js +59 -33
  28. package/dist/cjs/js/src/oceanex.js +1 -1
  29. package/dist/cjs/js/src/okx.js +11 -9
  30. package/dist/cjs/js/src/phemex.js +9 -2
  31. package/dist/cjs/js/src/pro/kraken.js +1 -1
  32. package/dist/cjs/js/src/pro/okx.js +52 -2
  33. package/dist/cjs/js/src/probit.js +4 -2
  34. package/dist/cjs/js/src/wavesexchange.js +1 -1
  35. package/dist/cjs/js/src/woo.js +56 -2
  36. package/js/ccxt.d.ts +1 -1
  37. package/js/ccxt.js +1 -1
  38. package/js/src/abstract/bigone.d.ts +1 -0
  39. package/js/src/abstract/bingx.d.ts +2 -0
  40. package/js/src/abstract/kucoin.d.ts +4 -0
  41. package/js/src/abstract/kucoinfutures.d.ts +4 -0
  42. package/js/src/abstract/okx.d.ts +1 -0
  43. package/js/src/base/Exchange.d.ts +8 -0
  44. package/js/src/base/Exchange.js +148 -1
  45. package/js/src/bigone.d.ts +2 -0
  46. package/js/src/bigone.js +125 -54
  47. package/js/src/binance.d.ts +9 -0
  48. package/js/src/binance.js +142 -27
  49. package/js/src/binanceus.js +8 -0
  50. package/js/src/bingx.js +110 -36
  51. package/js/src/bitget.js +17 -6
  52. package/js/src/bitmart.js +3 -3
  53. package/js/src/bybit.js +5 -1
  54. package/js/src/coinbase.d.ts +26 -3
  55. package/js/src/coinbase.js +176 -26
  56. package/js/src/coinex.js +3 -0
  57. package/js/src/coinlist.js +1 -1
  58. package/js/src/coinone.js +1 -1
  59. package/js/src/delta.js +7 -1
  60. package/js/src/deribit.js +1 -1
  61. package/js/src/gate.js +79 -56
  62. package/js/src/gemini.js +1 -1
  63. package/js/src/htx.d.ts +10 -0
  64. package/js/src/htx.js +151 -1
  65. package/js/src/independentreserve.js +7 -5
  66. package/js/src/kraken.js +22 -14
  67. package/js/src/kucoin.js +5 -0
  68. package/js/src/kucoinfutures.d.ts +4 -2
  69. package/js/src/kucoinfutures.js +131 -77
  70. package/js/src/lbank.js +59 -33
  71. package/js/src/oceanex.js +1 -1
  72. package/js/src/okx.js +11 -9
  73. package/js/src/phemex.js +9 -2
  74. package/js/src/pro/kraken.js +1 -1
  75. package/js/src/pro/okx.d.ts +1 -0
  76. package/js/src/pro/okx.js +52 -2
  77. package/js/src/probit.js +4 -2
  78. package/js/src/wavesexchange.js +1 -1
  79. package/js/src/woo.d.ts +2 -0
  80. package/js/src/woo.js +56 -2
  81. package/package.json +1 -1
@@ -41,13 +41,16 @@ class htx extends htx$1 {
41
41
  'createMarketBuyOrderWithCost': true,
42
42
  'createMarketOrderWithCost': false,
43
43
  'createMarketSellOrderWithCost': false,
44
- 'createTrailingPercentOrder': true,
45
44
  'createOrder': true,
46
45
  'createOrders': true,
47
46
  'createReduceOnlyOrder': false,
48
47
  'createStopLimitOrder': true,
49
48
  'createStopMarketOrder': true,
50
49
  'createStopOrder': true,
50
+ 'createTrailingPercentOrder': true,
51
+ 'createTriggerOrder': true,
52
+ 'createTakeProfitOrder': true,
53
+ 'createStopLossOrder': true,
51
54
  'fetchAccounts': true,
52
55
  'fetchBalance': true,
53
56
  'fetchBidsAsks': undefined,
@@ -75,6 +78,7 @@ class htx extends htx$1 {
75
78
  'fetchIsolatedBorrowRate': false,
76
79
  'fetchIsolatedBorrowRates': true,
77
80
  'fetchL3OrderBook': undefined,
81
+ 'fetchLastPrices': true,
78
82
  'fetchLedger': true,
79
83
  'fetchLedgerEntry': undefined,
80
84
  'fetchLeverage': false,
@@ -2267,6 +2271,127 @@ class htx extends htx$1 {
2267
2271
  }
2268
2272
  return this.filterByArrayTickers(result, 'symbol', symbols);
2269
2273
  }
2274
+ async fetchLastPrices(symbols = undefined, params = {}) {
2275
+ /**
2276
+ * @method
2277
+ * @name binance#fetchLastPrices
2278
+ * @description fetches the last price for multiple markets
2279
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=8cb81024-77b5-11ed-9966-0242ac110003 linear swap & linear future
2280
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=28c2e8fc-77ae-11ed-9966-0242ac110003 inverse future
2281
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=5d517ef5-77b6-11ed-9966-0242ac110003 inverse swap
2282
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
2283
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2284
+ * @returns {object} a dictionary of lastprices structures
2285
+ */
2286
+ await this.loadMarkets();
2287
+ symbols = this.marketSymbols(symbols);
2288
+ const market = this.getMarketFromSymbols(symbols);
2289
+ let type = undefined;
2290
+ let subType = undefined;
2291
+ [subType, params] = this.handleSubTypeAndParams('fetchLastPrices', market, params);
2292
+ [type, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
2293
+ let response = undefined;
2294
+ if (((type === 'swap') || (type === 'future')) && (subType === 'linear')) {
2295
+ response = await this.contractPublicGetLinearSwapExMarketTrade(params);
2296
+ //
2297
+ // {
2298
+ // "ch": "market.*.trade.detail",
2299
+ // "status": "ok",
2300
+ // "tick": {
2301
+ // "data": [
2302
+ // {
2303
+ // "amount": "4",
2304
+ // "quantity": "40",
2305
+ // "trade_turnover": "22.176",
2306
+ // "ts": 1703697705028,
2307
+ // "id": 1000003558478170000,
2308
+ // "price": "0.5544",
2309
+ // "direction": "buy",
2310
+ // "contract_code": "MANA-USDT",
2311
+ // "business_type": "swap",
2312
+ // "trade_partition": "USDT"
2313
+ // },
2314
+ // ],
2315
+ // "id": 1703697740147,
2316
+ // "ts": 1703697740147
2317
+ // },
2318
+ // "ts": 1703697740147
2319
+ // }
2320
+ //
2321
+ }
2322
+ else if ((type === 'swap') && (subType === 'inverse')) {
2323
+ response = await this.contractPublicGetSwapExMarketTrade(params);
2324
+ //
2325
+ // {
2326
+ // "ch": "market.*.trade.detail",
2327
+ // "status": "ok",
2328
+ // "tick": {
2329
+ // "data": [
2330
+ // {
2331
+ // "amount": "6",
2332
+ // "quantity": "94.5000945000945000945000945000945000945",
2333
+ // "ts": 1703698704594,
2334
+ // "id": 1000001187811060000,
2335
+ // "price": "0.63492",
2336
+ // "direction": "buy",
2337
+ // "contract_code": "XRP-USD"
2338
+ // },
2339
+ // ],
2340
+ // "id": 1703698706589,
2341
+ // "ts": 1703698706589
2342
+ // },
2343
+ // "ts": 1703698706589
2344
+ // }
2345
+ //
2346
+ }
2347
+ else if ((type === 'future') && (subType === 'inverse')) {
2348
+ response = await this.contractPublicGetMarketTrade(params);
2349
+ //
2350
+ // {
2351
+ // "ch": "market.*.trade.detail",
2352
+ // "status": "ok",
2353
+ // "tick": {
2354
+ // "data": [
2355
+ // {
2356
+ // "amount": "20",
2357
+ // "quantity": "44.4444444444444444444444444444444444444",
2358
+ // "ts": 1686134498885,
2359
+ // "id": 2323000000174820000,
2360
+ // "price": "4.5",
2361
+ // "direction": "sell",
2362
+ // "symbol": "DORA_CW"
2363
+ // },
2364
+ // ],
2365
+ // "id": 1703698855142,
2366
+ // "ts": 1703698855142
2367
+ // },
2368
+ // "ts": 1703698855142
2369
+ // }
2370
+ //
2371
+ }
2372
+ else {
2373
+ throw new errors.NotSupported(this.id + ' fetchLastPrices() does not support ' + type + ' markets yet');
2374
+ }
2375
+ const tick = this.safeValue(response, 'tick', {});
2376
+ const data = this.safeValue(tick, 'data', []);
2377
+ return this.parseLastPrices(data, symbols);
2378
+ }
2379
+ parseLastPrice(entry, market = undefined) {
2380
+ // example responses are documented in fetchLastPrices
2381
+ const marketId = this.safeString2(entry, 'symbol', 'contract_code');
2382
+ market = this.safeMarket(marketId, market);
2383
+ const price = this.safeNumber(entry, 'price');
2384
+ const direction = this.safeString(entry, 'direction'); // "buy" or "sell"
2385
+ // group timestamp should not be assigned to the individual trades' times
2386
+ return {
2387
+ 'symbol': market['symbol'],
2388
+ 'timestamp': undefined,
2389
+ 'datetime': undefined,
2390
+ 'price': price,
2391
+ 'side': direction,
2392
+ 'info': entry,
2393
+ };
2394
+ }
2270
2395
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
2271
2396
  /**
2272
2397
  * @method
@@ -4969,6 +5094,31 @@ class htx extends htx$1 {
4969
5094
  params['createMarketBuyOrderRequiresPrice'] = false;
4970
5095
  return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
4971
5096
  }
5097
+ async createTrailingPercentOrder(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
5098
+ /**
5099
+ * @method
5100
+ * @name htx#createTrailingPercentOrder
5101
+ * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
5102
+ * @param {string} symbol unified symbol of the market to create an order in
5103
+ * @param {string} type 'market' or 'limit'
5104
+ * @param {string} side 'buy' or 'sell'
5105
+ * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
5106
+ * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
5107
+ * @param {float} trailingPercent the percent to trail away from the current market price
5108
+ * @param {float} trailingTriggerPrice the price to activate a trailing order, default uses the price argument
5109
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5110
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
5111
+ */
5112
+ if (trailingPercent === undefined) {
5113
+ throw new errors.ArgumentsRequired(this.id + ' createTrailingPercentOrder() requires a trailingPercent argument');
5114
+ }
5115
+ if (trailingTriggerPrice === undefined) {
5116
+ throw new errors.ArgumentsRequired(this.id + ' createTrailingPercentOrder() requires a trailingTriggerPrice argument');
5117
+ }
5118
+ params['trailingPercent'] = trailingPercent;
5119
+ params['trailingTriggerPrice'] = trailingTriggerPrice;
5120
+ return await this.createOrder(symbol, type, side, amount, price, params);
5121
+ }
4972
5122
  async createSpotOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
4973
5123
  /**
4974
5124
  * @method
@@ -683,20 +683,22 @@ class independentreserve extends independentreserve$1 {
683
683
  */
684
684
  await this.loadMarkets();
685
685
  const market = this.market(symbol);
686
- const capitalizedOrderType = this.capitalize(type);
687
- const method = 'privatePostPlace' + capitalizedOrderType + 'Order';
688
- let orderType = capitalizedOrderType;
686
+ let orderType = this.capitalize(type);
689
687
  orderType += (side === 'sell') ? 'Offer' : 'Bid';
690
688
  const request = this.ordered({
691
689
  'primaryCurrencyCode': market['baseId'],
692
690
  'secondaryCurrencyCode': market['quoteId'],
693
691
  'orderType': orderType,
694
692
  });
693
+ let response = undefined;
694
+ request['volume'] = amount;
695
695
  if (type === 'limit') {
696
696
  request['price'] = price;
697
+ response = await this.privatePostPlaceLimitOrder(this.extend(request, params));
698
+ }
699
+ else {
700
+ response = await this.privatePostPlaceMarketOrder(this.extend(request, params));
697
701
  }
698
- request['volume'] = amount;
699
- const response = await this[method](this.extend(request, params));
700
702
  return this.safeOrder({
701
703
  'info': response,
702
704
  'id': response['OrderGuid'],
@@ -38,8 +38,8 @@ class kraken extends kraken$1 {
38
38
  'createOrder': true,
39
39
  'createStopLimitOrder': true,
40
40
  'createStopMarketOrder': true,
41
- 'createTrailingAmountOrder': true,
42
41
  'createStopOrder': true,
42
+ 'createTrailingAmountOrder': true,
43
43
  'editOrder': true,
44
44
  'fetchBalance': true,
45
45
  'fetchBorrowInterest': false,
@@ -1264,12 +1264,8 @@ class kraken extends kraken$1 {
1264
1264
  request['since'] = since * 1e6;
1265
1265
  request['since'] = since.toString() + '000000'; // expected to be in nanoseconds
1266
1266
  }
1267
- // https://github.com/ccxt/ccxt/issues/5698
1268
- if (limit !== undefined && limit !== 1000) {
1269
- const fetchTradesWarning = this.safeValue(this.options, 'fetchTradesWarning', true);
1270
- if (fetchTradesWarning) {
1271
- throw new errors.ExchangeError(this.id + ' fetchTrades() cannot serve ' + limit.toString() + " trades without breaking the pagination, see https://github.com/ccxt/ccxt/issues/5698 for more details. Set exchange.options['fetchTradesWarning'] to acknowledge this warning and silence it.");
1272
- }
1267
+ if (limit !== undefined) {
1268
+ request['count'] = limit;
1273
1269
  }
1274
1270
  const response = await this.publicGetTrades(this.extend(request, params));
1275
1271
  //
@@ -1624,27 +1620,39 @@ class kraken extends kraken$1 {
1624
1620
  const trailingAmount = this.safeString(params, 'trailingAmount');
1625
1621
  const trailingLimitAmount = this.safeString(params, 'trailingLimitAmount');
1626
1622
  const isTrailingAmountOrder = trailingAmount !== undefined;
1627
- if ((type === 'limit') && !isTrailingAmountOrder) {
1623
+ const isLimitOrder = type.endsWith('limit'); // supporting limit, stop-loss-limit, take-profit-limit, etc
1624
+ if (isLimitOrder && !isTrailingAmountOrder) {
1628
1625
  request['price'] = this.priceToPrecision(symbol, price);
1629
1626
  }
1630
- let reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
1627
+ const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
1631
1628
  if (isStopLossOrTakeProfitTrigger) {
1632
1629
  if (isStopLossTriggerOrder) {
1633
1630
  request['price'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
1634
- request['ordertype'] = 'stop-loss-limit';
1631
+ if (isLimitOrder) {
1632
+ request['ordertype'] = 'stop-loss-limit';
1633
+ }
1634
+ else {
1635
+ request['ordertype'] = 'stop-loss';
1636
+ }
1635
1637
  }
1636
1638
  else if (isTakeProfitTriggerOrder) {
1637
1639
  request['price'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
1638
- request['ordertype'] = 'take-profit-limit';
1640
+ if (isLimitOrder) {
1641
+ request['ordertype'] = 'take-profit-limit';
1642
+ }
1643
+ else {
1644
+ request['ordertype'] = 'take-profit';
1645
+ }
1646
+ }
1647
+ if (isLimitOrder) {
1648
+ request['price2'] = this.priceToPrecision(symbol, price);
1639
1649
  }
1640
- request['price2'] = this.priceToPrecision(symbol, price);
1641
- reduceOnly = true;
1642
1650
  }
1643
1651
  else if (isTrailingAmountOrder) {
1644
1652
  const trailingActivationPriceType = this.safeString(params, 'trigger', 'last');
1645
1653
  const trailingAmountString = '+' + trailingAmount;
1646
1654
  request['trigger'] = trailingActivationPriceType;
1647
- if ((type === 'limit') || (trailingLimitAmount !== undefined)) {
1655
+ if (isLimitOrder || (trailingLimitAmount !== undefined)) {
1648
1656
  const offset = this.safeString(params, 'offset', '-');
1649
1657
  const trailingLimitAmountString = offset + this.numberToString(trailingLimitAmount);
1650
1658
  request['price'] = trailingAmountString;
@@ -46,6 +46,7 @@ class kucoin extends kucoin$1 {
46
46
  'createPostOnlyOrder': true,
47
47
  'createStopLimitOrder': true,
48
48
  'createStopMarketOrder': true,
49
+ 'createTriggerOrder': true,
49
50
  'createStopOrder': true,
50
51
  'editOrder': true,
51
52
  'fetchAccounts': true,
@@ -313,6 +314,7 @@ class kucoin extends kucoin$1 {
313
314
  'premium/query': 4.5,
314
315
  'trade-statistics': 4.5,
315
316
  'funding-rate/{symbol}/current': 3,
317
+ 'contract/funding-rates': 7.5,
316
318
  'timestamp': 3,
317
319
  'status': 6,
318
320
  // ?
@@ -342,6 +344,7 @@ class kucoin extends kucoin$1 {
342
344
  'openOrderStatistics': 15,
343
345
  'position': 3,
344
346
  'positions': 3,
347
+ 'margin/maxWithdrawMargin': 15,
345
348
  'contracts/risk-limit/{symbol}': 7.5,
346
349
  'funding-history': 7.5, // 5FW
347
350
  },
@@ -352,7 +355,9 @@ class kucoin extends kucoin$1 {
352
355
  // futures
353
356
  'orders': 3,
354
357
  'orders/test': 3,
358
+ 'orders/multi': 4.5,
355
359
  'position/margin/auto-deposit-status': 6,
360
+ 'margin/withdrawMargin': 15,
356
361
  'position/margin/deposit-margin': 6,
357
362
  'position/risk-limit-level/change': 6,
358
363
  // ws
@@ -33,10 +33,14 @@ class kucoinfutures extends kucoinfutures$1 {
33
33
  'closePositions': false,
34
34
  'createDepositAddress': true,
35
35
  'createOrder': true,
36
+ 'createOrders': true,
36
37
  'createReduceOnlyOrder': true,
37
38
  'createStopLimitOrder': true,
38
39
  'createStopMarketOrder': true,
39
40
  'createStopOrder': true,
41
+ 'createTriggerOrder': true,
42
+ 'createTakeProfitOrder': true,
43
+ 'createStopLossOrder': true,
40
44
  'fetchAccounts': true,
41
45
  'fetchBalance': true,
42
46
  'fetchBorrowRateHistories': false,
@@ -51,7 +55,7 @@ class kucoinfutures extends kucoinfutures$1 {
51
55
  'fetchDepositWithdrawFees': false,
52
56
  'fetchFundingHistory': true,
53
57
  'fetchFundingRate': true,
54
- 'fetchFundingRateHistory': false,
58
+ 'fetchFundingRateHistory': true,
55
59
  'fetchIndexOHLCV': false,
56
60
  'fetchIsolatedBorrowRate': false,
57
61
  'fetchIsolatedBorrowRates': false,
@@ -1112,6 +1116,78 @@ class kucoinfutures extends kucoinfutures$1 {
1112
1116
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1113
1117
  */
1114
1118
  await this.loadMarkets();
1119
+ const market = this.market(symbol);
1120
+ const testOrder = this.safeValue(params, 'test', false);
1121
+ params = this.omit(params, 'test');
1122
+ const orderRequest = this.createContractOrderRequest(symbol, type, side, amount, price, params);
1123
+ let response = undefined;
1124
+ if (testOrder) {
1125
+ response = await this.futuresPrivatePostOrdersTest(orderRequest);
1126
+ }
1127
+ else {
1128
+ response = await this.futuresPrivatePostOrders(orderRequest);
1129
+ }
1130
+ //
1131
+ // {
1132
+ // "code": "200000",
1133
+ // "data": {
1134
+ // "orderId": "619717484f1d010001510cde",
1135
+ // },
1136
+ // }
1137
+ //
1138
+ const data = this.safeValue(response, 'data', {});
1139
+ return this.parseOrder(data, market);
1140
+ }
1141
+ async createOrders(orders, params = {}) {
1142
+ /**
1143
+ * @method
1144
+ * @name kucoinfutures#createOrders
1145
+ * @description create a list of trade orders
1146
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/place-multiple-orders
1147
+ * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
1148
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1149
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1150
+ */
1151
+ await this.loadMarkets();
1152
+ const ordersRequests = [];
1153
+ for (let i = 0; i < orders.length; i++) {
1154
+ const rawOrder = orders[i];
1155
+ const symbol = this.safeString(rawOrder, 'symbol');
1156
+ const market = this.market(symbol);
1157
+ const type = this.safeString(rawOrder, 'type');
1158
+ const side = this.safeString(rawOrder, 'side');
1159
+ const amount = this.safeValue(rawOrder, 'amount');
1160
+ const price = this.safeValue(rawOrder, 'price');
1161
+ const orderParams = this.safeValue(rawOrder, 'params', {});
1162
+ const orderRequest = this.createContractOrderRequest(market['id'], type, side, amount, price, orderParams);
1163
+ ordersRequests.push(orderRequest);
1164
+ }
1165
+ const response = await this.futuresPrivatePostOrdersMulti(ordersRequests);
1166
+ //
1167
+ // {
1168
+ // "code": "200000",
1169
+ // "data": [
1170
+ // {
1171
+ // "orderId": "135241412609331200",
1172
+ // "clientOid": "3d8fcc13-0b13-447f-ad30-4b3441e05213",
1173
+ // "symbol": "LTCUSDTM",
1174
+ // "code": "200000",
1175
+ // "msg": "success"
1176
+ // },
1177
+ // {
1178
+ // "orderId": "135241412747743234",
1179
+ // "clientOid": "b878c7ee-ae3e-4d63-a20b-038acbb7306f",
1180
+ // "symbol": "LTCUSDTM",
1181
+ // "code": "200000",
1182
+ // "msg": "success"
1183
+ // }
1184
+ // ]
1185
+ // }
1186
+ //
1187
+ const data = this.safeValue(response, 'data', []);
1188
+ return this.parseOrders(data);
1189
+ }
1190
+ createContractOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1115
1191
  const market = this.market(symbol);
1116
1192
  // required param, cannot be used twice
1117
1193
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId', this.uuid());
@@ -1184,48 +1260,7 @@ class kucoinfutures extends kucoinfutures$1 {
1184
1260
  }
1185
1261
  }
1186
1262
  params = this.omit(params, ['timeInForce', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']); // Time in force only valid for limit orders, exchange error when gtc for market orders
1187
- let response = undefined;
1188
- const testOrder = this.safeValue(params, 'test', false);
1189
- params = this.omit(params, 'test');
1190
- if (testOrder) {
1191
- response = await this.futuresPrivatePostOrdersTest(this.extend(request, params));
1192
- }
1193
- else {
1194
- response = await this.futuresPrivatePostOrders(this.extend(request, params));
1195
- }
1196
- //
1197
- // {
1198
- // "code": "200000",
1199
- // "data": {
1200
- // "orderId": "619717484f1d010001510cde",
1201
- // },
1202
- // }
1203
- //
1204
- const data = this.safeValue(response, 'data', {});
1205
- return this.safeOrder({
1206
- 'id': this.safeString(data, 'orderId'),
1207
- 'clientOrderId': undefined,
1208
- 'timestamp': undefined,
1209
- 'datetime': undefined,
1210
- 'lastTradeTimestamp': undefined,
1211
- 'symbol': undefined,
1212
- 'type': undefined,
1213
- 'side': undefined,
1214
- 'price': undefined,
1215
- 'amount': undefined,
1216
- 'cost': undefined,
1217
- 'average': undefined,
1218
- 'filled': undefined,
1219
- 'remaining': undefined,
1220
- 'status': undefined,
1221
- 'fee': undefined,
1222
- 'trades': undefined,
1223
- 'timeInForce': undefined,
1224
- 'postOnly': undefined,
1225
- 'stopPrice': undefined,
1226
- 'triggerPrice': undefined,
1227
- 'info': response,
1228
- }, market);
1263
+ return this.extend(request, params);
1229
1264
  }
1230
1265
  async cancelOrder(id, symbol = undefined, params = {}) {
1231
1266
  /**
@@ -1698,10 +1733,26 @@ class kucoinfutures extends kucoinfutures$1 {
1698
1733
  // "reduceOnly": false
1699
1734
  // }
1700
1735
  //
1736
+ // createOrder
1737
+ //
1738
+ // {
1739
+ // "orderId": "619717484f1d010001510cde"
1740
+ // }
1741
+ //
1742
+ // createOrders
1743
+ //
1744
+ // {
1745
+ // "orderId": "80465574458560512",
1746
+ // "clientOid": "5c52e11203aa677f33e491",
1747
+ // "symbol": "ETHUSDTM",
1748
+ // "code": "200000",
1749
+ // "msg": "success"
1750
+ // }
1751
+ //
1701
1752
  const marketId = this.safeString(order, 'symbol');
1702
1753
  market = this.safeMarket(marketId, market);
1703
1754
  const symbol = market['symbol'];
1704
- const orderId = this.safeString(order, 'id');
1755
+ const orderId = this.safeString2(order, 'id', 'orderId');
1705
1756
  const type = this.safeString(order, 'type');
1706
1757
  const timestamp = this.safeInteger(order, 'createdAt');
1707
1758
  const datetime = this.iso8601(timestamp);
@@ -1728,9 +1779,12 @@ class kucoinfutures extends kucoinfutures$1 {
1728
1779
  // precision reported by their api is 8 d.p.
1729
1780
  // const average = Precise.stringDiv (cost, Precise.stringMul (filled, market['contractSize']));
1730
1781
  // bool
1731
- const isActive = this.safeValue(order, 'isActive', false);
1782
+ const isActive = this.safeValue(order, 'isActive');
1732
1783
  const cancelExist = this.safeValue(order, 'cancelExist', false);
1733
- let status = isActive ? 'open' : 'closed';
1784
+ let status = undefined;
1785
+ if (isActive !== undefined) {
1786
+ status = isActive ? 'open' : 'closed';
1787
+ }
1734
1788
  status = cancelExist ? 'canceled' : status;
1735
1789
  let fee = undefined;
1736
1790
  if (feeCost !== undefined) {
@@ -2375,62 +2429,62 @@ class kucoinfutures extends kucoinfutures$1 {
2375
2429
  /**
2376
2430
  * @method
2377
2431
  * @name kucoinfutures#fetchFundingRateHistory
2432
+ * @see https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-public-funding-history#request-url
2378
2433
  * @description fetches historical funding rate prices
2379
2434
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
2380
2435
  * @param {int} [since] not used by kucuoinfutures
2381
2436
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
2382
2437
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2383
- * @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)
2438
+ * @param {int} [params.until] end time in ms
2384
2439
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
2385
2440
  */
2386
2441
  if (symbol === undefined) {
2387
2442
  throw new errors.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
2388
2443
  }
2389
2444
  await this.loadMarkets();
2390
- let paginate = false;
2391
- [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2392
- if (paginate) {
2393
- return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
2394
- }
2395
2445
  const market = this.market(symbol);
2396
2446
  const request = {
2397
2447
  'symbol': market['id'],
2448
+ 'from': 0,
2449
+ 'to': this.milliseconds(),
2398
2450
  };
2399
- if (limit !== undefined) {
2400
- request['maxCount'] = limit;
2451
+ const until = this.safeInteger2(params, 'until', 'till');
2452
+ params = this.omit(params, ['until', 'till']);
2453
+ if (since !== undefined) {
2454
+ request['from'] = since;
2455
+ if (until === undefined) {
2456
+ request['to'] = since + 1000 * 8 * 60 * 60 * 100;
2457
+ }
2458
+ }
2459
+ if (until !== undefined) {
2460
+ request['to'] = until;
2461
+ if (since === undefined) {
2462
+ request['to'] = until - 1000 * 8 * 60 * 60 * 100;
2463
+ }
2401
2464
  }
2402
- const response = await this.webExchangeGetContractSymbolFundingRates(this.extend(request, params));
2465
+ const response = await this.futuresPublicGetContractFundingRates(this.extend(request, params));
2403
2466
  //
2404
- // {
2405
- // "success": true,
2406
- // "code": "200",
2407
- // "msg": "success",
2408
- // "retry": false,
2409
- // "data": {
2410
- // "dataList": [
2411
- // {
2412
- // "symbol": "XBTUSDTM",
2413
- // "granularity": 28800000,
2414
- // "timePoint": 1675108800000,
2415
- // "value": 0.0001
2416
- // },
2417
- // ...
2418
- // ],
2419
- // "hasMore": true
2420
- // }
2421
- // }
2467
+ // {
2468
+ // "code": "200000",
2469
+ // "data": [
2470
+ // {
2471
+ // "symbol": "IDUSDTM",
2472
+ // "fundingRate": 2.26E-4,
2473
+ // "timepoint": 1702296000000
2474
+ // }
2475
+ // ]
2476
+ // }
2422
2477
  //
2423
2478
  const data = this.safeValue(response, 'data');
2424
- const dataList = this.safeValue(data, 'dataList');
2425
- return this.parseFundingRateHistories(dataList, market, since, limit);
2479
+ return this.parseFundingRateHistories(data, market, since, limit);
2426
2480
  }
2427
2481
  parseFundingRateHistory(info, market = undefined) {
2428
- const timestamp = this.safeInteger(info, 'timePoint');
2482
+ const timestamp = this.safeInteger(info, 'timepoint');
2429
2483
  const marketId = this.safeString(info, 'symbol');
2430
2484
  return {
2431
2485
  'info': info,
2432
2486
  'symbol': this.safeSymbol(marketId, market),
2433
- 'fundingRate': this.safeNumber(info, 'value'),
2487
+ 'fundingRate': this.safeNumber(info, 'fundingRate'),
2434
2488
  'timestamp': timestamp,
2435
2489
  'datetime': this.iso8601(timestamp),
2436
2490
  };