ccxt 4.2.77 → 4.2.79

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 (67) hide show
  1. package/README.md +5 -5
  2. package/dist/ccxt.browser.js +456 -98
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/bingx.js +39 -5
  6. package/dist/cjs/src/bitstamp.js +21 -26
  7. package/dist/cjs/src/bybit.js +107 -2
  8. package/dist/cjs/src/coinbase.js +22 -9
  9. package/dist/cjs/src/coinbaseinternational.js +2 -2
  10. package/dist/cjs/src/gate.js +4 -1
  11. package/dist/cjs/src/htx.js +36 -27
  12. package/dist/cjs/src/hyperliquid.js +6 -4
  13. package/dist/cjs/src/kucoin.js +52 -0
  14. package/dist/cjs/src/okcoin.js +27 -1
  15. package/dist/cjs/src/okx.js +18 -0
  16. package/dist/cjs/src/pro/alpaca.js +1 -1
  17. package/dist/cjs/src/pro/bitfinex2.js +1 -1
  18. package/dist/cjs/src/pro/bitget.js +1 -1
  19. package/dist/cjs/src/pro/bitmart.js +1 -1
  20. package/dist/cjs/src/pro/bitmex.js +1 -1
  21. package/dist/cjs/src/pro/blockchaincom.js +1 -1
  22. package/dist/cjs/src/pro/bybit.js +16 -1
  23. package/dist/cjs/src/pro/cex.js +9 -5
  24. package/dist/cjs/src/pro/cryptocom.js +1 -1
  25. package/dist/cjs/src/pro/hitbtc.js +1 -1
  26. package/dist/cjs/src/pro/htx.js +1 -1
  27. package/dist/cjs/src/pro/okcoin.js +1 -1
  28. package/dist/cjs/src/pro/onetrading.js +1 -1
  29. package/dist/cjs/src/pro/woo.js +38 -0
  30. package/dist/cjs/src/woo.js +47 -3
  31. package/js/ccxt.d.ts +1 -1
  32. package/js/ccxt.js +1 -1
  33. package/js/src/abstract/bingx.d.ts +1 -0
  34. package/js/src/abstract/gate.d.ts +1 -0
  35. package/js/src/abstract/gateio.d.ts +1 -0
  36. package/js/src/base/types.d.ts +2 -2
  37. package/js/src/bingx.js +39 -5
  38. package/js/src/bitstamp.js +21 -26
  39. package/js/src/bybit.d.ts +12 -1
  40. package/js/src/bybit.js +107 -2
  41. package/js/src/coinbase.d.ts +2 -2
  42. package/js/src/coinbase.js +22 -9
  43. package/js/src/coinbaseinternational.js +2 -2
  44. package/js/src/gate.js +4 -1
  45. package/js/src/htx.js +36 -27
  46. package/js/src/hyperliquid.js +6 -4
  47. package/js/src/kucoin.js +52 -0
  48. package/js/src/okcoin.js +27 -1
  49. package/js/src/okx.js +18 -0
  50. package/js/src/pro/alpaca.js +1 -1
  51. package/js/src/pro/bitfinex2.js +1 -1
  52. package/js/src/pro/bitget.js +1 -1
  53. package/js/src/pro/bitmart.js +1 -1
  54. package/js/src/pro/bitmex.js +1 -1
  55. package/js/src/pro/blockchaincom.js +1 -1
  56. package/js/src/pro/bybit.js +16 -1
  57. package/js/src/pro/cex.js +9 -5
  58. package/js/src/pro/cryptocom.js +1 -1
  59. package/js/src/pro/hitbtc.js +1 -1
  60. package/js/src/pro/htx.js +1 -1
  61. package/js/src/pro/okcoin.js +1 -1
  62. package/js/src/pro/onetrading.js +1 -1
  63. package/js/src/pro/woo.js +38 -0
  64. package/js/src/woo.d.ts +2 -0
  65. package/js/src/woo.js +47 -3
  66. package/package.json +1 -1
  67. package/skip-tests.json +5 -1
@@ -446,6 +446,56 @@ class kucoin extends kucoin$1 {
446
446
  '130202': errors.ExchangeError,
447
447
  '130203': errors.InsufficientFunds,
448
448
  '130204': errors.BadRequest,
449
+ '130301': errors.InsufficientFunds,
450
+ '130302': errors.PermissionDenied,
451
+ '130303': errors.NotSupported,
452
+ '130304': errors.NotSupported,
453
+ '130305': errors.NotSupported,
454
+ '130306': errors.NotSupported,
455
+ '130307': errors.NotSupported,
456
+ '130308': errors.InvalidOrder,
457
+ '130309': errors.InvalidOrder,
458
+ '130310': errors.ExchangeError,
459
+ '130311': errors.InvalidOrder,
460
+ '130312': errors.InvalidOrder,
461
+ '130313': errors.InvalidOrder,
462
+ '130314': errors.InvalidOrder,
463
+ '130315': errors.NotSupported,
464
+ '126000': errors.ExchangeError,
465
+ '126001': errors.NotSupported,
466
+ '126002': errors.ExchangeError,
467
+ '126003': errors.InvalidOrder,
468
+ '126004': errors.ExchangeError,
469
+ '126005': errors.PermissionDenied,
470
+ '126006': errors.ExchangeError,
471
+ '126007': errors.ExchangeError,
472
+ '126009': errors.ExchangeError,
473
+ '126010': errors.ExchangeError,
474
+ '126011': errors.ExchangeError,
475
+ '126013': errors.InsufficientFunds,
476
+ '126015': errors.ExchangeError,
477
+ '126021': errors.NotSupported,
478
+ '126022': errors.InvalidOrder,
479
+ '126027': errors.InvalidOrder,
480
+ '126028': errors.InvalidOrder,
481
+ '126029': errors.InvalidOrder,
482
+ '126030': errors.InvalidOrder,
483
+ '126033': errors.InvalidOrder,
484
+ '126034': errors.InvalidOrder,
485
+ '126036': errors.InvalidOrder,
486
+ '126037': errors.ExchangeError,
487
+ '126038': errors.ExchangeError,
488
+ '126039': errors.ExchangeError,
489
+ '126041': errors.ExchangeError,
490
+ '126042': errors.ExchangeError,
491
+ '126043': errors.OrderNotFound,
492
+ '126044': errors.InvalidOrder,
493
+ '126045': errors.NotSupported,
494
+ '126046': errors.NotSupported,
495
+ '126047': errors.PermissionDenied,
496
+ '126048': errors.PermissionDenied,
497
+ '135005': errors.ExchangeError,
498
+ '135018': errors.ExchangeError,
449
499
  '200004': errors.InsufficientFunds,
450
500
  '210014': errors.InvalidOrder,
451
501
  '210021': errors.InsufficientFunds,
@@ -467,10 +517,12 @@ class kucoin extends kucoin$1 {
467
517
  '400350': errors.InvalidOrder,
468
518
  '400370': errors.InvalidOrder,
469
519
  '400400': errors.BadRequest,
520
+ '400401': errors.AuthenticationError,
470
521
  '400500': errors.InvalidOrder,
471
522
  '400600': errors.BadSymbol,
472
523
  '400760': errors.InvalidOrder,
473
524
  '401000': errors.BadRequest,
525
+ '408000': errors.BadRequest,
474
526
  '411100': errors.AccountSuspended,
475
527
  '415000': errors.BadRequest,
476
528
  '400303': errors.PermissionDenied,
@@ -245,6 +245,16 @@ class okcoin extends okcoin$1 {
245
245
  '50026': errors.ExchangeNotAvailable,
246
246
  '50027': errors.PermissionDenied,
247
247
  '50028': errors.ExchangeError,
248
+ '50029': errors.ExchangeError,
249
+ '50030': errors.PermissionDenied,
250
+ '50032': errors.AccountSuspended,
251
+ '50033': errors.AccountSuspended,
252
+ '50035': errors.BadRequest,
253
+ '50036': errors.BadRequest,
254
+ '50037': errors.BadRequest,
255
+ '50038': errors.ExchangeError,
256
+ '50039': errors.ExchangeError,
257
+ '50041': errors.ExchangeError,
248
258
  '50044': errors.BadRequest,
249
259
  // API Class
250
260
  '50100': errors.ExchangeError,
@@ -288,9 +298,25 @@ class okcoin extends okcoin$1 {
288
298
  '51024': errors.AccountSuspended,
289
299
  '51025': errors.ExchangeError,
290
300
  '51026': errors.BadSymbol,
301
+ '51030': errors.InvalidOrder,
302
+ '51031': errors.InvalidOrder,
303
+ '51032': errors.InvalidOrder,
304
+ '51033': errors.InvalidOrder,
305
+ '51037': errors.InvalidOrder,
306
+ '51038': errors.InvalidOrder,
307
+ '51044': errors.InvalidOrder,
291
308
  '51046': errors.InvalidOrder,
292
309
  '51047': errors.InvalidOrder,
293
- '51031': errors.InvalidOrder,
310
+ '51048': errors.InvalidOrder,
311
+ '51049': errors.InvalidOrder,
312
+ '51050': errors.InvalidOrder,
313
+ '51051': errors.InvalidOrder,
314
+ '51052': errors.InvalidOrder,
315
+ '51053': errors.InvalidOrder,
316
+ '51054': errors.BadRequest,
317
+ '51056': errors.InvalidOrder,
318
+ '51058': errors.InvalidOrder,
319
+ '51059': errors.InvalidOrder,
294
320
  '51100': errors.InvalidOrder,
295
321
  '51102': errors.InvalidOrder,
296
322
  '51103': errors.InvalidOrder,
@@ -573,6 +573,7 @@ class okx extends okx$1 {
573
573
  '50027': errors.PermissionDenied,
574
574
  '50028': errors.ExchangeError,
575
575
  '50044': errors.BadRequest,
576
+ '50061': errors.ExchangeError,
576
577
  '50062': errors.ExchangeError,
577
578
  // API Class
578
579
  '50100': errors.ExchangeError,
@@ -760,6 +761,15 @@ class okx extends okx$1 {
760
761
  // SPOT/MARGIN error codes 54000-54999
761
762
  '54000': errors.ExchangeError,
762
763
  '54001': errors.ExchangeError,
764
+ // Trading bot Error Code from 55100 to 55999
765
+ '55100': errors.InvalidOrder,
766
+ '55101': errors.InvalidOrder,
767
+ '55102': errors.InvalidOrder,
768
+ '55103': errors.InvalidOrder,
769
+ '55104': errors.InvalidOrder,
770
+ '55111': errors.InvalidOrder,
771
+ '55112': errors.InvalidOrder,
772
+ '55113': errors.InvalidOrder,
763
773
  // FUNDING error codes 58000-58999
764
774
  '58000': errors.ExchangeError,
765
775
  '58001': errors.AuthenticationError,
@@ -5021,6 +5031,14 @@ class okx extends okx$1 {
5021
5031
  '3': 'pending',
5022
5032
  '4': 'pending',
5023
5033
  '5': 'pending',
5034
+ '6': 'pending',
5035
+ '7': 'pending',
5036
+ '8': 'pending',
5037
+ '9': 'pending',
5038
+ '10': 'pending',
5039
+ '12': 'pending',
5040
+ '15': 'pending',
5041
+ '16': 'pending',
5024
5042
  };
5025
5043
  return this.safeString(statuses, status, status);
5026
5044
  }
@@ -583,7 +583,7 @@ class alpaca extends alpaca$1 {
583
583
  }
584
584
  this.watch(url, messageHash, request, messageHash, future);
585
585
  }
586
- return future;
586
+ return await future;
587
587
  }
588
588
  handleErrorMessage(client, message) {
589
589
  //
@@ -861,7 +861,7 @@ class bitfinex2 extends bitfinex2$1 {
861
861
  const message = this.extend(request, params);
862
862
  this.watch(url, messageHash, message, messageHash);
863
863
  }
864
- return future;
864
+ return await future;
865
865
  }
866
866
  handleAuthenticationMessage(client, message) {
867
867
  const messageHash = 'authenticated';
@@ -1607,7 +1607,7 @@ class bitget extends bitget$1 {
1607
1607
  const message = this.extend(request, params);
1608
1608
  this.watch(url, messageHash, message, messageHash);
1609
1609
  }
1610
- return future;
1610
+ return await future;
1611
1611
  }
1612
1612
  async watchPrivate(messageHash, subscriptionHash, args, params = {}) {
1613
1613
  await this.authenticate();
@@ -1406,7 +1406,7 @@ class bitmart extends bitmart$1 {
1406
1406
  const message = this.extend(request, params);
1407
1407
  this.watch(url, messageHash, message, messageHash);
1408
1408
  }
1409
- return future;
1409
+ return await future;
1410
1410
  }
1411
1411
  handleSubscriptionStatus(client, message) {
1412
1412
  //
@@ -607,7 +607,7 @@ class bitmex extends bitmex$1 {
607
607
  const message = this.extend(request, params);
608
608
  this.watch(url, messageHash, message, messageHash);
609
609
  }
610
- return future;
610
+ return await future;
611
611
  }
612
612
  handleAuthenticationMessage(client, message) {
613
613
  const authenticated = this.safeBool(message, 'success', false);
@@ -768,7 +768,7 @@ class blockchaincom extends blockchaincom$1 {
768
768
  };
769
769
  return this.watch(url, messageHash, this.extend(request, params), messageHash);
770
770
  }
771
- return future;
771
+ return await future;
772
772
  }
773
773
  }
774
774
 
@@ -1037,8 +1037,23 @@ class bybit extends bybit$1 {
1037
1037
  for (let i = 0; i < rawPositions.length; i++) {
1038
1038
  const rawPosition = rawPositions[i];
1039
1039
  const position = this.parsePosition(rawPosition);
1040
+ const side = this.safeString(position, 'side');
1041
+ // hacky solution to handle closing positions
1042
+ // without crashing, we should handle this properly later
1040
1043
  newPositions.push(position);
1041
- cache.append(position);
1044
+ if (side === undefined || side === '') {
1045
+ // closing update, adding both sides to "reset" both sides
1046
+ // since we don't know which side is being closed
1047
+ position['side'] = 'long';
1048
+ cache.append(position);
1049
+ position['side'] = 'short';
1050
+ cache.append(position);
1051
+ position['side'] = undefined;
1052
+ }
1053
+ else {
1054
+ // regular update
1055
+ cache.append(position);
1056
+ }
1042
1057
  }
1043
1058
  const messageHashes = this.findMessageHashes(client, 'positions::');
1044
1059
  for (let i = 0; i < messageHashes.length; i++) {
@@ -157,16 +157,20 @@ class cex extends cex$1 {
157
157
  // {
158
158
  // "e": "history",
159
159
  // "data": [
160
- // "sell:1665467367741:3888551:19058.8:14541219",
161
- // "buy:1665467367741:1059339:19071.5:14541218",
160
+ // 'buy:1710255706095:444444:71222.2:14892622'
161
+ // 'sell:1710255658251:42530:71300:14892621'
162
+ // 'buy:1710252424241:87913:72800:14892620'
163
+ // ... timestamp descending
162
164
  // ]
163
165
  // }
164
166
  //
165
- const data = this.safeValue(message, 'data', []);
167
+ const data = this.safeList(message, 'data', []);
166
168
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
167
169
  const stored = new Cache.ArrayCache(limit);
168
- for (let i = 0; i < data.length; i++) {
169
- const rawTrade = data[i];
170
+ const dataLength = data.length;
171
+ for (let i = 0; i < dataLength; i++) {
172
+ const index = dataLength - 1 - i;
173
+ const rawTrade = data[index];
170
174
  const parsed = this.parseWsOldTrade(rawTrade);
171
175
  stored.append(parsed);
172
176
  }
@@ -1003,7 +1003,7 @@ class cryptocom extends cryptocom$1 {
1003
1003
  const message = this.extend(request, params);
1004
1004
  this.watch(url, messageHash, message, messageHash);
1005
1005
  }
1006
- return future;
1006
+ return await future;
1007
1007
  }
1008
1008
  handlePing(client, message) {
1009
1009
  this.spawn(this.pong, client, message);
@@ -113,7 +113,7 @@ class hitbtc extends hitbtc$1 {
113
113
  // }
114
114
  //
115
115
  }
116
- return future;
116
+ return await future;
117
117
  }
118
118
  async subscribePublic(name, messageHashPrefix, symbols = undefined, params = {}) {
119
119
  /**
@@ -2380,7 +2380,7 @@ class htx extends htx$1 {
2380
2380
  };
2381
2381
  this.watch(url, messageHash, request, messageHash, subscription);
2382
2382
  }
2383
- return future;
2383
+ return await future;
2384
2384
  }
2385
2385
  }
2386
2386
 
@@ -475,7 +475,7 @@ class okcoin extends okcoin$1 {
475
475
  };
476
476
  this.spawn(this.watch, url, messageHash, request, messageHash, future);
477
477
  }
478
- return future;
478
+ return await future;
479
479
  }
480
480
  async watchBalance(params = {}) {
481
481
  /**
@@ -1332,7 +1332,7 @@ class onetrading extends onetrading$1 {
1332
1332
  };
1333
1333
  this.watch(url, messageHash, this.extend(request, params), messageHash);
1334
1334
  }
1335
- return future;
1335
+ return await future;
1336
1336
  }
1337
1337
  }
1338
1338
 
@@ -82,6 +82,15 @@ class woo extends woo$1 {
82
82
  return await this.watch(url, messageHash, request, messageHash, subscribe);
83
83
  }
84
84
  async watchOrderBook(symbol, limit = undefined, params = {}) {
85
+ /**
86
+ * @method
87
+ * @name woo#watchOrderBook
88
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
89
+ * @param {string} symbol unified symbol of the market to fetch the order book for
90
+ * @param {int} [limit] the maximum amount of order book entries to return.
91
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
92
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
93
+ */
85
94
  await this.loadMarkets();
86
95
  const name = 'orderbook';
87
96
  const market = this.market(symbol);
@@ -131,9 +140,18 @@ class woo extends woo$1 {
131
140
  client.resolve(orderbook, topic);
132
141
  }
133
142
  async watchTicker(symbol, params = {}) {
143
+ /**
144
+ * @method
145
+ * @name woo#watchTicker
146
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
147
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
148
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
149
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
150
+ */
134
151
  await this.loadMarkets();
135
152
  const name = 'ticker';
136
153
  const market = this.market(symbol);
154
+ symbol = market['symbol'];
137
155
  const topic = market['id'] + '@' + name;
138
156
  const request = {
139
157
  'event': 'subscribe',
@@ -208,7 +226,16 @@ class woo extends woo$1 {
208
226
  return message;
209
227
  }
210
228
  async watchTickers(symbols = undefined, params = {}) {
229
+ /**
230
+ * @method
231
+ * @name woo#watchTickers
232
+ * @description n watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
233
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
234
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
235
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
236
+ */
211
237
  await this.loadMarkets();
238
+ symbols = this.marketSymbols(symbols);
212
239
  const name = 'tickers';
213
240
  const topic = name;
214
241
  const request = {
@@ -327,8 +354,19 @@ class woo extends woo$1 {
327
354
  client.resolve(stored, topic);
328
355
  }
329
356
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
357
+ /**
358
+ * @method
359
+ * @name woo#watchTrades
360
+ * @description watches information on multiple trades made in a market
361
+ * @param {string} symbol unified market symbol of the market trades were made in
362
+ * @param {int} [since] the earliest time in ms to fetch trades for
363
+ * @param {int} [limit] the maximum number of trade structures to retrieve
364
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
365
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
366
+ */
330
367
  await this.loadMarkets();
331
368
  const market = this.market(symbol);
369
+ symbol = market['symbol'];
332
370
  const topic = market['id'] + '@trade';
333
371
  const request = {
334
372
  'event': 'subscribe',
@@ -56,7 +56,7 @@ class woo extends woo$1 {
56
56
  'fetchBalance': true,
57
57
  'fetchCanceledOrders': false,
58
58
  'fetchClosedOrder': false,
59
- 'fetchClosedOrders': false,
59
+ 'fetchClosedOrders': true,
60
60
  'fetchCurrencies': true,
61
61
  'fetchDepositAddress': true,
62
62
  'fetchDeposits': true,
@@ -75,7 +75,7 @@ class woo extends woo$1 {
75
75
  'fetchOHLCV': true,
76
76
  'fetchOpenInterestHistory': false,
77
77
  'fetchOpenOrder': false,
78
- 'fetchOpenOrders': false,
78
+ 'fetchOpenOrders': true,
79
79
  'fetchOrder': true,
80
80
  'fetchOrderBook': true,
81
81
  'fetchOrders': true,
@@ -1445,7 +1445,51 @@ class woo extends woo$1 {
1445
1445
  //
1446
1446
  const data = this.safeValue(response, 'data', response);
1447
1447
  const orders = this.safeList(data, 'rows');
1448
- return this.parseOrders(orders, market, since, limit, params);
1448
+ return this.parseOrders(orders, market, since, limit);
1449
+ }
1450
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1451
+ /**
1452
+ * @method
1453
+ * @name woo#fetchOpenOrders
1454
+ * @description fetches information on multiple orders made by the user
1455
+ * @see https://docs.woo.org/#get-orders
1456
+ * @see https://docs.woo.org/#get-algo-orders
1457
+ * @param {string} symbol unified market symbol of the market orders were made in
1458
+ * @param {int} [since] the earliest time in ms to fetch orders for
1459
+ * @param {int} [limit] the maximum number of order structures to retrieve
1460
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1461
+ * @param {boolean} [params.stop] whether the order is a stop/algo order
1462
+ * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
1463
+ * @param {string} [params.side] 'buy' or 'sell'
1464
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
1465
+ * @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination
1466
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1467
+ */
1468
+ await this.loadMarkets();
1469
+ const extendedParams = this.extend(params, { 'status': 'INCOMPLETE' });
1470
+ return await this.fetchOrders(symbol, since, limit, extendedParams);
1471
+ }
1472
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1473
+ /**
1474
+ * @method
1475
+ * @name woo#fetchClosedOrders
1476
+ * @description fetches information on multiple orders made by the user
1477
+ * @see https://docs.woo.org/#get-orders
1478
+ * @see https://docs.woo.org/#get-algo-orders
1479
+ * @param {string} symbol unified market symbol of the market orders were made in
1480
+ * @param {int} [since] the earliest time in ms to fetch orders for
1481
+ * @param {int} [limit] the maximum number of order structures to retrieve
1482
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1483
+ * @param {boolean} [params.stop] whether the order is a stop/algo order
1484
+ * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
1485
+ * @param {string} [params.side] 'buy' or 'sell'
1486
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
1487
+ * @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination
1488
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1489
+ */
1490
+ await this.loadMarkets();
1491
+ const extendedParams = this.extend(params, { 'status': 'COMPLETED' });
1492
+ return await this.fetchOrders(symbol, since, limit, extendedParams);
1449
1493
  }
1450
1494
  parseTimeInForce(timeInForce) {
1451
1495
  const timeInForces = {
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.2.76";
7
+ declare const version = "4.2.78";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.77';
41
+ const version = '4.2.79';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -31,6 +31,7 @@ interface Exchange {
31
31
  swapV1PrivateGetTradeBatchCancelReplace(params?: {}): Promise<implicitReturnType>;
32
32
  swapV1PrivatePostTradeCancelReplace(params?: {}): Promise<implicitReturnType>;
33
33
  swapV1PrivatePostPositionSideDual(params?: {}): Promise<implicitReturnType>;
34
+ swapV1PrivatePostTradeClosePosition(params?: {}): Promise<implicitReturnType>;
34
35
  swapV2PublicGetServerTime(params?: {}): Promise<implicitReturnType>;
35
36
  swapV2PublicGetQuoteContracts(params?: {}): Promise<implicitReturnType>;
36
37
  swapV2PublicGetQuotePrice(params?: {}): Promise<implicitReturnType>;
@@ -90,6 +90,7 @@ interface Exchange {
90
90
  privateUnifiedGetLoanRecords(params?: {}): Promise<implicitReturnType>;
91
91
  privateUnifiedGetInterestRecords(params?: {}): Promise<implicitReturnType>;
92
92
  privateUnifiedGetEstimateRate(params?: {}): Promise<implicitReturnType>;
93
+ privateUnifiedGetCurrencyDiscountTiers(params?: {}): Promise<implicitReturnType>;
93
94
  privateUnifiedPostAccountMode(params?: {}): Promise<implicitReturnType>;
94
95
  privateUnifiedPostLoans(params?: {}): Promise<implicitReturnType>;
95
96
  privateSpotGetFee(params?: {}): Promise<implicitReturnType>;
@@ -90,6 +90,7 @@ interface gate {
90
90
  privateUnifiedGetLoanRecords(params?: {}): Promise<implicitReturnType>;
91
91
  privateUnifiedGetInterestRecords(params?: {}): Promise<implicitReturnType>;
92
92
  privateUnifiedGetEstimateRate(params?: {}): Promise<implicitReturnType>;
93
+ privateUnifiedGetCurrencyDiscountTiers(params?: {}): Promise<implicitReturnType>;
93
94
  privateUnifiedPostAccountMode(params?: {}): Promise<implicitReturnType>;
94
95
  privateUnifiedPostLoans(params?: {}): Promise<implicitReturnType>;
95
96
  privateSpotGetFee(params?: {}): Promise<implicitReturnType>;
@@ -357,8 +357,8 @@ export interface Liquidation {
357
357
  }
358
358
  export interface OrderRequest {
359
359
  symbol: string;
360
- type: Str;
361
- side: Str;
360
+ type: OrderType;
361
+ side: OrderSide;
362
362
  amount?: number;
363
363
  price?: number | undefined;
364
364
  params?: any;
package/js/src/bingx.js CHANGED
@@ -185,6 +185,7 @@ export default class bingx extends Exchange {
185
185
  'post': {
186
186
  'trade/cancelReplace': 1,
187
187
  'positionSide/dual': 1,
188
+ 'trade/closePosition': 1,
188
189
  },
189
190
  },
190
191
  },
@@ -2166,6 +2167,8 @@ export default class bingx extends Exchange {
2166
2167
  'SELL': 'sell',
2167
2168
  'SHORT': 'sell',
2168
2169
  'LONG': 'buy',
2170
+ 'ask': 'sell',
2171
+ 'bid': 'buy',
2169
2172
  };
2170
2173
  return this.safeString(sides, side, side);
2171
2174
  }
@@ -3913,14 +3916,45 @@ export default class bingx extends Exchange {
3913
3916
  * @param {string} symbol Unified CCXT market symbol
3914
3917
  * @param {string} [side] not used by bingx
3915
3918
  * @param {object} [params] extra parameters specific to the bingx api endpoint
3919
+ * @param {string|undefined} [params.positionId] it is recommended to fill in this parameter when closing a position
3916
3920
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3917
3921
  */
3918
3922
  await this.loadMarkets();
3919
- const market = this.market(symbol);
3920
- const request = {
3921
- 'symbol': market['id'],
3922
- };
3923
- const response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
3923
+ const positionId = this.safeString(params, 'positionId');
3924
+ params = this.omit(params, 'positionId');
3925
+ let response = undefined;
3926
+ if (positionId !== undefined) {
3927
+ const request = {
3928
+ 'positionId': positionId,
3929
+ };
3930
+ response = await this.swapV1PrivatePostTradeClosePosition(this.extend(request, params));
3931
+ }
3932
+ else {
3933
+ const market = this.market(symbol);
3934
+ const request = {
3935
+ 'symbol': market['id'],
3936
+ };
3937
+ response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
3938
+ }
3939
+ //
3940
+ // swapV1PrivatePostTradeClosePosition
3941
+ //
3942
+ // {
3943
+ // "code": 0,
3944
+ // "msg": "",
3945
+ // "timestamp": 1710992264190,
3946
+ // "data": {
3947
+ // "orderId": 1770656007907930112,
3948
+ // "positionId": "1751667128353910784",
3949
+ // "symbol": "LTC-USDT",
3950
+ // "side": "Ask",
3951
+ // "type": "MARKET",
3952
+ // "positionSide": "Long",
3953
+ // "origQty": "0.2"
3954
+ // }
3955
+ // }
3956
+ //
3957
+ // swapV2PrivatePostTradeCloseAllPositions
3924
3958
  //
3925
3959
  // {
3926
3960
  // "code": 0,