ccxt 4.2.13 → 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 (47) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +624 -130
  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 +36 -32
  8. package/dist/cjs/js/src/binance.js +108 -0
  9. package/dist/cjs/js/src/binanceus.js +8 -0
  10. package/dist/cjs/js/src/bingx.js +4 -0
  11. package/dist/cjs/js/src/bitget.js +4 -0
  12. package/dist/cjs/js/src/bybit.js +4 -0
  13. package/dist/cjs/js/src/coinex.js +3 -0
  14. package/dist/cjs/js/src/delta.js +7 -1
  15. package/dist/cjs/js/src/gate.js +5 -0
  16. package/dist/cjs/js/src/htx.js +126 -1
  17. package/dist/cjs/js/src/kraken.js +19 -7
  18. package/dist/cjs/js/src/kucoin.js +5 -0
  19. package/dist/cjs/js/src/kucoinfutures.js +131 -77
  20. package/dist/cjs/js/src/okx.js +9 -8
  21. package/dist/cjs/js/src/woo.js +6 -2
  22. package/js/ccxt.d.ts +1 -1
  23. package/js/ccxt.js +1 -1
  24. package/js/src/abstract/bigone.d.ts +1 -0
  25. package/js/src/abstract/kucoin.d.ts +4 -0
  26. package/js/src/abstract/kucoinfutures.d.ts +4 -0
  27. package/js/src/base/Exchange.d.ts +8 -0
  28. package/js/src/base/Exchange.js +148 -1
  29. package/js/src/bigone.js +36 -32
  30. package/js/src/binance.d.ts +9 -0
  31. package/js/src/binance.js +108 -0
  32. package/js/src/binanceus.js +8 -0
  33. package/js/src/bingx.js +4 -0
  34. package/js/src/bitget.js +4 -0
  35. package/js/src/bybit.js +4 -0
  36. package/js/src/coinex.js +3 -0
  37. package/js/src/delta.js +7 -1
  38. package/js/src/gate.js +5 -0
  39. package/js/src/htx.d.ts +9 -0
  40. package/js/src/htx.js +126 -1
  41. package/js/src/kraken.js +19 -7
  42. package/js/src/kucoin.js +5 -0
  43. package/js/src/kucoinfutures.d.ts +4 -2
  44. package/js/src/kucoinfutures.js +131 -77
  45. package/js/src/okx.js +9 -8
  46. package/js/src/woo.js +6 -2
  47. package/package.json +1 -1
package/js/src/htx.js CHANGED
@@ -51,6 +51,9 @@ export default class htx extends Exchange {
51
51
  'createStopMarketOrder': true,
52
52
  'createStopOrder': true,
53
53
  'createTrailingPercentOrder': true,
54
+ 'createTriggerOrder': true,
55
+ 'createTakeProfitOrder': true,
56
+ 'createStopLossOrder': true,
54
57
  'fetchAccounts': true,
55
58
  'fetchBalance': true,
56
59
  'fetchBidsAsks': undefined,
@@ -78,6 +81,7 @@ export default class htx extends Exchange {
78
81
  'fetchIsolatedBorrowRate': false,
79
82
  'fetchIsolatedBorrowRates': true,
80
83
  'fetchL3OrderBook': undefined,
84
+ 'fetchLastPrices': true,
81
85
  'fetchLedger': true,
82
86
  'fetchLedgerEntry': undefined,
83
87
  'fetchLeverage': false,
@@ -2270,6 +2274,127 @@ export default class htx extends Exchange {
2270
2274
  }
2271
2275
  return this.filterByArrayTickers(result, 'symbol', symbols);
2272
2276
  }
2277
+ async fetchLastPrices(symbols = undefined, params = {}) {
2278
+ /**
2279
+ * @method
2280
+ * @name binance#fetchLastPrices
2281
+ * @description fetches the last price for multiple markets
2282
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=8cb81024-77b5-11ed-9966-0242ac110003 linear swap & linear future
2283
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=28c2e8fc-77ae-11ed-9966-0242ac110003 inverse future
2284
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=5d517ef5-77b6-11ed-9966-0242ac110003 inverse swap
2285
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
2286
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2287
+ * @returns {object} a dictionary of lastprices structures
2288
+ */
2289
+ await this.loadMarkets();
2290
+ symbols = this.marketSymbols(symbols);
2291
+ const market = this.getMarketFromSymbols(symbols);
2292
+ let type = undefined;
2293
+ let subType = undefined;
2294
+ [subType, params] = this.handleSubTypeAndParams('fetchLastPrices', market, params);
2295
+ [type, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
2296
+ let response = undefined;
2297
+ if (((type === 'swap') || (type === 'future')) && (subType === 'linear')) {
2298
+ response = await this.contractPublicGetLinearSwapExMarketTrade(params);
2299
+ //
2300
+ // {
2301
+ // "ch": "market.*.trade.detail",
2302
+ // "status": "ok",
2303
+ // "tick": {
2304
+ // "data": [
2305
+ // {
2306
+ // "amount": "4",
2307
+ // "quantity": "40",
2308
+ // "trade_turnover": "22.176",
2309
+ // "ts": 1703697705028,
2310
+ // "id": 1000003558478170000,
2311
+ // "price": "0.5544",
2312
+ // "direction": "buy",
2313
+ // "contract_code": "MANA-USDT",
2314
+ // "business_type": "swap",
2315
+ // "trade_partition": "USDT"
2316
+ // },
2317
+ // ],
2318
+ // "id": 1703697740147,
2319
+ // "ts": 1703697740147
2320
+ // },
2321
+ // "ts": 1703697740147
2322
+ // }
2323
+ //
2324
+ }
2325
+ else if ((type === 'swap') && (subType === 'inverse')) {
2326
+ response = await this.contractPublicGetSwapExMarketTrade(params);
2327
+ //
2328
+ // {
2329
+ // "ch": "market.*.trade.detail",
2330
+ // "status": "ok",
2331
+ // "tick": {
2332
+ // "data": [
2333
+ // {
2334
+ // "amount": "6",
2335
+ // "quantity": "94.5000945000945000945000945000945000945",
2336
+ // "ts": 1703698704594,
2337
+ // "id": 1000001187811060000,
2338
+ // "price": "0.63492",
2339
+ // "direction": "buy",
2340
+ // "contract_code": "XRP-USD"
2341
+ // },
2342
+ // ],
2343
+ // "id": 1703698706589,
2344
+ // "ts": 1703698706589
2345
+ // },
2346
+ // "ts": 1703698706589
2347
+ // }
2348
+ //
2349
+ }
2350
+ else if ((type === 'future') && (subType === 'inverse')) {
2351
+ response = await this.contractPublicGetMarketTrade(params);
2352
+ //
2353
+ // {
2354
+ // "ch": "market.*.trade.detail",
2355
+ // "status": "ok",
2356
+ // "tick": {
2357
+ // "data": [
2358
+ // {
2359
+ // "amount": "20",
2360
+ // "quantity": "44.4444444444444444444444444444444444444",
2361
+ // "ts": 1686134498885,
2362
+ // "id": 2323000000174820000,
2363
+ // "price": "4.5",
2364
+ // "direction": "sell",
2365
+ // "symbol": "DORA_CW"
2366
+ // },
2367
+ // ],
2368
+ // "id": 1703698855142,
2369
+ // "ts": 1703698855142
2370
+ // },
2371
+ // "ts": 1703698855142
2372
+ // }
2373
+ //
2374
+ }
2375
+ else {
2376
+ throw new NotSupported(this.id + ' fetchLastPrices() does not support ' + type + ' markets yet');
2377
+ }
2378
+ const tick = this.safeValue(response, 'tick', {});
2379
+ const data = this.safeValue(tick, 'data', []);
2380
+ return this.parseLastPrices(data, symbols);
2381
+ }
2382
+ parseLastPrice(entry, market = undefined) {
2383
+ // example responses are documented in fetchLastPrices
2384
+ const marketId = this.safeString2(entry, 'symbol', 'contract_code');
2385
+ market = this.safeMarket(marketId, market);
2386
+ const price = this.safeNumber(entry, 'price');
2387
+ const direction = this.safeString(entry, 'direction'); // "buy" or "sell"
2388
+ // group timestamp should not be assigned to the individual trades' times
2389
+ return {
2390
+ 'symbol': market['symbol'],
2391
+ 'timestamp': undefined,
2392
+ 'datetime': undefined,
2393
+ 'price': price,
2394
+ 'side': direction,
2395
+ 'info': entry,
2396
+ };
2397
+ }
2273
2398
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
2274
2399
  /**
2275
2400
  * @method
@@ -4975,7 +5100,7 @@ export default class htx extends Exchange {
4975
5100
  async createTrailingPercentOrder(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
4976
5101
  /**
4977
5102
  * @method
4978
- * @name createTrailingPercentOrder
5103
+ * @name htx#createTrailingPercentOrder
4979
5104
  * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
4980
5105
  * @param {string} symbol unified symbol of the market to create an order in
4981
5106
  * @param {string} type 'market' or 'limit'
package/js/src/kraken.js CHANGED
@@ -1623,27 +1623,39 @@ export default class kraken extends Exchange {
1623
1623
  const trailingAmount = this.safeString(params, 'trailingAmount');
1624
1624
  const trailingLimitAmount = this.safeString(params, 'trailingLimitAmount');
1625
1625
  const isTrailingAmountOrder = trailingAmount !== undefined;
1626
- if ((type === 'limit') && !isTrailingAmountOrder) {
1626
+ const isLimitOrder = type.endsWith('limit'); // supporting limit, stop-loss-limit, take-profit-limit, etc
1627
+ if (isLimitOrder && !isTrailingAmountOrder) {
1627
1628
  request['price'] = this.priceToPrecision(symbol, price);
1628
1629
  }
1629
- let reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
1630
+ const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
1630
1631
  if (isStopLossOrTakeProfitTrigger) {
1631
1632
  if (isStopLossTriggerOrder) {
1632
1633
  request['price'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
1633
- request['ordertype'] = 'stop-loss-limit';
1634
+ if (isLimitOrder) {
1635
+ request['ordertype'] = 'stop-loss-limit';
1636
+ }
1637
+ else {
1638
+ request['ordertype'] = 'stop-loss';
1639
+ }
1634
1640
  }
1635
1641
  else if (isTakeProfitTriggerOrder) {
1636
1642
  request['price'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
1637
- request['ordertype'] = 'take-profit-limit';
1643
+ if (isLimitOrder) {
1644
+ request['ordertype'] = 'take-profit-limit';
1645
+ }
1646
+ else {
1647
+ request['ordertype'] = 'take-profit';
1648
+ }
1649
+ }
1650
+ if (isLimitOrder) {
1651
+ request['price2'] = this.priceToPrecision(symbol, price);
1638
1652
  }
1639
- request['price2'] = this.priceToPrecision(symbol, price);
1640
- reduceOnly = true;
1641
1653
  }
1642
1654
  else if (isTrailingAmountOrder) {
1643
1655
  const trailingActivationPriceType = this.safeString(params, 'trigger', 'last');
1644
1656
  const trailingAmountString = '+' + trailingAmount;
1645
1657
  request['trigger'] = trailingActivationPriceType;
1646
- if ((type === 'limit') || (trailingLimitAmount !== undefined)) {
1658
+ if (isLimitOrder || (trailingLimitAmount !== undefined)) {
1647
1659
  const offset = this.safeString(params, 'offset', '-');
1648
1660
  const trailingLimitAmountString = offset + this.numberToString(trailingLimitAmount);
1649
1661
  request['price'] = trailingAmountString;
package/js/src/kucoin.js CHANGED
@@ -49,6 +49,7 @@ export default class kucoin extends Exchange {
49
49
  'createPostOnlyOrder': true,
50
50
  'createStopLimitOrder': true,
51
51
  'createStopMarketOrder': true,
52
+ 'createTriggerOrder': true,
52
53
  'createStopOrder': true,
53
54
  'editOrder': true,
54
55
  'fetchAccounts': true,
@@ -316,6 +317,7 @@ export default class kucoin extends Exchange {
316
317
  'premium/query': 4.5,
317
318
  'trade-statistics': 4.5,
318
319
  'funding-rate/{symbol}/current': 3,
320
+ 'contract/funding-rates': 7.5,
319
321
  'timestamp': 3,
320
322
  'status': 6,
321
323
  // ?
@@ -345,6 +347,7 @@ export default class kucoin extends Exchange {
345
347
  'openOrderStatistics': 15,
346
348
  'position': 3,
347
349
  'positions': 3,
350
+ 'margin/maxWithdrawMargin': 15,
348
351
  'contracts/risk-limit/{symbol}': 7.5,
349
352
  'funding-history': 7.5, // 5FW
350
353
  },
@@ -355,7 +358,9 @@ export default class kucoin extends Exchange {
355
358
  // futures
356
359
  'orders': 3,
357
360
  'orders/test': 3,
361
+ 'orders/multi': 4.5,
358
362
  'position/margin/auto-deposit-status': 6,
363
+ 'margin/withdrawMargin': 15,
359
364
  'position/margin/deposit-margin': 6,
360
365
  'position/risk-limit-level/change': 6,
361
366
  // ws
@@ -1,5 +1,5 @@
1
1
  import kucoin from './abstract/kucoinfutures.js';
2
- import type { Int, OrderSide, OrderType, OHLCV, Order, Trade, FundingRateHistory, FundingHistory, Balances, Str, Ticker, OrderBook, Transaction, Strings, Market, Currency } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, OHLCV, Order, Trade, FundingHistory, Balances, Str, Ticker, OrderBook, Transaction, Strings, Market, Currency, OrderRequest } from './base/types.js';
3
3
  export default class kucoinfutures extends kucoin {
4
4
  describe(): any;
5
5
  fetchStatus(params?: {}): Promise<{
@@ -28,6 +28,8 @@ export default class kucoinfutures extends kucoin {
28
28
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
29
29
  parsePosition(position: any, market?: Market): import("./base/types.js").Position;
30
30
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
31
+ createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
32
+ createContractOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
31
33
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
32
34
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
33
35
  addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
@@ -85,7 +87,7 @@ export default class kucoinfutures extends kucoin {
85
87
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
86
88
  fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<any[]>;
87
89
  parseMarketLeverageTiers(info: any, market?: Market): any[];
88
- fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
90
+ fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").FundingRateHistory[]>;
89
91
  parseFundingRateHistory(info: any, market?: Market): {
90
92
  info: any;
91
93
  symbol: string;
@@ -36,10 +36,14 @@ export default class kucoinfutures extends kucoin {
36
36
  'closePositions': false,
37
37
  'createDepositAddress': true,
38
38
  'createOrder': true,
39
+ 'createOrders': true,
39
40
  'createReduceOnlyOrder': true,
40
41
  'createStopLimitOrder': true,
41
42
  'createStopMarketOrder': true,
42
43
  'createStopOrder': true,
44
+ 'createTriggerOrder': true,
45
+ 'createTakeProfitOrder': true,
46
+ 'createStopLossOrder': true,
43
47
  'fetchAccounts': true,
44
48
  'fetchBalance': true,
45
49
  'fetchBorrowRateHistories': false,
@@ -54,7 +58,7 @@ export default class kucoinfutures extends kucoin {
54
58
  'fetchDepositWithdrawFees': false,
55
59
  'fetchFundingHistory': true,
56
60
  'fetchFundingRate': true,
57
- 'fetchFundingRateHistory': false,
61
+ 'fetchFundingRateHistory': true,
58
62
  'fetchIndexOHLCV': false,
59
63
  'fetchIsolatedBorrowRate': false,
60
64
  'fetchIsolatedBorrowRates': false,
@@ -1115,6 +1119,78 @@ export default class kucoinfutures extends kucoin {
1115
1119
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1116
1120
  */
1117
1121
  await this.loadMarkets();
1122
+ const market = this.market(symbol);
1123
+ const testOrder = this.safeValue(params, 'test', false);
1124
+ params = this.omit(params, 'test');
1125
+ const orderRequest = this.createContractOrderRequest(symbol, type, side, amount, price, params);
1126
+ let response = undefined;
1127
+ if (testOrder) {
1128
+ response = await this.futuresPrivatePostOrdersTest(orderRequest);
1129
+ }
1130
+ else {
1131
+ response = await this.futuresPrivatePostOrders(orderRequest);
1132
+ }
1133
+ //
1134
+ // {
1135
+ // "code": "200000",
1136
+ // "data": {
1137
+ // "orderId": "619717484f1d010001510cde",
1138
+ // },
1139
+ // }
1140
+ //
1141
+ const data = this.safeValue(response, 'data', {});
1142
+ return this.parseOrder(data, market);
1143
+ }
1144
+ async createOrders(orders, params = {}) {
1145
+ /**
1146
+ * @method
1147
+ * @name kucoinfutures#createOrders
1148
+ * @description create a list of trade orders
1149
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/place-multiple-orders
1150
+ * @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
1151
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1152
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1153
+ */
1154
+ await this.loadMarkets();
1155
+ const ordersRequests = [];
1156
+ for (let i = 0; i < orders.length; i++) {
1157
+ const rawOrder = orders[i];
1158
+ const symbol = this.safeString(rawOrder, 'symbol');
1159
+ const market = this.market(symbol);
1160
+ const type = this.safeString(rawOrder, 'type');
1161
+ const side = this.safeString(rawOrder, 'side');
1162
+ const amount = this.safeValue(rawOrder, 'amount');
1163
+ const price = this.safeValue(rawOrder, 'price');
1164
+ const orderParams = this.safeValue(rawOrder, 'params', {});
1165
+ const orderRequest = this.createContractOrderRequest(market['id'], type, side, amount, price, orderParams);
1166
+ ordersRequests.push(orderRequest);
1167
+ }
1168
+ const response = await this.futuresPrivatePostOrdersMulti(ordersRequests);
1169
+ //
1170
+ // {
1171
+ // "code": "200000",
1172
+ // "data": [
1173
+ // {
1174
+ // "orderId": "135241412609331200",
1175
+ // "clientOid": "3d8fcc13-0b13-447f-ad30-4b3441e05213",
1176
+ // "symbol": "LTCUSDTM",
1177
+ // "code": "200000",
1178
+ // "msg": "success"
1179
+ // },
1180
+ // {
1181
+ // "orderId": "135241412747743234",
1182
+ // "clientOid": "b878c7ee-ae3e-4d63-a20b-038acbb7306f",
1183
+ // "symbol": "LTCUSDTM",
1184
+ // "code": "200000",
1185
+ // "msg": "success"
1186
+ // }
1187
+ // ]
1188
+ // }
1189
+ //
1190
+ const data = this.safeValue(response, 'data', []);
1191
+ return this.parseOrders(data);
1192
+ }
1193
+ createContractOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1118
1194
  const market = this.market(symbol);
1119
1195
  // required param, cannot be used twice
1120
1196
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId', this.uuid());
@@ -1187,48 +1263,7 @@ export default class kucoinfutures extends kucoin {
1187
1263
  }
1188
1264
  }
1189
1265
  params = this.omit(params, ['timeInForce', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']); // Time in force only valid for limit orders, exchange error when gtc for market orders
1190
- let response = undefined;
1191
- const testOrder = this.safeValue(params, 'test', false);
1192
- params = this.omit(params, 'test');
1193
- if (testOrder) {
1194
- response = await this.futuresPrivatePostOrdersTest(this.extend(request, params));
1195
- }
1196
- else {
1197
- response = await this.futuresPrivatePostOrders(this.extend(request, params));
1198
- }
1199
- //
1200
- // {
1201
- // "code": "200000",
1202
- // "data": {
1203
- // "orderId": "619717484f1d010001510cde",
1204
- // },
1205
- // }
1206
- //
1207
- const data = this.safeValue(response, 'data', {});
1208
- return this.safeOrder({
1209
- 'id': this.safeString(data, 'orderId'),
1210
- 'clientOrderId': undefined,
1211
- 'timestamp': undefined,
1212
- 'datetime': undefined,
1213
- 'lastTradeTimestamp': undefined,
1214
- 'symbol': undefined,
1215
- 'type': undefined,
1216
- 'side': undefined,
1217
- 'price': undefined,
1218
- 'amount': undefined,
1219
- 'cost': undefined,
1220
- 'average': undefined,
1221
- 'filled': undefined,
1222
- 'remaining': undefined,
1223
- 'status': undefined,
1224
- 'fee': undefined,
1225
- 'trades': undefined,
1226
- 'timeInForce': undefined,
1227
- 'postOnly': undefined,
1228
- 'stopPrice': undefined,
1229
- 'triggerPrice': undefined,
1230
- 'info': response,
1231
- }, market);
1266
+ return this.extend(request, params);
1232
1267
  }
1233
1268
  async cancelOrder(id, symbol = undefined, params = {}) {
1234
1269
  /**
@@ -1701,10 +1736,26 @@ export default class kucoinfutures extends kucoin {
1701
1736
  // "reduceOnly": false
1702
1737
  // }
1703
1738
  //
1739
+ // createOrder
1740
+ //
1741
+ // {
1742
+ // "orderId": "619717484f1d010001510cde"
1743
+ // }
1744
+ //
1745
+ // createOrders
1746
+ //
1747
+ // {
1748
+ // "orderId": "80465574458560512",
1749
+ // "clientOid": "5c52e11203aa677f33e491",
1750
+ // "symbol": "ETHUSDTM",
1751
+ // "code": "200000",
1752
+ // "msg": "success"
1753
+ // }
1754
+ //
1704
1755
  const marketId = this.safeString(order, 'symbol');
1705
1756
  market = this.safeMarket(marketId, market);
1706
1757
  const symbol = market['symbol'];
1707
- const orderId = this.safeString(order, 'id');
1758
+ const orderId = this.safeString2(order, 'id', 'orderId');
1708
1759
  const type = this.safeString(order, 'type');
1709
1760
  const timestamp = this.safeInteger(order, 'createdAt');
1710
1761
  const datetime = this.iso8601(timestamp);
@@ -1731,9 +1782,12 @@ export default class kucoinfutures extends kucoin {
1731
1782
  // precision reported by their api is 8 d.p.
1732
1783
  // const average = Precise.stringDiv (cost, Precise.stringMul (filled, market['contractSize']));
1733
1784
  // bool
1734
- const isActive = this.safeValue(order, 'isActive', false);
1785
+ const isActive = this.safeValue(order, 'isActive');
1735
1786
  const cancelExist = this.safeValue(order, 'cancelExist', false);
1736
- let status = isActive ? 'open' : 'closed';
1787
+ let status = undefined;
1788
+ if (isActive !== undefined) {
1789
+ status = isActive ? 'open' : 'closed';
1790
+ }
1737
1791
  status = cancelExist ? 'canceled' : status;
1738
1792
  let fee = undefined;
1739
1793
  if (feeCost !== undefined) {
@@ -2378,62 +2432,62 @@ export default class kucoinfutures extends kucoin {
2378
2432
  /**
2379
2433
  * @method
2380
2434
  * @name kucoinfutures#fetchFundingRateHistory
2435
+ * @see https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-public-funding-history#request-url
2381
2436
  * @description fetches historical funding rate prices
2382
2437
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
2383
2438
  * @param {int} [since] not used by kucuoinfutures
2384
2439
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
2385
2440
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2386
- * @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)
2441
+ * @param {int} [params.until] end time in ms
2387
2442
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
2388
2443
  */
2389
2444
  if (symbol === undefined) {
2390
2445
  throw new ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
2391
2446
  }
2392
2447
  await this.loadMarkets();
2393
- let paginate = false;
2394
- [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2395
- if (paginate) {
2396
- return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
2397
- }
2398
2448
  const market = this.market(symbol);
2399
2449
  const request = {
2400
2450
  'symbol': market['id'],
2451
+ 'from': 0,
2452
+ 'to': this.milliseconds(),
2401
2453
  };
2402
- if (limit !== undefined) {
2403
- request['maxCount'] = limit;
2454
+ const until = this.safeInteger2(params, 'until', 'till');
2455
+ params = this.omit(params, ['until', 'till']);
2456
+ if (since !== undefined) {
2457
+ request['from'] = since;
2458
+ if (until === undefined) {
2459
+ request['to'] = since + 1000 * 8 * 60 * 60 * 100;
2460
+ }
2461
+ }
2462
+ if (until !== undefined) {
2463
+ request['to'] = until;
2464
+ if (since === undefined) {
2465
+ request['to'] = until - 1000 * 8 * 60 * 60 * 100;
2466
+ }
2404
2467
  }
2405
- const response = await this.webExchangeGetContractSymbolFundingRates(this.extend(request, params));
2468
+ const response = await this.futuresPublicGetContractFundingRates(this.extend(request, params));
2406
2469
  //
2407
- // {
2408
- // "success": true,
2409
- // "code": "200",
2410
- // "msg": "success",
2411
- // "retry": false,
2412
- // "data": {
2413
- // "dataList": [
2414
- // {
2415
- // "symbol": "XBTUSDTM",
2416
- // "granularity": 28800000,
2417
- // "timePoint": 1675108800000,
2418
- // "value": 0.0001
2419
- // },
2420
- // ...
2421
- // ],
2422
- // "hasMore": true
2423
- // }
2424
- // }
2470
+ // {
2471
+ // "code": "200000",
2472
+ // "data": [
2473
+ // {
2474
+ // "symbol": "IDUSDTM",
2475
+ // "fundingRate": 2.26E-4,
2476
+ // "timepoint": 1702296000000
2477
+ // }
2478
+ // ]
2479
+ // }
2425
2480
  //
2426
2481
  const data = this.safeValue(response, 'data');
2427
- const dataList = this.safeValue(data, 'dataList');
2428
- return this.parseFundingRateHistories(dataList, market, since, limit);
2482
+ return this.parseFundingRateHistories(data, market, since, limit);
2429
2483
  }
2430
2484
  parseFundingRateHistory(info, market = undefined) {
2431
- const timestamp = this.safeInteger(info, 'timePoint');
2485
+ const timestamp = this.safeInteger(info, 'timepoint');
2432
2486
  const marketId = this.safeString(info, 'symbol');
2433
2487
  return {
2434
2488
  'info': info,
2435
2489
  'symbol': this.safeSymbol(marketId, market),
2436
- 'fundingRate': this.safeNumber(info, 'value'),
2490
+ 'fundingRate': this.safeNumber(info, 'fundingRate'),
2437
2491
  'timestamp': timestamp,
2438
2492
  'datetime': this.iso8601(timestamp),
2439
2493
  };
package/js/src/okx.js CHANGED
@@ -43,12 +43,16 @@ export default class okx extends Exchange {
43
43
  'createMarketSellOrderWithCost': true,
44
44
  'createOrder': true,
45
45
  'createOrders': true,
46
+ 'createOrderWithTakeProfitAndStopLoss': true,
46
47
  'createPostOnlyOrder': true,
47
48
  'createReduceOnlyOrder': true,
49
+ 'createStopLossOrder': true,
48
50
  'createStopLimitOrder': true,
49
51
  'createStopMarketOrder': true,
50
52
  'createStopOrder': true,
53
+ 'createTakeProfitOrder': true,
51
54
  'createTrailingPercentOrder': true,
55
+ 'createTriggerOrder': true,
52
56
  'editOrder': true,
53
57
  'fetchAccounts': true,
54
58
  'fetchBalance': true,
@@ -2136,17 +2140,14 @@ export default class okx extends Exchange {
2136
2140
  let defaultType = 'Candles';
2137
2141
  if (since !== undefined) {
2138
2142
  const now = this.milliseconds();
2139
- const difference = now - since;
2140
2143
  const durationInMilliseconds = duration * 1000;
2141
- // if the since timestamp is more than limit candles back in the past
2142
- // additional one bar for max offset to round the current day to UTC
2143
- const calc = (1440 - limit - 1) * durationInMilliseconds;
2144
- if (difference > calc) {
2144
+ // switch to history candles if since is past the cutoff for current candles
2145
+ const historyBorder = now - ((1440 - 1) * durationInMilliseconds);
2146
+ if (since < historyBorder) {
2145
2147
  defaultType = 'HistoryCandles';
2146
2148
  }
2147
- const startTime = Math.max(since - 1, 0);
2148
- request['before'] = startTime;
2149
- request['after'] = this.sum(startTime, durationInMilliseconds * limit);
2149
+ request['before'] = since;
2150
+ request['after'] = this.sum(since, durationInMilliseconds * limit);
2150
2151
  }
2151
2152
  const until = this.safeInteger(params, 'until');
2152
2153
  if (until !== undefined) {
package/js/src/woo.js CHANGED
@@ -51,6 +51,10 @@ export default class woo extends Exchange {
51
51
  'createStopOrder': false,
52
52
  'createTrailingAmountOrder': true,
53
53
  'createTrailingPercentOrder': true,
54
+ 'createTriggerOrder': true,
55
+ 'createTakeProfitOrder': true,
56
+ 'createStopLossOrder': true,
57
+ 'createOrderWithTakeProfitAndStopLoss': true,
54
58
  'fetchAccounts': true,
55
59
  'fetchBalance': true,
56
60
  'fetchCanceledOrders': false,
@@ -769,7 +773,7 @@ export default class woo extends Exchange {
769
773
  async createTrailingAmountOrder(symbol, type, side, amount, price = undefined, trailingAmount = undefined, trailingTriggerPrice = undefined, params = {}) {
770
774
  /**
771
775
  * @method
772
- * @name createTrailingAmountOrder
776
+ * @name woo#createTrailingAmountOrder
773
777
  * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
774
778
  * @param {string} symbol unified symbol of the market to create an order in
775
779
  * @param {string} type 'market' or 'limit'
@@ -794,7 +798,7 @@ export default class woo extends Exchange {
794
798
  async createTrailingPercentOrder(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
795
799
  /**
796
800
  * @method
797
- * @name createTrailingPercentOrder
801
+ * @name woo#createTrailingPercentOrder
798
802
  * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
799
803
  * @param {string} symbol unified symbol of the market to create an order in
800
804
  * @param {string} type 'market' or 'limit'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.13",
3
+ "version": "4.2.14",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",