ccxt 4.3.62 → 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 (61) 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 +6 -9
  8. package/dist/cjs/src/bingx.js +466 -151
  9. package/dist/cjs/src/cryptocom.js +18 -2
  10. package/dist/cjs/src/mercado.js +5 -1
  11. package/dist/cjs/src/pro/binance.js +58 -34
  12. package/dist/cjs/src/pro/bitfinex2.js +6 -3
  13. package/dist/cjs/src/pro/bitget.js +4 -1
  14. package/dist/cjs/src/pro/bitvavo.js +1 -1
  15. package/dist/cjs/src/pro/bybit.js +44 -18
  16. package/dist/cjs/src/pro/cryptocom.js +7 -1
  17. package/dist/cjs/src/pro/gate.js +6 -2
  18. package/dist/cjs/src/pro/htx.js +5 -1
  19. package/dist/cjs/src/pro/independentreserve.js +5 -3
  20. package/dist/cjs/src/pro/kraken.js +82 -4
  21. package/dist/cjs/src/pro/okx.js +3 -3
  22. package/dist/cjs/src/pro/poloniexfutures.js +5 -1
  23. package/dist/cjs/src/pro/woofipro.js +1 -1
  24. package/dist/cjs/src/woo.js +313 -81
  25. package/js/ccxt.d.ts +3 -3
  26. package/js/ccxt.js +3 -3
  27. package/js/src/abstract/cryptocom.d.ts +11 -0
  28. package/js/src/abstract/woo.d.ts +3 -0
  29. package/js/src/ace.js +34 -15
  30. package/js/src/base/Exchange.d.ts +1 -0
  31. package/js/src/base/Exchange.js +8 -1
  32. package/js/src/base/errorHierarchy.d.ts +3 -1
  33. package/js/src/base/errorHierarchy.js +3 -1
  34. package/js/src/base/errors.d.ts +5 -1
  35. package/js/src/base/errors.js +8 -2
  36. package/js/src/binance.js +6 -9
  37. package/js/src/bingx.d.ts +1 -0
  38. package/js/src/bingx.js +466 -151
  39. package/js/src/coinbaseinternational.d.ts +1 -1
  40. package/js/src/cryptocom.js +18 -2
  41. package/js/src/mercado.js +5 -1
  42. package/js/src/pro/binance.d.ts +1 -0
  43. package/js/src/pro/binance.js +59 -35
  44. package/js/src/pro/bitfinex2.js +7 -4
  45. package/js/src/pro/bitget.js +5 -2
  46. package/js/src/pro/bitvavo.js +1 -1
  47. package/js/src/pro/bybit.d.ts +1 -0
  48. package/js/src/pro/bybit.js +44 -18
  49. package/js/src/pro/cryptocom.js +8 -2
  50. package/js/src/pro/gate.js +7 -3
  51. package/js/src/pro/htx.js +6 -2
  52. package/js/src/pro/independentreserve.js +6 -4
  53. package/js/src/pro/kraken.d.ts +3 -1
  54. package/js/src/pro/kraken.js +83 -5
  55. package/js/src/pro/okx.js +4 -4
  56. package/js/src/pro/poloniexfutures.js +6 -2
  57. package/js/src/pro/woofipro.js +1 -1
  58. package/js/src/woo.d.ts +5 -1
  59. package/js/src/woo.js +313 -81
  60. package/js/src/xt.d.ts +3 -3
  61. package/package.json +1 -1
@@ -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);
@@ -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 = {
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);
@@ -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++) {
@@ -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);
package/js/src/woo.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/woo.js';
2
- import type { TransferEntry, Balances, Conversion, Currency, FundingRateHistory, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Dict, Strings, Trade, Transaction, Leverage, Account, Currencies, TradingFees, TransferEntries, int } from './base/types.js';
2
+ import type { TransferEntry, Balances, Conversion, Currency, FundingRateHistory, Int, Market, MarginModification, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Dict, Strings, Trade, Transaction, Leverage, Account, Currencies, TradingFees, TransferEntries, int } from './base/types.js';
3
3
  /**
4
4
  * @class woo
5
5
  * @augments Exchange
@@ -26,6 +26,7 @@ export default class woo extends Exchange {
26
26
  createTrailingAmountOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, trailingAmount?: any, trailingTriggerPrice?: any, params?: {}): Promise<Order>;
27
27
  createTrailingPercentOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, trailingPercent?: any, trailingTriggerPrice?: any, params?: {}): Promise<Order>;
28
28
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
29
+ encodeMarginMode(mode: any): string;
29
30
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
30
31
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
31
32
  cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
@@ -163,6 +164,9 @@ export default class woo extends Exchange {
163
164
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
164
165
  parseLeverage(leverage: Dict, market?: Market): Leverage;
165
166
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
167
+ addMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
168
+ reduceMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
169
+ modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
166
170
  fetchPosition(symbol?: Str, params?: {}): Promise<import("./base/types.js").Position>;
167
171
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
168
172
  parsePosition(position: Dict, market?: Market): import("./base/types.js").Position;