ccxt 4.3.62 → 4.3.64

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 (86) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +2 -1
  4. package/dist/cjs/src/ace.js +34 -15
  5. package/dist/cjs/src/alpaca.js +1 -0
  6. package/dist/cjs/src/base/Exchange.js +11 -4
  7. package/dist/cjs/src/base/errors.js +8 -1
  8. package/dist/cjs/src/binance.js +6 -9
  9. package/dist/cjs/src/bingx.js +554 -151
  10. package/dist/cjs/src/bitfinex.js +1 -1
  11. package/dist/cjs/src/bitfinex2.js +1 -1
  12. package/dist/cjs/src/cryptocom.js +18 -2
  13. package/dist/cjs/src/independentreserve.js +107 -0
  14. package/dist/cjs/src/kucoin.js +2 -0
  15. package/dist/cjs/src/mercado.js +5 -1
  16. package/dist/cjs/src/pro/binance.js +58 -34
  17. package/dist/cjs/src/pro/bitfinex2.js +6 -3
  18. package/dist/cjs/src/pro/bitget.js +4 -1
  19. package/dist/cjs/src/pro/bitmart.js +3 -3
  20. package/dist/cjs/src/pro/bitvavo.js +1 -1
  21. package/dist/cjs/src/pro/bybit.js +44 -18
  22. package/dist/cjs/src/pro/cryptocom.js +7 -1
  23. package/dist/cjs/src/pro/gate.js +7 -3
  24. package/dist/cjs/src/pro/gemini.js +4 -2
  25. package/dist/cjs/src/pro/htx.js +5 -1
  26. package/dist/cjs/src/pro/independentreserve.js +5 -3
  27. package/dist/cjs/src/pro/kraken.js +82 -4
  28. package/dist/cjs/src/pro/okx.js +3 -3
  29. package/dist/cjs/src/pro/onetrading.js +3 -2
  30. package/dist/cjs/src/pro/poloniexfutures.js +5 -1
  31. package/dist/cjs/src/pro/vertex.js +3 -2
  32. package/dist/cjs/src/pro/woo.js +2 -1
  33. package/dist/cjs/src/pro/woofipro.js +3 -2
  34. package/dist/cjs/src/woo.js +344 -81
  35. package/js/ccxt.d.ts +3 -3
  36. package/js/ccxt.js +3 -3
  37. package/js/src/abstract/cryptocom.d.ts +11 -0
  38. package/js/src/abstract/kucoin.d.ts +1 -0
  39. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  40. package/js/src/abstract/woo.d.ts +3 -0
  41. package/js/src/ace.js +34 -15
  42. package/js/src/alpaca.js +1 -0
  43. package/js/src/base/Exchange.d.ts +1 -0
  44. package/js/src/base/Exchange.js +11 -4
  45. package/js/src/base/errorHierarchy.d.ts +3 -1
  46. package/js/src/base/errorHierarchy.js +3 -1
  47. package/js/src/base/errors.d.ts +5 -1
  48. package/js/src/base/errors.js +8 -2
  49. package/js/src/binance.js +6 -9
  50. package/js/src/bingx.d.ts +4 -1
  51. package/js/src/bingx.js +554 -151
  52. package/js/src/bitfinex.js +1 -1
  53. package/js/src/bitfinex2.js +1 -1
  54. package/js/src/coinbaseinternational.d.ts +1 -1
  55. package/js/src/cryptocom.js +18 -2
  56. package/js/src/independentreserve.d.ts +3 -1
  57. package/js/src/independentreserve.js +106 -0
  58. package/js/src/kucoin.js +2 -0
  59. package/js/src/mercado.js +5 -1
  60. package/js/src/pro/binance.d.ts +1 -0
  61. package/js/src/pro/binance.js +59 -35
  62. package/js/src/pro/bitfinex2.js +7 -4
  63. package/js/src/pro/bitget.js +5 -2
  64. package/js/src/pro/bitmart.js +3 -3
  65. package/js/src/pro/bitvavo.js +1 -1
  66. package/js/src/pro/bybit.d.ts +1 -0
  67. package/js/src/pro/bybit.js +44 -18
  68. package/js/src/pro/cryptocom.js +8 -2
  69. package/js/src/pro/gate.js +8 -4
  70. package/js/src/pro/gemini.js +4 -2
  71. package/js/src/pro/htx.js +6 -2
  72. package/js/src/pro/independentreserve.js +6 -4
  73. package/js/src/pro/kraken.d.ts +3 -1
  74. package/js/src/pro/kraken.js +83 -5
  75. package/js/src/pro/okx.js +4 -4
  76. package/js/src/pro/onetrading.js +3 -2
  77. package/js/src/pro/poloniexfutures.js +6 -2
  78. package/js/src/pro/vertex.js +3 -2
  79. package/js/src/pro/woo.js +2 -1
  80. package/js/src/pro/woofipro.js +3 -2
  81. package/js/src/whitebit.d.ts +1 -1
  82. package/js/src/woo.d.ts +6 -2
  83. package/js/src/woo.js +344 -81
  84. package/js/src/xt.d.ts +3 -3
  85. package/js/src/zonda.d.ts +1 -1
  86. package/package.json +1 -1
@@ -4,6 +4,7 @@ var gemini$1 = require('../gemini.js');
4
4
  var Cache = require('../base/ws/Cache.js');
5
5
  var errors = require('../base/errors.js');
6
6
  var sha512 = require('../static_dependencies/noble-hashes/sha512.js');
7
+ var Precise = require('../base/Precise.js');
7
8
 
8
9
  // ---------------------------------------------------------------------------
9
10
  // ---------------------------------------------------------------------------
@@ -470,10 +471,11 @@ class gemini extends gemini$1 {
470
471
  const entry = rawBidAskChanges[i];
471
472
  const rawSide = this.safeString(entry, 'side');
472
473
  const price = this.safeNumber(entry, 'price');
473
- const size = this.safeNumber(entry, 'remaining');
474
- if (size === 0) {
474
+ const sizeString = this.safeString(entry, 'remaining');
475
+ if (Precise["default"].stringEq(sizeString, '0')) {
475
476
  continue;
476
477
  }
478
+ const size = this.parseNumber(sizeString);
477
479
  if (rawSide === 'bid') {
478
480
  currentBidAsk['bid'] = price;
479
481
  currentBidAsk['bidVolume'] = size;
@@ -97,6 +97,7 @@ class htx extends htx$1 {
97
97
  'api': 'api',
98
98
  'watchOrderBook': {
99
99
  'maxRetries': 3,
100
+ 'checksum': true,
100
101
  },
101
102
  'ws': {
102
103
  'gunzip': true,
@@ -568,7 +569,10 @@ class htx extends htx$1 {
568
569
  orderbook['nonce'] = version;
569
570
  }
570
571
  if ((prevSeqNum !== undefined) && prevSeqNum > orderbook['nonce']) {
571
- throw new errors.InvalidNonce(this.id + ' watchOrderBook() received a mesage out of order');
572
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
573
+ if (checksum) {
574
+ throw new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
575
+ }
572
576
  }
573
577
  const spotConditon = market['spot'] && (prevSeqNum === orderbook['nonce']);
574
578
  const nonSpotCondition = market['contract'] && (version - 1 === orderbook['nonce']);
@@ -26,7 +26,9 @@ class independentreserve extends independentreserve$1 {
26
26
  },
27
27
  },
28
28
  'options': {
29
- 'checksum': false, // TODO: currently only working for snapshot
29
+ 'watchOrderBook': {
30
+ 'checksum': true, // TODO: currently only working for snapshot
31
+ },
30
32
  },
31
33
  'streaming': {},
32
34
  'exceptions': {},
@@ -196,7 +198,7 @@ class independentreserve extends independentreserve$1 {
196
198
  orderbook['timestamp'] = timestamp;
197
199
  orderbook['datetime'] = this.iso8601(timestamp);
198
200
  }
199
- const checksum = this.safeBool(this.options, 'checksum', true);
201
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
200
202
  if (checksum && receivedSnapshot) {
201
203
  const storedAsks = orderbook['asks'];
202
204
  const storedBids = orderbook['bids'];
@@ -216,7 +218,7 @@ class independentreserve extends independentreserve$1 {
216
218
  const calculatedChecksum = this.crc32(payload, true);
217
219
  const responseChecksum = this.safeInteger(orderBook, 'Crc32');
218
220
  if (calculatedChecksum !== responseChecksum) {
219
- const error = new errors.InvalidNonce(this.id + ' invalid checksum');
221
+ const error = new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
220
222
  delete client.subscriptions[messageHash];
221
223
  delete this.orderbooks[symbol];
222
224
  client.reject(error, messageHash);
@@ -12,7 +12,7 @@ class kraken extends kraken$1 {
12
12
  return this.deepExtend(super.describe(), {
13
13
  'has': {
14
14
  'ws': true,
15
- 'watchBalance': false,
15
+ 'watchBalance': true,
16
16
  'watchMyTrades': true,
17
17
  'watchOHLCV': true,
18
18
  'watchOrderBook': true,
@@ -35,6 +35,7 @@ class kraken extends kraken$1 {
35
35
  'ws': {
36
36
  'public': 'wss://ws.kraken.com',
37
37
  'private': 'wss://ws-auth.kraken.com',
38
+ 'privateV2': 'wss://ws-auth.kraken.com/v2',
38
39
  'beta': 'wss://beta-ws.kraken.com',
39
40
  'beta-private': 'wss://beta-ws-auth.kraken.com',
40
41
  },
@@ -48,7 +49,9 @@ class kraken extends kraken$1 {
48
49
  'OHLCVLimit': 1000,
49
50
  'ordersLimit': 1000,
50
51
  'symbolsByOrderId': {},
51
- 'checksum': true,
52
+ 'watchOrderBook': {
53
+ 'checksum': true,
54
+ },
52
55
  },
53
56
  'exceptions': {
54
57
  'ws': {
@@ -746,7 +749,7 @@ class kraken extends kraken$1 {
746
749
  }
747
750
  // don't remove this line or I will poop on your face
748
751
  orderbook.limit();
749
- const checksum = this.safeBool(this.options, 'checksum', true);
752
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
750
753
  if (checksum) {
751
754
  const priceString = this.safeString(example, 0);
752
755
  const amountString = this.safeString(example, 1);
@@ -768,7 +771,7 @@ class kraken extends kraken$1 {
768
771
  const payload = payloadArray.join('');
769
772
  const localChecksum = this.crc32(payload, false);
770
773
  if (localChecksum !== c) {
771
- const error = new errors.InvalidNonce(this.id + ' invalid checksum');
774
+ const error = new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
772
775
  delete client.subscriptions[messageHash];
773
776
  delete this.orderbooks[symbol];
774
777
  client.reject(error, messageHash);
@@ -1326,6 +1329,71 @@ class kraken extends kraken$1 {
1326
1329
  const url = this.urls['api']['ws']['public'];
1327
1330
  return await this.watchMultiple(url, messageHashes, this.deepExtend(request, params), messageHashes, subscriptionArgs);
1328
1331
  }
1332
+ async watchBalance(params = {}) {
1333
+ /**
1334
+ * @method
1335
+ * @name kraken#watchBalance
1336
+ * @description watch balance and get the amount of funds available for trading or funds locked in orders
1337
+ * @see https://docs.kraken.com/api/docs/websocket-v2/balances
1338
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1339
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1340
+ */
1341
+ await this.loadMarkets();
1342
+ const token = await this.authenticate();
1343
+ const messageHash = 'balances';
1344
+ const url = this.urls['api']['ws']['privateV2'];
1345
+ const requestId = this.requestId();
1346
+ const subscribe = {
1347
+ 'method': 'subscribe',
1348
+ 'req_id': requestId,
1349
+ 'params': {
1350
+ 'channel': 'balances',
1351
+ 'token': token,
1352
+ },
1353
+ };
1354
+ const request = this.deepExtend(subscribe, params);
1355
+ return await this.watch(url, messageHash, request, messageHash);
1356
+ }
1357
+ handleBalance(client, message) {
1358
+ //
1359
+ // {
1360
+ // "channel": "balances",
1361
+ // "data": [
1362
+ // {
1363
+ // "asset": "BTC",
1364
+ // "asset_class": "currency",
1365
+ // "balance": 1.2,
1366
+ // "wallets": [
1367
+ // {
1368
+ // "type": "spot",
1369
+ // "id": "main",
1370
+ // "balance": 1.2
1371
+ // }
1372
+ // ]
1373
+ // }
1374
+ // ],
1375
+ // "type": "snapshot",
1376
+ // "sequence": 1
1377
+ // }
1378
+ //
1379
+ const data = this.safeList(message, 'data', []);
1380
+ const result = { 'info': message };
1381
+ for (let i = 0; i < data.length; i++) {
1382
+ const currencyId = this.safeString(data[i], 'asset');
1383
+ const code = this.safeCurrencyCode(currencyId);
1384
+ const account = this.account();
1385
+ const eq = this.safeString(data[i], 'balance');
1386
+ account['total'] = eq;
1387
+ result[code] = account;
1388
+ }
1389
+ const type = 'spot';
1390
+ const balance = this.safeBalance(result);
1391
+ const oldBalance = this.safeValue(this.balance, type, {});
1392
+ const newBalance = this.deepExtend(oldBalance, balance);
1393
+ this.balance[type] = this.safeBalance(newBalance);
1394
+ const channel = this.safeString(message, 'channel');
1395
+ client.resolve(this.balance[type], channel);
1396
+ }
1329
1397
  getMessageHash(unifiedElementName, subChannelName = undefined, symbol = undefined) {
1330
1398
  // unifiedElementName can be : orderbook, trade, ticker, bidask ...
1331
1399
  // subChannelName only applies to channel that needs specific variation (i.e. depth_50, depth_100..) to be selected
@@ -1429,6 +1497,16 @@ class kraken extends kraken$1 {
1429
1497
  }
1430
1498
  }
1431
1499
  else {
1500
+ const channel = this.safeString(message, 'channel');
1501
+ if (channel !== undefined) {
1502
+ const methods = {
1503
+ 'balances': this.handleBalance,
1504
+ };
1505
+ const method = this.safeValue(methods, channel);
1506
+ if (method !== undefined) {
1507
+ method.call(this, client, message);
1508
+ }
1509
+ }
1432
1510
  if (this.handleErrorMessage(client, message)) {
1433
1511
  const event = this.safeString(message, 'event');
1434
1512
  const methods = {
@@ -46,6 +46,7 @@ class okx extends okx$1 {
46
46
  },
47
47
  'options': {
48
48
  'watchOrderBook': {
49
+ 'checksum': true,
49
50
  //
50
51
  // bbo-tbt
51
52
  // 1. Newly added channel that sends tick-by-tick Level 1 data
@@ -93,7 +94,6 @@ class okx extends okx$1 {
93
94
  'ws': {
94
95
  // 'inflate': true,
95
96
  },
96
- 'checksum': true,
97
97
  },
98
98
  'streaming': {
99
99
  // okex does not support built-in ws protocol-level ping-pong
@@ -919,7 +919,7 @@ class okx extends okx$1 {
919
919
  this.handleDeltas(storedBids, bids);
920
920
  const marketId = this.safeString(message, 'instId');
921
921
  const symbol = this.safeSymbol(marketId);
922
- const checksum = this.safeBool(this.options, 'checksum', true);
922
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
923
923
  if (checksum) {
924
924
  const asksLength = storedAsks.length;
925
925
  const bidsLength = storedBids.length;
@@ -938,7 +938,7 @@ class okx extends okx$1 {
938
938
  const responseChecksum = this.safeInteger(message, 'checksum');
939
939
  const localChecksum = this.crc32(payload, true);
940
940
  if (responseChecksum !== localChecksum) {
941
- const error = new errors.InvalidNonce(this.id + ' invalid checksum');
941
+ const error = new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
942
942
  delete client.subscriptions[messageHash];
943
943
  delete this.orderbooks[symbol];
944
944
  client.reject(error, messageHash);
@@ -3,6 +3,7 @@
3
3
  var onetrading$1 = require('../onetrading.js');
4
4
  var errors = require('../base/errors.js');
5
5
  var Cache = require('../base/ws/Cache.js');
6
+ var Precise = require('../base/Precise.js');
6
7
 
7
8
  // ---------------------------------------------------------------------------
8
9
  // ---------------------------------------------------------------------------
@@ -962,9 +963,9 @@ class onetrading extends onetrading$1 {
962
963
  const previousOrderArray = this.filterByArray(this.orders, 'id', orderId, false);
963
964
  const previousOrder = this.safeValue(previousOrderArray, 0, {});
964
965
  symbol = previousOrder['symbol'];
965
- const filled = this.safeNumber(update, 'filled_amount');
966
+ const filled = this.safeString(update, 'filled_amount');
966
967
  let status = this.parseWsOrderStatus(updateType);
967
- if (updateType === 'ORDER_CLOSED' && filled === 0) {
968
+ if (updateType === 'ORDER_CLOSED' && Precise["default"].stringEq(filled, '0')) {
968
969
  status = 'canceled';
969
970
  }
970
971
  const orderObject = {
@@ -49,6 +49,7 @@ class poloniexfutures extends poloniexfutures$1 {
49
49
  'method': '/contractMarket/level2',
50
50
  'snapshotDelay': 5,
51
51
  'snapshotMaxRetries': 3,
52
+ 'checksum': true,
52
53
  },
53
54
  'streamLimit': 5,
54
55
  'streamBySubscriptionsHash': {},
@@ -857,7 +858,10 @@ class poloniexfutures extends poloniexfutures$1 {
857
858
  return;
858
859
  }
859
860
  if (nonce !== lastSequence) {
860
- throw new errors.InvalidNonce(this.id + ' watchOrderBook received an out-of-order nonce');
861
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
862
+ if (checksum) {
863
+ throw new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(''));
864
+ }
861
865
  }
862
866
  const changes = this.safeList(delta, 'changes');
863
867
  for (let i = 0; i < changes.length; i++) {
@@ -842,9 +842,10 @@ class vertex extends vertex$1 {
842
842
  //
843
843
  const marketId = this.safeString(order, 'product_id');
844
844
  const timestamp = this.parseToInt(Precise["default"].stringDiv(this.safeString(order, 'timestamp'), '1000000'));
845
- const remaining = this.parseToNumeric(this.convertFromX18(this.safeString(order, 'amount')));
845
+ const remainingString = this.convertFromX18(this.safeString(order, 'amount'));
846
+ const remaining = this.parseToNumeric(remainingString);
846
847
  let status = this.parseWsOrderStatus(this.safeString(order, 'reason'));
847
- if (remaining === 0 && status === 'open') {
848
+ if (Precise["default"].stringEq(remainingString, '0') && status === 'open') {
848
849
  status = 'closed';
849
850
  }
850
851
  market = this.safeMarket(marketId, market);
@@ -662,9 +662,10 @@ class woo extends woo$1 {
662
662
  'cost': this.safeString(order, 'totalFee'),
663
663
  'currency': this.safeString(order, 'feeAsset'),
664
664
  };
665
+ const priceString = this.safeString(order, 'price');
665
666
  let price = this.safeNumber(order, 'price');
666
667
  const avgPrice = this.safeNumber(order, 'avgPrice');
667
- if ((price === 0) && (avgPrice !== undefined)) {
668
+ if (Precise["default"].stringEq(priceString, '0') && (avgPrice !== undefined)) {
668
669
  price = avgPrice;
669
670
  }
670
671
  const amount = this.safeFloat(order, 'quantity');
@@ -374,7 +374,7 @@ class woofipro extends woofipro$1 {
374
374
  * @param {int} [since] the earliest time in ms to fetch trades for
375
375
  * @param {int} [limit] the maximum number of trade structures to retrieve
376
376
  * @param {object} [params] extra parameters specific to the exchange API endpoint
377
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
377
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
378
378
  */
379
379
  await this.loadMarkets();
380
380
  const market = this.market(symbol);
@@ -714,9 +714,10 @@ class woofipro extends woofipro$1 {
714
714
  'cost': this.safeString(order, 'totalFee'),
715
715
  'currency': this.safeString(order, 'feeAsset'),
716
716
  };
717
+ const priceString = this.safeString(order, 'price');
717
718
  let price = this.safeNumber(order, 'price');
718
719
  const avgPrice = this.safeNumber(order, 'avgPrice');
719
- if ((price === 0) && (avgPrice !== undefined)) {
720
+ if (Precise["default"].stringEq(priceString, '0') && (avgPrice !== undefined)) {
720
721
  price = avgPrice;
721
722
  }
722
723
  const amount = this.safeString(order, 'quantity');