ccxt 4.5.6 → 4.5.7

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 (84) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/apex.js +2 -2
  5. package/dist/cjs/src/binance.js +3 -0
  6. package/dist/cjs/src/bitbank.js +1 -0
  7. package/dist/cjs/src/bitbns.js +1 -0
  8. package/dist/cjs/src/bitflyer.js +1 -0
  9. package/dist/cjs/src/bithumb.js +1 -0
  10. package/dist/cjs/src/bitso.js +1 -0
  11. package/dist/cjs/src/bitvavo.js +26 -40
  12. package/dist/cjs/src/blockchaincom.js +1 -0
  13. package/dist/cjs/src/btcalpha.js +1 -0
  14. package/dist/cjs/src/btcbox.js +1 -0
  15. package/dist/cjs/src/btcmarkets.js +1 -0
  16. package/dist/cjs/src/btcturk.js +1 -0
  17. package/dist/cjs/src/deribit.js +3 -2
  18. package/dist/cjs/src/digifinex.js +1 -1
  19. package/dist/cjs/src/gate.js +8 -12
  20. package/dist/cjs/src/gemini.js +3 -3
  21. package/dist/cjs/src/htx.js +11 -1
  22. package/dist/cjs/src/independentreserve.js +1 -0
  23. package/dist/cjs/src/indodax.js +17 -6
  24. package/dist/cjs/src/kraken.js +25 -6
  25. package/dist/cjs/src/krakenfutures.js +1 -0
  26. package/dist/cjs/src/mercado.js +1 -0
  27. package/dist/cjs/src/mexc.js +80 -36
  28. package/dist/cjs/src/novadax.js +1 -0
  29. package/dist/cjs/src/oceanex.js +1 -0
  30. package/dist/cjs/src/okx.js +18 -5
  31. package/dist/cjs/src/pro/apex.js +7 -4
  32. package/dist/cjs/src/pro/backpack.js +6 -4
  33. package/dist/cjs/src/pro/bingx.js +206 -220
  34. package/dist/cjs/src/pro/htx.js +1 -1
  35. package/dist/cjs/src/upbit.js +1 -0
  36. package/dist/cjs/src/wavesexchange.js +1 -0
  37. package/dist/cjs/src/yobit.js +1 -0
  38. package/dist/cjs/src/zaif.js +1 -0
  39. package/dist/cjs/src/zonda.js +1 -0
  40. package/js/ccxt.d.ts +1 -1
  41. package/js/ccxt.js +1 -1
  42. package/js/src/abstract/mexc.d.ts +1 -0
  43. package/js/src/apex.js +2 -2
  44. package/js/src/binance.js +3 -0
  45. package/js/src/bitbank.js +1 -0
  46. package/js/src/bitbns.js +1 -0
  47. package/js/src/bitflyer.js +1 -0
  48. package/js/src/bithumb.js +1 -0
  49. package/js/src/bitso.js +1 -0
  50. package/js/src/bitvavo.d.ts +0 -2
  51. package/js/src/bitvavo.js +27 -41
  52. package/js/src/blockchaincom.js +1 -0
  53. package/js/src/btcalpha.js +1 -0
  54. package/js/src/btcbox.js +1 -0
  55. package/js/src/btcmarkets.js +1 -0
  56. package/js/src/btcturk.js +1 -0
  57. package/js/src/deribit.js +3 -2
  58. package/js/src/digifinex.js +1 -1
  59. package/js/src/gate.d.ts +2 -2
  60. package/js/src/gate.js +8 -12
  61. package/js/src/gemini.js +3 -3
  62. package/js/src/htx.js +11 -1
  63. package/js/src/independentreserve.js +1 -0
  64. package/js/src/indodax.js +17 -6
  65. package/js/src/kraken.d.ts +1 -1
  66. package/js/src/kraken.js +25 -6
  67. package/js/src/krakenfutures.js +1 -0
  68. package/js/src/mercado.js +1 -0
  69. package/js/src/mexc.d.ts +4 -1
  70. package/js/src/mexc.js +80 -36
  71. package/js/src/novadax.js +1 -0
  72. package/js/src/oceanex.js +1 -0
  73. package/js/src/okx.js +18 -5
  74. package/js/src/pro/apex.js +7 -4
  75. package/js/src/pro/backpack.js +6 -4
  76. package/js/src/pro/bingx.d.ts +53 -33
  77. package/js/src/pro/bingx.js +207 -221
  78. package/js/src/pro/htx.js +1 -1
  79. package/js/src/upbit.js +1 -0
  80. package/js/src/wavesexchange.js +1 -0
  81. package/js/src/yobit.js +1 -0
  82. package/js/src/zaif.js +1 -0
  83. package/js/src/zonda.js +1 -0
  84. package/package.json +1 -1
@@ -232,6 +232,7 @@ class mexc extends mexc$1["default"] {
232
232
  'mxDeduct/enable': 1,
233
233
  'userDataStream': 1,
234
234
  'selfSymbols': 1,
235
+ 'asset/internal/transfer/record': 10,
235
236
  },
236
237
  'post': {
237
238
  'order': 1,
@@ -5269,7 +5270,7 @@ class mexc extends mexc$1["default"] {
5269
5270
  const request = {
5270
5271
  'transact_id': id,
5271
5272
  };
5272
- const response = await this.spot2PrivateGetAssetInternalTransferInfo(this.extend(request, query));
5273
+ const response = await this.spotPrivateGetAssetInternalTransferRecord(this.extend(request, query));
5273
5274
  //
5274
5275
  // {
5275
5276
  // "code": "200",
@@ -5297,60 +5298,84 @@ class mexc extends mexc$1["default"] {
5297
5298
  * @description fetch a history of internal transfers made on an account
5298
5299
  * @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
5299
5300
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
5300
- * @param {string} code unified currency code of the currency transferred
5301
+ * @see https://www.mexc.com/api-docs/spot-v3/wallet-endpoints#query-user-universal-transfer-history * @param {string} code unified currency code of the currency transferred
5302
+ * @param code
5301
5303
  * @param {int} [since] the earliest time in ms to fetch transfers for
5302
5304
  * @param {int} [limit] the maximum number of transfers structures to retrieve
5303
5305
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5306
+ * @param {string} [params.fromAccountType] 'SPOT' for spot wallet, 'FUTURES' for contract wallet
5307
+ * @param {string} [params.toAccountType] 'SPOT' for spot wallet, 'FUTURES' for contract wallet
5304
5308
  * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
5305
5309
  */
5306
5310
  async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
5307
- const [marketType, query] = this.handleMarketTypeAndParams('fetchTransfers', undefined, params);
5311
+ let marketType = undefined;
5312
+ [marketType, params] = this.handleMarketTypeAndParams('fetchTransfers', undefined, params);
5308
5313
  await this.loadMarkets();
5309
5314
  const request = {};
5310
5315
  let currency = undefined;
5311
- let resultList = undefined;
5312
5316
  if (code !== undefined) {
5313
5317
  currency = this.currency(code);
5314
- request['currency'] = currency['id'];
5315
5318
  }
5319
+ let fromAccountType = undefined;
5320
+ [fromAccountType, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'fromAccountType');
5321
+ const accountTypes = {
5322
+ 'spot': 'SPOT',
5323
+ 'swap': 'FUTURES',
5324
+ 'futures': 'FUTURES',
5325
+ 'future': 'FUTURES',
5326
+ 'margin': 'SPOT',
5327
+ };
5328
+ if (fromAccountType !== undefined) {
5329
+ request['fromAccountType'] = this.safeString(accountTypes, fromAccountType, fromAccountType);
5330
+ }
5331
+ else {
5332
+ throw new errors.ArgumentsRequired(this.id + ' fetchTransfers() requires a fromAccountType parameter, one of "SPOT", "FUTURES"');
5333
+ }
5334
+ let toAccountType = undefined;
5335
+ [toAccountType, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'toAccountType');
5336
+ if (toAccountType !== undefined) {
5337
+ request['toAccountType'] = this.safeString(accountTypes, toAccountType, toAccountType);
5338
+ }
5339
+ else {
5340
+ throw new errors.ArgumentsRequired(this.id + ' fetchTransfers() requires a toAccountType parameter, one of "SPOT", "FUTURES"');
5341
+ }
5342
+ let resultList = [];
5316
5343
  if (marketType === 'spot') {
5317
5344
  if (since !== undefined) {
5318
- request['start_time'] = since;
5345
+ request['startTime'] = since;
5319
5346
  }
5320
5347
  if (limit !== undefined) {
5321
- if (limit > 50) {
5348
+ if (limit > 100) {
5322
5349
  throw new errors.ExchangeError('This exchange supports a maximum limit of 50');
5323
5350
  }
5324
- request['page-size'] = limit;
5351
+ request['size'] = limit;
5325
5352
  }
5326
- const response = await this.spot2PrivateGetAssetInternalTransferRecord(this.extend(request, query));
5353
+ const response = await this.spotPrivateGetCapitalTransfer(this.extend(request, params));
5327
5354
  //
5328
- // {
5329
- // "code": "200",
5330
- // "data": {
5331
- // "total_page": "1",
5332
- // "total_size": "5",
5333
- // "result_list": [{
5334
- // "currency": "USDT",
5335
- // "amount": "1",
5336
- // "transact_id": "954877a2ef54499db9b28a7cf9ebcf41",
5337
- // "from": "MAIN",
5338
- // "to": "CONTRACT",
5339
- // "transact_state": "SUCCESS"
5340
- // },
5341
- // ...
5342
- // ]
5343
- // }
5344
- // }
5345
5355
  //
5346
- const data = this.safeValue(response, 'data', {});
5347
- resultList = this.safeValue(data, 'result_list', []);
5356
+ // {
5357
+ // "rows": [
5358
+ // {
5359
+ // "tranId": "cdf0d2a618b5458c965baefe6b1d0859",
5360
+ // "clientTranId": null,
5361
+ // "asset": "USDT",
5362
+ // "amount": "1",
5363
+ // "fromAccountType": "FUTURES",
5364
+ // "toAccountType": "SPOT",
5365
+ // "symbol": null,
5366
+ // "status": "SUCCESS",
5367
+ // "timestamp": 1759328309000
5368
+ // }
5369
+ // ],
5370
+ // "total": 1
5371
+ // }
5372
+ resultList = this.safeList(response, 'rows', []);
5348
5373
  }
5349
5374
  else if (marketType === 'swap') {
5350
5375
  if (limit !== undefined) {
5351
5376
  request['page_size'] = limit;
5352
5377
  }
5353
- const response = await this.contractPrivateGetAccountTransferRecord(this.extend(request, query));
5378
+ const response = await this.contractPrivateGetAccountTransferRecord(this.extend(request, params));
5354
5379
  const data = this.safeValue(response, 'data');
5355
5380
  resultList = this.safeValue(data, 'resultList');
5356
5381
  //
@@ -5399,10 +5424,10 @@ class mexc extends mexc$1["default"] {
5399
5424
  const accounts = {
5400
5425
  'spot': 'SPOT',
5401
5426
  'swap': 'FUTURES',
5402
- 'margin': 'ISOLATED_MARGIN',
5427
+ 'future': 'FUTURES',
5403
5428
  };
5404
- const fromId = this.safeString(accounts, fromAccount);
5405
- const toId = this.safeString(accounts, toAccount);
5429
+ const fromId = this.safeString(accounts, fromAccount, fromAccount);
5430
+ const toId = this.safeString(accounts, toAccount, toAccount);
5406
5431
  if (fromId === undefined) {
5407
5432
  const keys = Object.keys(accounts);
5408
5433
  throw new errors.ExchangeError(this.id + ' fromAccount must be one of ' + keys.join(', '));
@@ -5464,6 +5489,17 @@ class mexc extends mexc$1["default"] {
5464
5489
  // "createTime": "1648849076000",
5465
5490
  // "updateTime": "1648849076000"
5466
5491
  // }
5492
+ // {
5493
+ // "tranId": "cdf0d2a618b5458c965baefe6b1d0859",
5494
+ // "clientTranId": null,
5495
+ // "asset": "USDT",
5496
+ // "amount": "1",
5497
+ // "fromAccountType": "FUTURES",
5498
+ // "toAccountType": "SPOT",
5499
+ // "symbol": null,
5500
+ // "status": "SUCCESS",
5501
+ // "timestamp": 1759328309000
5502
+ // }
5467
5503
  //
5468
5504
  // transfer
5469
5505
  //
@@ -5471,14 +5507,20 @@ class mexc extends mexc$1["default"] {
5471
5507
  // "tranId": "ebb06123e6a64f4ab234b396c548d57e"
5472
5508
  // }
5473
5509
  //
5474
- const currencyId = this.safeString(transfer, 'currency');
5510
+ const currencyId = this.safeString2(transfer, 'currency', 'asset');
5475
5511
  const id = this.safeStringN(transfer, ['transact_id', 'txid', 'tranId']);
5476
- const timestamp = this.safeInteger(transfer, 'createTime');
5512
+ const timestamp = this.safeInteger2(transfer, 'createTime', 'timestamp');
5477
5513
  const datetime = (timestamp !== undefined) ? this.iso8601(timestamp) : undefined;
5478
5514
  const direction = this.safeString(transfer, 'type');
5479
5515
  let accountFrom = undefined;
5480
5516
  let accountTo = undefined;
5481
- if (direction !== undefined) {
5517
+ const fromAccountType = this.safeString(transfer, 'fromAccountType');
5518
+ const toAccountType = this.safeString(transfer, 'toAccountType');
5519
+ if ((fromAccountType !== undefined) && (toAccountType !== undefined)) {
5520
+ accountFrom = fromAccountType;
5521
+ accountTo = toAccountType;
5522
+ }
5523
+ else if (direction !== undefined) {
5482
5524
  accountFrom = (direction === 'IN') ? 'MAIN' : 'CONTRACT';
5483
5525
  accountTo = (direction === 'IN') ? 'CONTRACT' : 'MAIN';
5484
5526
  }
@@ -5495,11 +5537,13 @@ class mexc extends mexc$1["default"] {
5495
5537
  'amount': this.safeNumber(transfer, 'amount'),
5496
5538
  'fromAccount': this.parseAccountId(accountFrom),
5497
5539
  'toAccount': this.parseAccountId(accountTo),
5498
- 'status': this.parseTransferStatus(this.safeString2(transfer, 'transact_state', 'state')),
5540
+ 'status': this.parseTransferStatus(this.safeStringN(transfer, ['transact_state', 'state', 'status'])),
5499
5541
  };
5500
5542
  }
5501
5543
  parseAccountId(status) {
5502
5544
  const statuses = {
5545
+ 'SPOT': 'spot',
5546
+ 'FUTURES': 'swap',
5503
5547
  'MAIN': 'spot',
5504
5548
  'CONTRACT': 'swap',
5505
5549
  };
@@ -60,6 +60,7 @@ class novadax extends novadax$1["default"] {
60
60
  'fetchClosedOrders': true,
61
61
  'fetchCrossBorrowRate': false,
62
62
  'fetchCrossBorrowRates': false,
63
+ 'fetchCurrencies': false,
63
64
  'fetchDepositAddress': false,
64
65
  'fetchDepositAddresses': false,
65
66
  'fetchDepositAddressesByNetwork': false,
@@ -49,6 +49,7 @@ class oceanex extends oceanex$1["default"] {
49
49
  'fetchClosedOrders': true,
50
50
  'fetchCrossBorrowRate': false,
51
51
  'fetchCrossBorrowRates': false,
52
+ 'fetchCurrencies': false,
52
53
  'fetchDepositAddress': 'emulated',
53
54
  'fetchDepositAddresses': undefined,
54
55
  'fetchDepositAddressesByNetwork': true,
@@ -3641,10 +3641,18 @@ class okx extends okx$1["default"] {
3641
3641
  }
3642
3642
  else {
3643
3643
  for (let i = 0; i < clientOrderIds.length; i++) {
3644
- request.push({
3645
- 'instId': market['id'],
3646
- 'clOrdId': clientOrderIds[i],
3647
- });
3644
+ if (trailing || trigger) {
3645
+ request.push({
3646
+ 'instId': market['id'],
3647
+ 'algoClOrdId': clientOrderIds[i],
3648
+ });
3649
+ }
3650
+ else {
3651
+ request.push({
3652
+ 'instId': market['id'],
3653
+ 'clOrdId': clientOrderIds[i],
3654
+ });
3655
+ }
3648
3656
  }
3649
3657
  }
3650
3658
  let response = undefined;
@@ -3721,7 +3729,12 @@ class okx extends okx$1["default"] {
3721
3729
  idKey = 'algoId';
3722
3730
  }
3723
3731
  else if (clientOrderId !== undefined) {
3724
- idKey = 'clOrdId';
3732
+ if (isStopOrTrailing) {
3733
+ idKey = 'algoClOrdId';
3734
+ }
3735
+ else {
3736
+ idKey = 'clOrdId';
3737
+ }
3725
3738
  }
3726
3739
  const requestItem = {
3727
3740
  'instId': market['id'],
@@ -117,9 +117,10 @@ class apex extends apex$1["default"] {
117
117
  // "v": "0.001",
118
118
  // "p": "16578.50",
119
119
  // "L": "PlusTick",
120
- // "i": "20f43950-d8dd-5b31-9112-a178eb6023af",
120
+ // "i": "20f43950-d8dd-5b31-9112-a178eb6023ef",
121
121
  // "BT": false
122
- // }
122
+ // },
123
+ // // sorted by newest first
123
124
  // ]
124
125
  // }
125
126
  //
@@ -136,8 +137,10 @@ class apex extends apex$1["default"] {
136
137
  stored = new Cache.ArrayCache(limit);
137
138
  this.trades[symbol] = stored;
138
139
  }
139
- for (let j = 0; j < trades.length; j++) {
140
- const parsed = this.parseWsTrade(trades[j], market);
140
+ const length = trades.length;
141
+ for (let j = 0; j < length; j++) {
142
+ const index = length - j - 1;
143
+ const parsed = this.parseWsTrade(trades[index], market);
141
144
  stored.append(parsed);
142
145
  }
143
146
  const messageHash = 'trade' + ':' + symbol;
@@ -864,7 +864,7 @@ class backpack extends backpack$1["default"] {
864
864
  storedOrderBook.cache.push(data);
865
865
  return;
866
866
  }
867
- else if (nonce >= deltaNonce) {
867
+ else if (nonce > deltaNonce) {
868
868
  return;
869
869
  }
870
870
  this.handleDelta(storedOrderBook, data);
@@ -889,16 +889,18 @@ class backpack extends backpack$1["default"] {
889
889
  }
890
890
  }
891
891
  getCacheIndex(orderbook, cache) {
892
+ //
893
+ // {"E":"1759338824897386","T":"1759338824895616","U":1662976171,"a":[],"b":[["117357.0","0.00000"]],"e":"depth","s":"BTC_USDC_PERP","u":1662976171}
892
894
  const firstDelta = this.safeDict(cache, 0);
893
895
  const nonce = this.safeInteger(orderbook, 'nonce');
894
- const firstDeltaStart = this.safeInteger(firstDelta, 'sequenceStart');
896
+ const firstDeltaStart = this.safeInteger(firstDelta, 'U');
895
897
  if (nonce < firstDeltaStart - 1) {
896
898
  return -1;
897
899
  }
898
900
  for (let i = 0; i < cache.length; i++) {
899
901
  const delta = cache[i];
900
- const deltaStart = this.safeInteger(delta, 'sequenceStart');
901
- const deltaEnd = this.safeInteger(delta, 'sequenceEnd');
902
+ const deltaStart = this.safeInteger(delta, 'U');
903
+ const deltaEnd = this.safeInteger(delta, 'u');
902
904
  if ((nonce >= deltaStart - 1) && (nonce < deltaEnd)) {
903
905
  return i;
904
906
  }