ccxt 4.3.61 → 4.3.63

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 (104) 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/base/Exchange.js +8 -1
  6. package/dist/cjs/src/base/errors.js +8 -1
  7. package/dist/cjs/src/binance.js +50 -43
  8. package/dist/cjs/src/bingx.js +507 -184
  9. package/dist/cjs/src/bybit.js +1 -1
  10. package/dist/cjs/src/cryptocom.js +18 -2
  11. package/dist/cjs/src/mercado.js +5 -1
  12. package/dist/cjs/src/pro/alpaca.js +3 -3
  13. package/dist/cjs/src/pro/binance.js +60 -38
  14. package/dist/cjs/src/pro/bingx.js +2 -2
  15. package/dist/cjs/src/pro/bitfinex2.js +8 -5
  16. package/dist/cjs/src/pro/bitget.js +5 -2
  17. package/dist/cjs/src/pro/bitmex.js +1 -1
  18. package/dist/cjs/src/pro/bitopro.js +1 -1
  19. package/dist/cjs/src/pro/bitvavo.js +1 -1
  20. package/dist/cjs/src/pro/bybit.js +49 -23
  21. package/dist/cjs/src/pro/coinbaseexchange.js +2 -2
  22. package/dist/cjs/src/pro/coincheck.js +1 -1
  23. package/dist/cjs/src/pro/coinone.js +1 -1
  24. package/dist/cjs/src/pro/cryptocom.js +8 -2
  25. package/dist/cjs/src/pro/deribit.js +1 -1
  26. package/dist/cjs/src/pro/gate.js +8 -4
  27. package/dist/cjs/src/pro/hollaex.js +1 -1
  28. package/dist/cjs/src/pro/htx.js +6 -2
  29. package/dist/cjs/src/pro/hyperliquid.js +3 -3
  30. package/dist/cjs/src/pro/independentreserve.js +5 -3
  31. package/dist/cjs/src/pro/kraken.js +83 -5
  32. package/dist/cjs/src/pro/kucoin.js +1 -1
  33. package/dist/cjs/src/pro/mexc.js +1 -1
  34. package/dist/cjs/src/pro/okx.js +4 -4
  35. package/dist/cjs/src/pro/oxfun.js +1 -1
  36. package/dist/cjs/src/pro/phemex.js +1 -1
  37. package/dist/cjs/src/pro/poloniexfutures.js +5 -1
  38. package/dist/cjs/src/pro/upbit.js +1 -1
  39. package/dist/cjs/src/pro/vertex.js +2 -2
  40. package/dist/cjs/src/pro/whitebit.js +1 -1
  41. package/dist/cjs/src/pro/woo.js +1 -1
  42. package/dist/cjs/src/pro/woofipro.js +1 -1
  43. package/dist/cjs/src/tradeogre.js +1 -1
  44. package/dist/cjs/src/woo.js +313 -81
  45. package/dist/cjs/src/xt.js +1 -1
  46. package/js/ccxt.d.ts +3 -3
  47. package/js/ccxt.js +3 -3
  48. package/js/src/abstract/cryptocom.d.ts +11 -0
  49. package/js/src/abstract/woo.d.ts +3 -0
  50. package/js/src/ace.js +34 -15
  51. package/js/src/base/Exchange.d.ts +1 -0
  52. package/js/src/base/Exchange.js +8 -1
  53. package/js/src/base/errorHierarchy.d.ts +3 -1
  54. package/js/src/base/errorHierarchy.js +3 -1
  55. package/js/src/base/errors.d.ts +5 -1
  56. package/js/src/base/errors.js +8 -2
  57. package/js/src/base/ws/Client.d.ts +1 -1
  58. package/js/src/binance.js +50 -43
  59. package/js/src/bingx.d.ts +1 -0
  60. package/js/src/bingx.js +507 -184
  61. package/js/src/bybit.js +1 -1
  62. package/js/src/coinbaseinternational.d.ts +1 -1
  63. package/js/src/cryptocom.js +18 -2
  64. package/js/src/mercado.js +5 -1
  65. package/js/src/pro/alpaca.js +3 -3
  66. package/js/src/pro/binance.d.ts +1 -0
  67. package/js/src/pro/binance.js +61 -39
  68. package/js/src/pro/bingx.js +2 -2
  69. package/js/src/pro/bitfinex2.js +9 -6
  70. package/js/src/pro/bitget.js +6 -3
  71. package/js/src/pro/bitmex.js +1 -1
  72. package/js/src/pro/bitopro.js +1 -1
  73. package/js/src/pro/bitvavo.js +1 -1
  74. package/js/src/pro/bybit.d.ts +1 -0
  75. package/js/src/pro/bybit.js +49 -23
  76. package/js/src/pro/coinbaseexchange.js +2 -2
  77. package/js/src/pro/coincheck.js +1 -1
  78. package/js/src/pro/coinone.js +1 -1
  79. package/js/src/pro/cryptocom.js +9 -3
  80. package/js/src/pro/deribit.js +1 -1
  81. package/js/src/pro/gate.js +9 -5
  82. package/js/src/pro/hollaex.js +1 -1
  83. package/js/src/pro/htx.js +7 -3
  84. package/js/src/pro/hyperliquid.js +3 -3
  85. package/js/src/pro/independentreserve.js +6 -4
  86. package/js/src/pro/kraken.d.ts +3 -1
  87. package/js/src/pro/kraken.js +84 -6
  88. package/js/src/pro/kucoin.js +1 -1
  89. package/js/src/pro/mexc.js +1 -1
  90. package/js/src/pro/okx.js +5 -5
  91. package/js/src/pro/oxfun.js +1 -1
  92. package/js/src/pro/phemex.js +1 -1
  93. package/js/src/pro/poloniexfutures.js +6 -2
  94. package/js/src/pro/upbit.js +1 -1
  95. package/js/src/pro/vertex.js +2 -2
  96. package/js/src/pro/whitebit.js +1 -1
  97. package/js/src/pro/woo.js +1 -1
  98. package/js/src/pro/woofipro.js +1 -1
  99. package/js/src/tradeogre.js +1 -1
  100. package/js/src/woo.d.ts +5 -1
  101. package/js/src/woo.js +313 -81
  102. package/js/src/xt.d.ts +3 -3
  103. package/js/src/xt.js +1 -1
  104. package/package.json +1 -1
@@ -201,7 +201,7 @@ export default class coinbaseexchange extends coinbaseexchangeRest {
201
201
  * @param {int} [since] the earliest time in ms to fetch trades for
202
202
  * @param {int} [limit] the maximum number of trade structures to retrieve
203
203
  * @param {object} [params] extra parameters specific to the exchange API endpoint
204
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
204
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
205
205
  */
206
206
  if (symbol === undefined) {
207
207
  throw new ArgumentsRequired(this.id + ' watchMyTrades() requires a symbol argument');
@@ -226,7 +226,7 @@ export default class coinbaseexchange extends coinbaseexchangeRest {
226
226
  * @param {int} [since] the earliest time in ms to fetch trades for
227
227
  * @param {int} [limit] the maximum number of trade structures to retrieve
228
228
  * @param {object} [params] extra parameters specific to the exchange API endpoint
229
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
229
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
230
230
  */
231
231
  symbols = this.marketSymbols(symbols, undefined, false);
232
232
  await this.loadMarkets();
@@ -114,7 +114,7 @@ export default class coincheck extends coincheckRest {
114
114
  * @param {int} [since] the earliest time in ms to fetch trades for
115
115
  * @param {int} [limit] the maximum number of trade structures to retrieve
116
116
  * @param {object} [params] extra parameters specific to the exchange API endpoint
117
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
117
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
118
118
  */
119
119
  await this.loadMarkets();
120
120
  const market = this.market(symbol);
@@ -257,7 +257,7 @@ export default class coinone extends coinoneRest {
257
257
  * @param {int} [since] the earliest time in ms to fetch trades for
258
258
  * @param {int} [limit] the maximum number of trade structures to retrieve
259
259
  * @param {object} [params] extra parameters specific to the exchange API endpoint
260
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
260
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
261
261
  */
262
262
  await this.loadMarkets();
263
263
  const market = this.market(symbol);
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import cryptocomRest from '../cryptocom.js';
9
- import { AuthenticationError, InvalidNonce, NetworkError } from '../base/errors.js';
9
+ import { AuthenticationError, ChecksumError, NetworkError } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
11
11
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
12
12
  // ---------------------------------------------------------------------------
@@ -47,6 +47,9 @@ export default class cryptocom extends cryptocomRest {
47
47
  'fetchPositionsSnapshot': true,
48
48
  'awaitPositionsSnapshot': true, // whether to wait for the positions snapshot before providing updates
49
49
  },
50
+ 'watchOrderBook': {
51
+ 'checksum': true,
52
+ },
50
53
  },
51
54
  'streaming': {},
52
55
  });
@@ -220,7 +223,10 @@ export default class cryptocom extends cryptocomRest {
220
223
  const previousNonce = this.safeInteger(data, 'pu');
221
224
  const currentNonce = orderbook['nonce'];
222
225
  if (currentNonce !== previousNonce) {
223
- throw new InvalidNonce(this.id + ' watchOrderBook() ' + symbol + ' ' + previousNonce + ' != ' + nonce);
226
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
227
+ if (checksum) {
228
+ throw new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
229
+ }
224
230
  }
225
231
  }
226
232
  this.handleDeltas(orderbook['asks'], this.safeValue(books, 'asks', []));
@@ -330,7 +336,7 @@ export default class cryptocom extends cryptocomRest {
330
336
  * @param {int} [since] the earliest time in ms to fetch trades for
331
337
  * @param {int} [limit] the maximum number of trade structures to retrieve
332
338
  * @param {object} [params] extra parameters specific to the exchange API endpoint
333
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
339
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
334
340
  */
335
341
  await this.loadMarkets();
336
342
  let market = undefined;
@@ -566,7 +566,7 @@ export default class deribit extends deribitRest {
566
566
  * @param {int} [since] the earliest time in ms to fetch orders for
567
567
  * @param {int} [limit] the maximum number of order structures to retrieve
568
568
  * @param {object} [params] extra parameters specific to the exchange API endpoint
569
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
569
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
570
570
  */
571
571
  await this.loadMarkets();
572
572
  await this.authenticate(params);
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import gateRest from '../gate.js';
9
- import { AuthenticationError, BadRequest, ArgumentsRequired, InvalidNonce, ExchangeError, NotSupported } from '../base/errors.js';
9
+ import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, NotSupported } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
11
11
  import { sha512 } from '../static_dependencies/noble-hashes/sha512.js';
12
12
  import Precise from '../base/Precise.js';
@@ -97,6 +97,7 @@ export default class gate extends gateRest {
97
97
  'interval': '100ms',
98
98
  'snapshotDelay': 10,
99
99
  'snapshotMaxRetries': 3,
100
+ 'checksum': true,
100
101
  },
101
102
  'watchBalance': {
102
103
  'settle': 'usdt',
@@ -482,10 +483,13 @@ export default class gate extends gateRest {
482
483
  this.handleDelta(storedOrderBook, delta);
483
484
  }
484
485
  else {
485
- const error = new InvalidNonce(this.id + ' orderbook update has a nonce bigger than u');
486
486
  delete client.subscriptions[messageHash];
487
487
  delete this.orderbooks[symbol];
488
- client.reject(error, messageHash);
488
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
489
+ if (checksum) {
490
+ const error = new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
491
+ client.reject(error, messageHash);
492
+ }
489
493
  }
490
494
  client.resolve(storedOrderBook, messageHash);
491
495
  }
@@ -845,7 +849,7 @@ export default class gate extends gateRest {
845
849
  * @param {int} [since] the earliest time in ms to fetch trades for
846
850
  * @param {int} [limit] the maximum number of trade structures to retrieve
847
851
  * @param {object} [params] extra parameters specific to the exchange API endpoint
848
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
852
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
849
853
  */
850
854
  await this.loadMarkets();
851
855
  let subType = undefined;
@@ -1193,7 +1197,7 @@ export default class gate extends gateRest {
1193
1197
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1194
1198
  * @param {string} [params.type] spot, margin, swap, future, or option. Required if listening to all symbols.
1195
1199
  * @param {boolean} [params.isInverse] if future, listen to inverse or linear contracts
1196
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
1200
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1197
1201
  */
1198
1202
  await this.loadMarkets();
1199
1203
  let market = undefined;
@@ -176,7 +176,7 @@ export default class hollaex extends hollaexRest {
176
176
  * @param {int} [since] the earliest time in ms to fetch trades for
177
177
  * @param {int} [limit] the maximum number of trade structures to retrieve
178
178
  * @param {object} [params] extra parameters specific to the exchange API endpoint
179
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
179
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
180
180
  */
181
181
  await this.loadMarkets();
182
182
  let messageHash = 'usertrade';
package/js/src/pro/htx.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import htxRest from '../htx.js';
9
- import { ExchangeError, InvalidNonce, ArgumentsRequired, BadRequest, BadSymbol, AuthenticationError, NetworkError } from '../base/errors.js';
9
+ import { ExchangeError, InvalidNonce, ChecksumError, ArgumentsRequired, BadRequest, BadSymbol, AuthenticationError, NetworkError } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
11
11
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
12
12
  // ---------------------------------------------------------------------------
@@ -100,6 +100,7 @@ export default class htx extends htxRest {
100
100
  'api': 'api',
101
101
  'watchOrderBook': {
102
102
  'maxRetries': 3,
103
+ 'checksum': true,
103
104
  },
104
105
  'ws': {
105
106
  'gunzip': true,
@@ -571,7 +572,10 @@ export default class htx extends htxRest {
571
572
  orderbook['nonce'] = version;
572
573
  }
573
574
  if ((prevSeqNum !== undefined) && prevSeqNum > orderbook['nonce']) {
574
- throw new InvalidNonce(this.id + ' watchOrderBook() received a mesage out of order');
575
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
576
+ if (checksum) {
577
+ throw new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
578
+ }
575
579
  }
576
580
  const spotConditon = market['spot'] && (prevSeqNum === orderbook['nonce']);
577
581
  const nonSpotCondition = market['contract'] && (version - 1 === orderbook['nonce']);
@@ -671,7 +675,7 @@ export default class htx extends htxRest {
671
675
  * @param {int} [since] the earliest time in ms to fetch trades for
672
676
  * @param {int} [limit] the maximum number of trade structures to retrieve
673
677
  * @param {object} [params] extra parameters specific to the exchange API endpoint
674
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
678
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
675
679
  */
676
680
  this.checkRequiredCredentials();
677
681
  await this.loadMarkets();
@@ -131,7 +131,7 @@ export default class hyperliquid extends hyperliquidRest {
131
131
  * @param {int} [limit] the maximum number of order structures to retrieve
132
132
  * @param {object} [params] extra parameters specific to the exchange API endpoint
133
133
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
134
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
134
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
135
135
  */
136
136
  let userAddress = undefined;
137
137
  [userAddress, params] = this.handlePublicAddress('watchMyTrades', params);
@@ -222,7 +222,7 @@ export default class hyperliquid extends hyperliquidRest {
222
222
  * @param {int} [since] the earliest time in ms to fetch trades for
223
223
  * @param {int} [limit] the maximum number of trade structures to retrieve
224
224
  * @param {object} [params] extra parameters specific to the exchange API endpoint
225
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
225
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
226
226
  */
227
227
  await this.loadMarkets();
228
228
  const market = this.market(symbol);
@@ -422,7 +422,7 @@ export default class hyperliquid extends hyperliquidRest {
422
422
  * @param {int} [limit] the maximum number of order structures to retrieve
423
423
  * @param {object} [params] extra parameters specific to the exchange API endpoint
424
424
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
425
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
425
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
426
426
  */
427
427
  await this.loadMarkets();
428
428
  let userAddress = undefined;
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import independentreserveRest from '../independentreserve.js';
9
- import { NotSupported, InvalidNonce } from '../base/errors.js';
9
+ import { NotSupported, ChecksumError } from '../base/errors.js';
10
10
  import { ArrayCache } from '../base/ws/Cache.js';
11
11
  // ---------------------------------------------------------------------------
12
12
  export default class independentreserve extends independentreserveRest {
@@ -29,7 +29,9 @@ export default class independentreserve extends independentreserveRest {
29
29
  },
30
30
  },
31
31
  'options': {
32
- 'checksum': false, // TODO: currently only working for snapshot
32
+ 'watchOrderBook': {
33
+ 'checksum': true, // TODO: currently only working for snapshot
34
+ },
33
35
  },
34
36
  'streaming': {},
35
37
  'exceptions': {},
@@ -199,7 +201,7 @@ export default class independentreserve extends independentreserveRest {
199
201
  orderbook['timestamp'] = timestamp;
200
202
  orderbook['datetime'] = this.iso8601(timestamp);
201
203
  }
202
- const checksum = this.safeBool(this.options, 'checksum', true);
204
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
203
205
  if (checksum && receivedSnapshot) {
204
206
  const storedAsks = orderbook['asks'];
205
207
  const storedBids = orderbook['bids'];
@@ -219,7 +221,7 @@ export default class independentreserve extends independentreserveRest {
219
221
  const calculatedChecksum = this.crc32(payload, true);
220
222
  const responseChecksum = this.safeInteger(orderBook, 'Crc32');
221
223
  if (calculatedChecksum !== responseChecksum) {
222
- const error = new InvalidNonce(this.id + ' invalid checksum');
224
+ const error = new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
223
225
  delete client.subscriptions[messageHash];
224
226
  delete this.orderbooks[symbol];
225
227
  client.reject(error, messageHash);
@@ -1,5 +1,5 @@
1
1
  import krakenRest from '../kraken.js';
2
- import type { Int, Strings, OrderSide, OrderType, Str, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Num } from '../base/types.js';
2
+ import type { Int, Strings, OrderSide, OrderType, Str, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Num, Balances } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class kraken extends krakenRest {
5
5
  describe(): any;
@@ -53,6 +53,8 @@ export default class kraken extends krakenRest {
53
53
  handleOrders(client: Client, message: any, subscription?: any): void;
54
54
  parseWsOrder(order: any, market?: any): Order;
55
55
  watchMultiHelper(unifiedName: string, channelName: string, symbols?: Strings, subscriptionArgs?: any, params?: {}): Promise<any>;
56
+ watchBalance(params?: {}): Promise<Balances>;
57
+ handleBalance(client: Client, message: any): void;
56
58
  getMessageHash(unifiedElementName: string, subChannelName?: Str, symbol?: Str): string;
57
59
  handleSubscriptionStatus(client: Client, message: any): void;
58
60
  handleErrorMessage(client: Client, message: any): boolean;
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import krakenRest from '../kraken.js';
9
- import { ExchangeError, BadSymbol, PermissionDenied, AccountSuspended, BadRequest, InsufficientFunds, InvalidOrder, OrderNotFound, NotSupported, RateLimitExceeded, ExchangeNotAvailable, InvalidNonce, AuthenticationError } from '../base/errors.js';
9
+ import { ExchangeError, BadSymbol, PermissionDenied, AccountSuspended, BadRequest, InsufficientFunds, InvalidOrder, OrderNotFound, NotSupported, RateLimitExceeded, ExchangeNotAvailable, ChecksumError, AuthenticationError } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
11
11
  import { Precise } from '../base/Precise.js';
12
12
  // ---------------------------------------------------------------------------
@@ -15,7 +15,7 @@ export default class kraken extends krakenRest {
15
15
  return this.deepExtend(super.describe(), {
16
16
  'has': {
17
17
  'ws': true,
18
- 'watchBalance': false,
18
+ 'watchBalance': true,
19
19
  'watchMyTrades': true,
20
20
  'watchOHLCV': true,
21
21
  'watchOrderBook': true,
@@ -38,6 +38,7 @@ export default class kraken extends krakenRest {
38
38
  'ws': {
39
39
  'public': 'wss://ws.kraken.com',
40
40
  'private': 'wss://ws-auth.kraken.com',
41
+ 'privateV2': 'wss://ws-auth.kraken.com/v2',
41
42
  'beta': 'wss://beta-ws.kraken.com',
42
43
  'beta-private': 'wss://beta-ws-auth.kraken.com',
43
44
  },
@@ -51,7 +52,9 @@ export default class kraken extends krakenRest {
51
52
  'OHLCVLimit': 1000,
52
53
  'ordersLimit': 1000,
53
54
  'symbolsByOrderId': {},
54
- 'checksum': true,
55
+ 'watchOrderBook': {
56
+ 'checksum': true,
57
+ },
55
58
  },
56
59
  'exceptions': {
57
60
  'ws': {
@@ -749,7 +752,7 @@ export default class kraken extends krakenRest {
749
752
  }
750
753
  // don't remove this line or I will poop on your face
751
754
  orderbook.limit();
752
- const checksum = this.safeBool(this.options, 'checksum', true);
755
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
753
756
  if (checksum) {
754
757
  const priceString = this.safeString(example, 0);
755
758
  const amountString = this.safeString(example, 1);
@@ -771,7 +774,7 @@ export default class kraken extends krakenRest {
771
774
  const payload = payloadArray.join('');
772
775
  const localChecksum = this.crc32(payload, false);
773
776
  if (localChecksum !== c) {
774
- const error = new InvalidNonce(this.id + ' invalid checksum');
777
+ const error = new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
775
778
  delete client.subscriptions[messageHash];
776
779
  delete this.orderbooks[symbol];
777
780
  client.reject(error, messageHash);
@@ -884,7 +887,7 @@ export default class kraken extends krakenRest {
884
887
  * @param {int} [since] the earliest time in ms to fetch trades for
885
888
  * @param {int} [limit] the maximum number of trade structures to retrieve
886
889
  * @param {object} [params] extra parameters specific to the exchange API endpoint
887
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
890
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
888
891
  */
889
892
  return await this.watchPrivate('ownTrades', symbol, since, limit, params);
890
893
  }
@@ -1329,6 +1332,71 @@ export default class kraken extends krakenRest {
1329
1332
  const url = this.urls['api']['ws']['public'];
1330
1333
  return await this.watchMultiple(url, messageHashes, this.deepExtend(request, params), messageHashes, subscriptionArgs);
1331
1334
  }
1335
+ async watchBalance(params = {}) {
1336
+ /**
1337
+ * @method
1338
+ * @name kraken#watchBalance
1339
+ * @description watch balance and get the amount of funds available for trading or funds locked in orders
1340
+ * @see https://docs.kraken.com/api/docs/websocket-v2/balances
1341
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1342
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1343
+ */
1344
+ await this.loadMarkets();
1345
+ const token = await this.authenticate();
1346
+ const messageHash = 'balances';
1347
+ const url = this.urls['api']['ws']['privateV2'];
1348
+ const requestId = this.requestId();
1349
+ const subscribe = {
1350
+ 'method': 'subscribe',
1351
+ 'req_id': requestId,
1352
+ 'params': {
1353
+ 'channel': 'balances',
1354
+ 'token': token,
1355
+ },
1356
+ };
1357
+ const request = this.deepExtend(subscribe, params);
1358
+ return await this.watch(url, messageHash, request, messageHash);
1359
+ }
1360
+ handleBalance(client, message) {
1361
+ //
1362
+ // {
1363
+ // "channel": "balances",
1364
+ // "data": [
1365
+ // {
1366
+ // "asset": "BTC",
1367
+ // "asset_class": "currency",
1368
+ // "balance": 1.2,
1369
+ // "wallets": [
1370
+ // {
1371
+ // "type": "spot",
1372
+ // "id": "main",
1373
+ // "balance": 1.2
1374
+ // }
1375
+ // ]
1376
+ // }
1377
+ // ],
1378
+ // "type": "snapshot",
1379
+ // "sequence": 1
1380
+ // }
1381
+ //
1382
+ const data = this.safeList(message, 'data', []);
1383
+ const result = { 'info': message };
1384
+ for (let i = 0; i < data.length; i++) {
1385
+ const currencyId = this.safeString(data[i], 'asset');
1386
+ const code = this.safeCurrencyCode(currencyId);
1387
+ const account = this.account();
1388
+ const eq = this.safeString(data[i], 'balance');
1389
+ account['total'] = eq;
1390
+ result[code] = account;
1391
+ }
1392
+ const type = 'spot';
1393
+ const balance = this.safeBalance(result);
1394
+ const oldBalance = this.safeValue(this.balance, type, {});
1395
+ const newBalance = this.deepExtend(oldBalance, balance);
1396
+ this.balance[type] = this.safeBalance(newBalance);
1397
+ const channel = this.safeString(message, 'channel');
1398
+ client.resolve(this.balance[type], channel);
1399
+ }
1332
1400
  getMessageHash(unifiedElementName, subChannelName = undefined, symbol = undefined) {
1333
1401
  // unifiedElementName can be : orderbook, trade, ticker, bidask ...
1334
1402
  // subChannelName only applies to channel that needs specific variation (i.e. depth_50, depth_100..) to be selected
@@ -1432,6 +1500,16 @@ export default class kraken extends krakenRest {
1432
1500
  }
1433
1501
  }
1434
1502
  else {
1503
+ const channel = this.safeString(message, 'channel');
1504
+ if (channel !== undefined) {
1505
+ const methods = {
1506
+ 'balances': this.handleBalance,
1507
+ };
1508
+ const method = this.safeValue(methods, channel);
1509
+ if (method !== undefined) {
1510
+ method.call(this, client, message);
1511
+ }
1512
+ }
1435
1513
  if (this.handleErrorMessage(client, message)) {
1436
1514
  const event = this.safeString(message, 'event');
1437
1515
  const methods = {
@@ -990,7 +990,7 @@ export default class kucoin extends kucoinRest {
990
990
  * @param {int} [limit] the maximum number of trade structures to retrieve
991
991
  * @param {object} [params] extra parameters specific to the exchange API endpoint
992
992
  * @param {string} [params.method] '/spotMarket/tradeOrders' or '/spot/tradeFills' default is '/spotMarket/tradeOrders'
993
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
993
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
994
994
  */
995
995
  await this.loadMarkets();
996
996
  const url = await this.negotiate(true);
@@ -617,7 +617,7 @@ export default class mexc extends mexcRest {
617
617
  * @param {int} [since] the earliest time in ms to fetch trades for
618
618
  * @param {int} [limit] the maximum number of trade structures to retrieve
619
619
  * @param {object} [params] extra parameters specific to the exchange API endpoint
620
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
620
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
621
621
  */
622
622
  await this.loadMarkets();
623
623
  let messageHash = 'myTrades';
package/js/src/pro/okx.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import okxRest from '../okx.js';
9
- import { ArgumentsRequired, BadRequest, ExchangeError, InvalidNonce, AuthenticationError } from '../base/errors.js';
9
+ import { ArgumentsRequired, BadRequest, ExchangeError, ChecksumError, AuthenticationError } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
11
11
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
12
12
  // ---------------------------------------------------------------------------
@@ -49,6 +49,7 @@ export default class okx extends okxRest {
49
49
  },
50
50
  'options': {
51
51
  'watchOrderBook': {
52
+ 'checksum': true,
52
53
  //
53
54
  // bbo-tbt
54
55
  // 1. Newly added channel that sends tick-by-tick Level 1 data
@@ -96,7 +97,6 @@ export default class okx extends okxRest {
96
97
  'ws': {
97
98
  // 'inflate': true,
98
99
  },
99
- 'checksum': true,
100
100
  },
101
101
  'streaming': {
102
102
  // okex does not support built-in ws protocol-level ping-pong
@@ -922,7 +922,7 @@ export default class okx extends okxRest {
922
922
  this.handleDeltas(storedBids, bids);
923
923
  const marketId = this.safeString(message, 'instId');
924
924
  const symbol = this.safeSymbol(marketId);
925
- const checksum = this.safeBool(this.options, 'checksum', true);
925
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
926
926
  if (checksum) {
927
927
  const asksLength = storedAsks.length;
928
928
  const bidsLength = storedBids.length;
@@ -941,7 +941,7 @@ export default class okx extends okxRest {
941
941
  const responseChecksum = this.safeInteger(message, 'checksum');
942
942
  const localChecksum = this.crc32(payload, true);
943
943
  if (responseChecksum !== localChecksum) {
944
- const error = new InvalidNonce(this.id + ' invalid checksum');
944
+ const error = new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
945
945
  delete client.subscriptions[messageHash];
946
946
  delete this.orderbooks[symbol];
947
947
  client.reject(error, messageHash);
@@ -1226,7 +1226,7 @@ export default class okx extends okxRest {
1226
1226
  * @param {bool} [params.stop] true if fetching trigger or conditional trades
1227
1227
  * @param {string} [params.type] 'spot', 'swap', 'future', 'option', 'ANY', 'SPOT', 'MARGIN', 'SWAP', 'FUTURES' or 'OPTION'
1228
1228
  * @param {string} [params.marginMode] 'cross' or 'isolated', for automatically setting the type to spot margin
1229
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
1229
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1230
1230
  */
1231
1231
  // By default, receive order updates from any instrument type
1232
1232
  let type = undefined;
@@ -80,7 +80,7 @@ export default class oxfun extends oxfunRest {
80
80
  * @param {int} [limit] the maximum number of trade structures to retrieve
81
81
  * @param {object} [params] extra parameters specific to the exchange API endpoint
82
82
  * @param {int|string} [params.tag] If given it will be echoed in the reply and the max size of tag is 32
83
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
83
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
84
84
  */
85
85
  return await this.watchTradesForSymbols([symbol], since, limit, params);
86
86
  }
@@ -733,7 +733,7 @@ export default class phemex extends phemexRest {
733
733
  * @param {int} [since] the earliest time in ms to fetch trades for
734
734
  * @param {int} [limit] the maximum number of trade structures to retrieve
735
735
  * @param {object} [params] extra parameters specific to the exchange API endpoint
736
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
736
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
737
737
  */
738
738
  await this.loadMarkets();
739
739
  let market = undefined;
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import poloniexfuturesRest from '../poloniexfutures.js';
9
- import { AuthenticationError, BadRequest, InvalidNonce } from '../base/errors.js';
9
+ import { AuthenticationError, BadRequest, ChecksumError } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
11
11
  // ---------------------------------------------------------------------------
12
12
  export default class poloniexfutures extends poloniexfuturesRest {
@@ -52,6 +52,7 @@ export default class poloniexfutures extends poloniexfuturesRest {
52
52
  'method': '/contractMarket/level2',
53
53
  'snapshotDelay': 5,
54
54
  'snapshotMaxRetries': 3,
55
+ 'checksum': true,
55
56
  },
56
57
  'streamLimit': 5,
57
58
  'streamBySubscriptionsHash': {},
@@ -860,7 +861,10 @@ export default class poloniexfutures extends poloniexfuturesRest {
860
861
  return;
861
862
  }
862
863
  if (nonce !== lastSequence) {
863
- throw new InvalidNonce(this.id + ' watchOrderBook received an out-of-order nonce');
864
+ const checksum = this.handleOption('watchOrderBook', 'checksum', true);
865
+ if (checksum) {
866
+ throw new ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(''));
867
+ }
864
868
  }
865
869
  const changes = this.safeList(delta, 'changes');
866
870
  for (let i = 0; i < changes.length; i++) {
@@ -309,7 +309,7 @@ export default class upbit extends upbitRest {
309
309
  * @param {int} [since] the earliest time in ms to fetch orders for
310
310
  * @param {int} [limit] the maximum number of order structures to retrieve
311
311
  * @param {object} [params] extra parameters specific to the exchange API endpoint
312
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
312
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
313
313
  */
314
314
  await this.loadMarkets();
315
315
  const channel = 'myOrder';
@@ -87,7 +87,7 @@ export default class vertex extends vertexRest {
87
87
  * @param {int} [since] the earliest time in ms to fetch trades for
88
88
  * @param {int} [limit] the maximum number of trade structures to retrieve
89
89
  * @param {object} [params] extra parameters specific to the exchange API endpoint
90
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
90
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
91
91
  */
92
92
  await this.loadMarkets();
93
93
  const market = this.market(symbol);
@@ -148,7 +148,7 @@ export default class vertex extends vertexRest {
148
148
  * @param {int} [limit] the maximum number of order structures to retrieve
149
149
  * @param {object} [params] extra parameters specific to the exchange API endpoint
150
150
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
151
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
151
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
152
152
  */
153
153
  if (symbol === undefined) {
154
154
  throw new ArgumentsRequired(this.id + ' watchMyTrades requires a symbol.');
@@ -478,7 +478,7 @@ export default class whitebit extends whitebitRest {
478
478
  * @param {int} [since] the earliest time in ms to fetch orders for
479
479
  * @param {int} [limit] the maximum number of order structures to retrieve
480
480
  * @param {object} [params] extra parameters specific to the exchange API endpoint
481
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure
481
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
482
482
  */
483
483
  if (symbol === undefined) {
484
484
  throw new ArgumentsRequired(this.id + ' watchOrders() requires a symbol argument');
package/js/src/pro/woo.js CHANGED
@@ -379,7 +379,7 @@ export default class woo extends wooRest {
379
379
  * @param {int} [since] the earliest time in ms to fetch trades for
380
380
  * @param {int} [limit] the maximum number of trade structures to retrieve
381
381
  * @param {object} [params] extra parameters specific to the exchange API endpoint
382
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
382
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
383
383
  */
384
384
  await this.loadMarkets();
385
385
  const market = this.market(symbol);
@@ -377,7 +377,7 @@ export default class woofipro extends woofiproRest {
377
377
  * @param {int} [since] the earliest time in ms to fetch trades for
378
378
  * @param {int} [limit] the maximum number of trade structures to retrieve
379
379
  * @param {object} [params] extra parameters specific to the exchange API endpoint
380
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
380
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
381
381
  */
382
382
  await this.loadMarkets();
383
383
  const market = this.market(symbol);
@@ -218,7 +218,7 @@ export default class tradeogre extends Exchange {
218
218
  'inverse': undefined,
219
219
  'contractSize': undefined,
220
220
  'taker': this.fees['trading']['taker'],
221
- 'maker': this.fees['trading']['taker'],
221
+ 'maker': this.fees['trading']['maker'],
222
222
  'expiry': undefined,
223
223
  'expiryDatetime': undefined,
224
224
  'strike': undefined,