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
package/js/src/okcoin.js CHANGED
@@ -248,6 +248,16 @@ export default class okcoin extends Exchange {
248
248
  '50026': ExchangeNotAvailable,
249
249
  '50027': PermissionDenied,
250
250
  '50028': ExchangeError,
251
+ '50029': ExchangeError,
252
+ '50030': PermissionDenied,
253
+ '50032': AccountSuspended,
254
+ '50033': AccountSuspended,
255
+ '50035': BadRequest,
256
+ '50036': BadRequest,
257
+ '50037': BadRequest,
258
+ '50038': ExchangeError,
259
+ '50039': ExchangeError,
260
+ '50041': ExchangeError,
251
261
  '50044': BadRequest,
252
262
  // API Class
253
263
  '50100': ExchangeError,
@@ -291,9 +301,25 @@ export default class okcoin extends Exchange {
291
301
  '51024': AccountSuspended,
292
302
  '51025': ExchangeError,
293
303
  '51026': BadSymbol,
304
+ '51030': InvalidOrder,
305
+ '51031': InvalidOrder,
306
+ '51032': InvalidOrder,
307
+ '51033': InvalidOrder,
308
+ '51037': InvalidOrder,
309
+ '51038': InvalidOrder,
310
+ '51044': InvalidOrder,
294
311
  '51046': InvalidOrder,
295
312
  '51047': InvalidOrder,
296
- '51031': InvalidOrder,
313
+ '51048': InvalidOrder,
314
+ '51049': InvalidOrder,
315
+ '51050': InvalidOrder,
316
+ '51051': InvalidOrder,
317
+ '51052': InvalidOrder,
318
+ '51053': InvalidOrder,
319
+ '51054': BadRequest,
320
+ '51056': InvalidOrder,
321
+ '51058': InvalidOrder,
322
+ '51059': InvalidOrder,
297
323
  '51100': InvalidOrder,
298
324
  '51102': InvalidOrder,
299
325
  '51103': InvalidOrder,
package/js/src/okx.js CHANGED
@@ -576,6 +576,7 @@ export default class okx extends Exchange {
576
576
  '50027': PermissionDenied,
577
577
  '50028': ExchangeError,
578
578
  '50044': BadRequest,
579
+ '50061': ExchangeError,
579
580
  '50062': ExchangeError,
580
581
  // API Class
581
582
  '50100': ExchangeError,
@@ -763,6 +764,15 @@ export default class okx extends Exchange {
763
764
  // SPOT/MARGIN error codes 54000-54999
764
765
  '54000': ExchangeError,
765
766
  '54001': ExchangeError,
767
+ // Trading bot Error Code from 55100 to 55999
768
+ '55100': InvalidOrder,
769
+ '55101': InvalidOrder,
770
+ '55102': InvalidOrder,
771
+ '55103': InvalidOrder,
772
+ '55104': InvalidOrder,
773
+ '55111': InvalidOrder,
774
+ '55112': InvalidOrder,
775
+ '55113': InvalidOrder,
766
776
  // FUNDING error codes 58000-58999
767
777
  '58000': ExchangeError,
768
778
  '58001': AuthenticationError,
@@ -5024,6 +5034,14 @@ export default class okx extends Exchange {
5024
5034
  '3': 'pending',
5025
5035
  '4': 'pending',
5026
5036
  '5': 'pending',
5037
+ '6': 'pending',
5038
+ '7': 'pending',
5039
+ '8': 'pending',
5040
+ '9': 'pending',
5041
+ '10': 'pending',
5042
+ '12': 'pending',
5043
+ '15': 'pending',
5044
+ '16': 'pending',
5027
5045
  };
5028
5046
  return this.safeString(statuses, status, status);
5029
5047
  }
@@ -586,7 +586,7 @@ export default class alpaca extends alpacaRest {
586
586
  }
587
587
  this.watch(url, messageHash, request, messageHash, future);
588
588
  }
589
- return future;
589
+ return await future;
590
590
  }
591
591
  handleErrorMessage(client, message) {
592
592
  //
@@ -864,7 +864,7 @@ export default class bitfinex2 extends bitfinex2Rest {
864
864
  const message = this.extend(request, params);
865
865
  this.watch(url, messageHash, message, messageHash);
866
866
  }
867
- return future;
867
+ return await future;
868
868
  }
869
869
  handleAuthenticationMessage(client, message) {
870
870
  const messageHash = 'authenticated';
@@ -1610,7 +1610,7 @@ export default class bitget extends bitgetRest {
1610
1610
  const message = this.extend(request, params);
1611
1611
  this.watch(url, messageHash, message, messageHash);
1612
1612
  }
1613
- return future;
1613
+ return await future;
1614
1614
  }
1615
1615
  async watchPrivate(messageHash, subscriptionHash, args, params = {}) {
1616
1616
  await this.authenticate();
@@ -1409,7 +1409,7 @@ export default class bitmart extends bitmartRest {
1409
1409
  const message = this.extend(request, params);
1410
1410
  this.watch(url, messageHash, message, messageHash);
1411
1411
  }
1412
- return future;
1412
+ return await future;
1413
1413
  }
1414
1414
  handleSubscriptionStatus(client, message) {
1415
1415
  //
@@ -612,7 +612,7 @@ export default class bitmex extends bitmexRest {
612
612
  const message = this.extend(request, params);
613
613
  this.watch(url, messageHash, message, messageHash);
614
614
  }
615
- return future;
615
+ return await future;
616
616
  }
617
617
  handleAuthenticationMessage(client, message) {
618
618
  const authenticated = this.safeBool(message, 'success', false);
@@ -771,6 +771,6 @@ export default class blockchaincom extends blockchaincomRest {
771
771
  };
772
772
  return this.watch(url, messageHash, this.extend(request, params), messageHash);
773
773
  }
774
- return future;
774
+ return await future;
775
775
  }
776
776
  }
@@ -1040,8 +1040,23 @@ export default class bybit extends bybitRest {
1040
1040
  for (let i = 0; i < rawPositions.length; i++) {
1041
1041
  const rawPosition = rawPositions[i];
1042
1042
  const position = this.parsePosition(rawPosition);
1043
+ const side = this.safeString(position, 'side');
1044
+ // hacky solution to handle closing positions
1045
+ // without crashing, we should handle this properly later
1043
1046
  newPositions.push(position);
1044
- cache.append(position);
1047
+ if (side === undefined || side === '') {
1048
+ // closing update, adding both sides to "reset" both sides
1049
+ // since we don't know which side is being closed
1050
+ position['side'] = 'long';
1051
+ cache.append(position);
1052
+ position['side'] = 'short';
1053
+ cache.append(position);
1054
+ position['side'] = undefined;
1055
+ }
1056
+ else {
1057
+ // regular update
1058
+ cache.append(position);
1059
+ }
1045
1060
  }
1046
1061
  const messageHashes = this.findMessageHashes(client, 'positions::');
1047
1062
  for (let i = 0; i < messageHashes.length; i++) {
package/js/src/pro/cex.js CHANGED
@@ -160,16 +160,20 @@ export default class cex extends cexRest {
160
160
  // {
161
161
  // "e": "history",
162
162
  // "data": [
163
- // "sell:1665467367741:3888551:19058.8:14541219",
164
- // "buy:1665467367741:1059339:19071.5:14541218",
163
+ // 'buy:1710255706095:444444:71222.2:14892622'
164
+ // 'sell:1710255658251:42530:71300:14892621'
165
+ // 'buy:1710252424241:87913:72800:14892620'
166
+ // ... timestamp descending
165
167
  // ]
166
168
  // }
167
169
  //
168
- const data = this.safeValue(message, 'data', []);
170
+ const data = this.safeList(message, 'data', []);
169
171
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
170
172
  const stored = new ArrayCache(limit);
171
- for (let i = 0; i < data.length; i++) {
172
- const rawTrade = data[i];
173
+ const dataLength = data.length;
174
+ for (let i = 0; i < dataLength; i++) {
175
+ const index = dataLength - 1 - i;
176
+ const rawTrade = data[index];
173
177
  const parsed = this.parseWsOldTrade(rawTrade);
174
178
  stored.append(parsed);
175
179
  }
@@ -1006,7 +1006,7 @@ export default class cryptocom extends cryptocomRest {
1006
1006
  const message = this.extend(request, params);
1007
1007
  this.watch(url, messageHash, message, messageHash);
1008
1008
  }
1009
- return future;
1009
+ return await future;
1010
1010
  }
1011
1011
  handlePing(client, message) {
1012
1012
  this.spawn(this.pong, client, message);
@@ -116,7 +116,7 @@ export default class hitbtc extends hitbtcRest {
116
116
  // }
117
117
  //
118
118
  }
119
- return future;
119
+ return await future;
120
120
  }
121
121
  async subscribePublic(name, messageHashPrefix, symbols = undefined, params = {}) {
122
122
  /**
package/js/src/pro/htx.js CHANGED
@@ -2383,6 +2383,6 @@ export default class htx extends htxRest {
2383
2383
  };
2384
2384
  this.watch(url, messageHash, request, messageHash, subscription);
2385
2385
  }
2386
- return future;
2386
+ return await future;
2387
2387
  }
2388
2388
  }
@@ -478,7 +478,7 @@ export default class okcoin extends okcoinRest {
478
478
  };
479
479
  this.spawn(this.watch, url, messageHash, request, messageHash, future);
480
480
  }
481
- return future;
481
+ return await future;
482
482
  }
483
483
  async watchBalance(params = {}) {
484
484
  /**
@@ -1335,6 +1335,6 @@ export default class onetrading extends onetradingRest {
1335
1335
  };
1336
1336
  this.watch(url, messageHash, this.extend(request, params), messageHash);
1337
1337
  }
1338
- return future;
1338
+ return await future;
1339
1339
  }
1340
1340
  }
package/js/src/pro/woo.js CHANGED
@@ -85,6 +85,15 @@ export default class woo extends wooRest {
85
85
  return await this.watch(url, messageHash, request, messageHash, subscribe);
86
86
  }
87
87
  async watchOrderBook(symbol, limit = undefined, params = {}) {
88
+ /**
89
+ * @method
90
+ * @name woo#watchOrderBook
91
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
92
+ * @param {string} symbol unified symbol of the market to fetch the order book for
93
+ * @param {int} [limit] the maximum amount of order book entries to return.
94
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
95
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
96
+ */
88
97
  await this.loadMarkets();
89
98
  const name = 'orderbook';
90
99
  const market = this.market(symbol);
@@ -134,9 +143,18 @@ export default class woo extends wooRest {
134
143
  client.resolve(orderbook, topic);
135
144
  }
136
145
  async watchTicker(symbol, params = {}) {
146
+ /**
147
+ * @method
148
+ * @name woo#watchTicker
149
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
150
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
151
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
152
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
153
+ */
137
154
  await this.loadMarkets();
138
155
  const name = 'ticker';
139
156
  const market = this.market(symbol);
157
+ symbol = market['symbol'];
140
158
  const topic = market['id'] + '@' + name;
141
159
  const request = {
142
160
  'event': 'subscribe',
@@ -211,7 +229,16 @@ export default class woo extends wooRest {
211
229
  return message;
212
230
  }
213
231
  async watchTickers(symbols = undefined, params = {}) {
232
+ /**
233
+ * @method
234
+ * @name woo#watchTickers
235
+ * @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
236
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
237
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
238
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
239
+ */
214
240
  await this.loadMarkets();
241
+ symbols = this.marketSymbols(symbols);
215
242
  const name = 'tickers';
216
243
  const topic = name;
217
244
  const request = {
@@ -330,8 +357,19 @@ export default class woo extends wooRest {
330
357
  client.resolve(stored, topic);
331
358
  }
332
359
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
360
+ /**
361
+ * @method
362
+ * @name woo#watchTrades
363
+ * @description watches information on multiple trades made in a market
364
+ * @param {string} symbol unified market symbol of the market trades were made in
365
+ * @param {int} [since] the earliest time in ms to fetch trades for
366
+ * @param {int} [limit] the maximum number of trade structures to retrieve
367
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
368
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
369
+ */
333
370
  await this.loadMarkets();
334
371
  const market = this.market(symbol);
372
+ symbol = market['symbol'];
335
373
  const topic = market['id'] + '@trade';
336
374
  const request = {
337
375
  'event': 'subscribe',
package/js/src/woo.d.ts CHANGED
@@ -30,6 +30,8 @@ export default class woo extends Exchange {
30
30
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
31
31
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
32
32
  fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
33
+ fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
34
+ fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
33
35
  parseTimeInForce(timeInForce: any): string;
34
36
  parseOrder(order: any, market?: Market): Order;
35
37
  parseOrderStatus(status: any): any;
package/js/src/woo.js CHANGED
@@ -59,7 +59,7 @@ export default class woo extends Exchange {
59
59
  'fetchBalance': true,
60
60
  'fetchCanceledOrders': false,
61
61
  'fetchClosedOrder': false,
62
- 'fetchClosedOrders': false,
62
+ 'fetchClosedOrders': true,
63
63
  'fetchCurrencies': true,
64
64
  'fetchDepositAddress': true,
65
65
  'fetchDeposits': true,
@@ -78,7 +78,7 @@ export default class woo extends Exchange {
78
78
  'fetchOHLCV': true,
79
79
  'fetchOpenInterestHistory': false,
80
80
  'fetchOpenOrder': false,
81
- 'fetchOpenOrders': false,
81
+ 'fetchOpenOrders': true,
82
82
  'fetchOrder': true,
83
83
  'fetchOrderBook': true,
84
84
  'fetchOrders': true,
@@ -1448,7 +1448,51 @@ export default class woo extends Exchange {
1448
1448
  //
1449
1449
  const data = this.safeValue(response, 'data', response);
1450
1450
  const orders = this.safeList(data, 'rows');
1451
- return this.parseOrders(orders, market, since, limit, params);
1451
+ return this.parseOrders(orders, market, since, limit);
1452
+ }
1453
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1454
+ /**
1455
+ * @method
1456
+ * @name woo#fetchOpenOrders
1457
+ * @description fetches information on multiple orders made by the user
1458
+ * @see https://docs.woo.org/#get-orders
1459
+ * @see https://docs.woo.org/#get-algo-orders
1460
+ * @param {string} symbol unified market symbol of the market orders were made in
1461
+ * @param {int} [since] the earliest time in ms to fetch orders for
1462
+ * @param {int} [limit] the maximum number of order structures to retrieve
1463
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1464
+ * @param {boolean} [params.stop] whether the order is a stop/algo order
1465
+ * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
1466
+ * @param {string} [params.side] 'buy' or 'sell'
1467
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
1468
+ * @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination
1469
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1470
+ */
1471
+ await this.loadMarkets();
1472
+ const extendedParams = this.extend(params, { 'status': 'INCOMPLETE' });
1473
+ return await this.fetchOrders(symbol, since, limit, extendedParams);
1474
+ }
1475
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1476
+ /**
1477
+ * @method
1478
+ * @name woo#fetchClosedOrders
1479
+ * @description fetches information on multiple orders made by the user
1480
+ * @see https://docs.woo.org/#get-orders
1481
+ * @see https://docs.woo.org/#get-algo-orders
1482
+ * @param {string} symbol unified market symbol of the market orders were made in
1483
+ * @param {int} [since] the earliest time in ms to fetch orders for
1484
+ * @param {int} [limit] the maximum number of order structures to retrieve
1485
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1486
+ * @param {boolean} [params.stop] whether the order is a stop/algo order
1487
+ * @param {boolean} [params.isTriggered] whether the order has been triggered (false by default)
1488
+ * @param {string} [params.side] 'buy' or 'sell'
1489
+ * @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
1490
+ * @param {boolean} [params.paginate] set to true if you want to fetch orders with pagination
1491
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1492
+ */
1493
+ await this.loadMarkets();
1494
+ const extendedParams = this.extend(params, { 'status': 'COMPLETED' });
1495
+ return await this.fetchOrders(symbol, since, limit, extendedParams);
1452
1496
  }
1453
1497
  parseTimeInForce(timeInForce) {
1454
1498
  const timeInForces = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.77",
3
+ "version": "4.2.79",
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",
package/skip-tests.json CHANGED
@@ -728,6 +728,9 @@
728
728
  "ticker": {
729
729
  "baseVolume": "quoteVolume >= baseVolume * low is failing",
730
730
  "bid": "failing the test"
731
+ },
732
+ "fetchOHLCV": {
733
+ "4":"https://app.travis-ci.com/github/ccxt/ccxt/builds/269542746#L3512"
731
734
  }
732
735
  }
733
736
  },
@@ -1397,7 +1400,8 @@
1397
1400
  "side": "undefined"
1398
1401
  },
1399
1402
  "ticker": {
1400
- "baseVolume": "not supported"
1403
+ "baseVolume": "not supported",
1404
+ "spread": "same bid-ask https://app.travis-ci.com/github/ccxt/ccxt/builds/269550508#L3581"
1401
1405
  },
1402
1406
  "fetchOHLCV": "spot not supported",
1403
1407
  "fetchCurrencies": {