ccxt 4.5.5 → 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 (151) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +15 -15
  3. package/dist/cjs/ccxt.js +6 -6
  4. package/dist/cjs/src/abstract/toobit.js +11 -0
  5. package/dist/cjs/src/abstract/tradeogre.js +1 -1
  6. package/dist/cjs/src/apex.js +2 -2
  7. package/dist/cjs/src/backpack.js +1 -1
  8. package/dist/cjs/src/base/Exchange.js +129 -2
  9. package/dist/cjs/src/bigone.js +4 -4
  10. package/dist/cjs/src/binance.js +82 -20
  11. package/dist/cjs/src/bingx.js +5 -2
  12. package/dist/cjs/src/bitbank.js +1 -0
  13. package/dist/cjs/src/bitbns.js +1 -0
  14. package/dist/cjs/src/bitflyer.js +1 -0
  15. package/dist/cjs/src/bitget.js +16 -9
  16. package/dist/cjs/src/bithumb.js +1 -0
  17. package/dist/cjs/src/bitso.js +1 -0
  18. package/dist/cjs/src/bitvavo.js +26 -40
  19. package/dist/cjs/src/blockchaincom.js +1 -0
  20. package/dist/cjs/src/btcalpha.js +1 -0
  21. package/dist/cjs/src/btcbox.js +1 -0
  22. package/dist/cjs/src/btcmarkets.js +1 -0
  23. package/dist/cjs/src/btcturk.js +1 -0
  24. package/dist/cjs/src/bybit.js +186 -127
  25. package/dist/cjs/src/coinsph.js +4 -1
  26. package/dist/cjs/src/cryptocom.js +6 -3
  27. package/dist/cjs/src/deribit.js +3 -2
  28. package/dist/cjs/src/digifinex.js +1 -1
  29. package/dist/cjs/src/gate.js +9 -13
  30. package/dist/cjs/src/gemini.js +5 -5
  31. package/dist/cjs/src/htx.js +11 -1
  32. package/dist/cjs/src/hyperliquid.js +3 -0
  33. package/dist/cjs/src/independentreserve.js +1 -0
  34. package/dist/cjs/src/indodax.js +17 -6
  35. package/dist/cjs/src/kraken.js +31 -8
  36. package/dist/cjs/src/krakenfutures.js +1 -0
  37. package/dist/cjs/src/kucoin.js +1 -2
  38. package/dist/cjs/src/luno.js +4 -1
  39. package/dist/cjs/src/mercado.js +1 -0
  40. package/dist/cjs/src/mexc.js +84 -37
  41. package/dist/cjs/src/novadax.js +1 -0
  42. package/dist/cjs/src/oceanex.js +1 -0
  43. package/dist/cjs/src/okcoin.js +4 -1
  44. package/dist/cjs/src/okx.js +52 -8
  45. package/dist/cjs/src/phemex.js +1 -1
  46. package/dist/cjs/src/pro/apex.js +8 -4
  47. package/dist/cjs/src/pro/backpack.js +7 -5
  48. package/dist/cjs/src/pro/binance.js +150 -19
  49. package/dist/cjs/src/pro/bingx.js +206 -220
  50. package/dist/cjs/src/pro/bitget.js +332 -76
  51. package/dist/cjs/src/pro/cex.js +1 -0
  52. package/dist/cjs/src/pro/htx.js +1 -1
  53. package/dist/cjs/src/pro/independentreserve.js +1 -0
  54. package/dist/cjs/src/pro/mexc.js +23 -23
  55. package/dist/cjs/src/pro/okx.js +46 -10
  56. package/dist/cjs/src/pro/toobit.js +1163 -0
  57. package/dist/cjs/src/pro/tradeogre.js +1 -1
  58. package/dist/cjs/src/toobit.js +2999 -0
  59. package/dist/cjs/src/tradeogre.js +1 -1
  60. package/dist/cjs/src/upbit.js +1 -0
  61. package/dist/cjs/src/wavesexchange.js +1 -0
  62. package/dist/cjs/src/yobit.js +1 -0
  63. package/dist/cjs/src/zaif.js +1 -0
  64. package/dist/cjs/src/zonda.js +1 -0
  65. package/js/ccxt.d.ts +8 -8
  66. package/js/ccxt.js +6 -6
  67. package/js/src/abstract/mexc.d.ts +1 -0
  68. package/js/src/abstract/myokx.d.ts +1 -0
  69. package/js/src/abstract/okx.d.ts +1 -0
  70. package/js/src/abstract/okxus.d.ts +1 -0
  71. package/js/src/abstract/toobit.d.ts +66 -0
  72. package/js/src/apex.js +2 -2
  73. package/js/src/backpack.js +1 -1
  74. package/js/src/base/Exchange.d.ts +9 -0
  75. package/js/src/base/Exchange.js +129 -2
  76. package/js/src/bigone.js +4 -4
  77. package/js/src/binance.d.ts +9 -0
  78. package/js/src/binance.js +82 -20
  79. package/js/src/bingx.js +5 -2
  80. package/js/src/bitbank.js +1 -0
  81. package/js/src/bitbns.js +1 -0
  82. package/js/src/bitflyer.js +1 -0
  83. package/js/src/bitget.js +16 -9
  84. package/js/src/bithumb.js +1 -0
  85. package/js/src/bitso.js +1 -0
  86. package/js/src/bitvavo.d.ts +0 -2
  87. package/js/src/bitvavo.js +27 -41
  88. package/js/src/blockchaincom.js +1 -0
  89. package/js/src/btcalpha.js +1 -0
  90. package/js/src/btcbox.js +1 -0
  91. package/js/src/btcmarkets.js +1 -0
  92. package/js/src/btcturk.js +1 -0
  93. package/js/src/bybit.d.ts +8 -0
  94. package/js/src/bybit.js +186 -127
  95. package/js/src/coinsph.js +4 -1
  96. package/js/src/cryptocom.js +6 -3
  97. package/js/src/deribit.js +3 -2
  98. package/js/src/digifinex.js +1 -1
  99. package/js/src/gate.d.ts +2 -2
  100. package/js/src/gate.js +9 -13
  101. package/js/src/gemini.js +5 -5
  102. package/js/src/htx.js +11 -1
  103. package/js/src/hyperliquid.js +3 -0
  104. package/js/src/independentreserve.js +1 -0
  105. package/js/src/indodax.js +17 -6
  106. package/js/src/kraken.d.ts +2 -2
  107. package/js/src/kraken.js +31 -8
  108. package/js/src/krakenfutures.js +1 -0
  109. package/js/src/kucoin.js +1 -2
  110. package/js/src/luno.js +4 -1
  111. package/js/src/mercado.js +1 -0
  112. package/js/src/mexc.d.ts +4 -1
  113. package/js/src/mexc.js +84 -37
  114. package/js/src/novadax.js +1 -0
  115. package/js/src/oceanex.js +1 -0
  116. package/js/src/okcoin.js +4 -1
  117. package/js/src/okx.js +52 -8
  118. package/js/src/phemex.js +1 -1
  119. package/js/src/pro/apex.js +8 -4
  120. package/js/src/pro/backpack.d.ts +1 -1
  121. package/js/src/pro/backpack.js +7 -5
  122. package/js/src/pro/binance.d.ts +24 -0
  123. package/js/src/pro/binance.js +150 -19
  124. package/js/src/pro/bingx.d.ts +53 -33
  125. package/js/src/pro/bingx.js +207 -221
  126. package/js/src/pro/bitget.d.ts +6 -0
  127. package/js/src/pro/bitget.js +332 -76
  128. package/js/src/pro/cex.js +1 -0
  129. package/js/src/pro/htx.js +1 -1
  130. package/js/src/pro/independentreserve.js +1 -0
  131. package/js/src/pro/mexc.js +23 -23
  132. package/js/src/pro/okx.d.ts +7 -1
  133. package/js/src/pro/okx.js +46 -10
  134. package/js/src/pro/toobit.d.ts +174 -0
  135. package/js/src/pro/toobit.js +1162 -0
  136. package/js/src/toobit.d.ts +456 -0
  137. package/js/src/toobit.js +2992 -0
  138. package/js/src/upbit.js +1 -0
  139. package/js/src/wavesexchange.js +1 -0
  140. package/js/src/yobit.js +1 -0
  141. package/js/src/zaif.js +1 -0
  142. package/js/src/zonda.js +1 -0
  143. package/package.json +1 -1
  144. package/dist/373.ccxt.browser.js +0 -7630
  145. package/dist/373.ccxt.browser.min.js +0 -1
  146. package/js/src/abstract/tradeogre.d.ts +0 -21
  147. package/js/src/pro/tradeogre.d.ts +0 -49
  148. package/js/src/pro/tradeogre.js +0 -278
  149. package/js/src/tradeogre.d.ts +0 -149
  150. package/js/src/tradeogre.js +0 -872
  151. /package/js/src/abstract/{tradeogre.js → toobit.js} +0 -0
@@ -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,
@@ -763,6 +764,9 @@ class mexc extends mexc$1["default"] {
763
764
  },
764
765
  'spot': {
765
766
  'extends': 'default',
767
+ 'fetchCurrencies': {
768
+ 'private': true,
769
+ },
766
770
  },
767
771
  'forDerivs': {
768
772
  'extends': 'default',
@@ -1053,7 +1057,7 @@ class mexc extends mexc$1["default"] {
1053
1057
  // therefore we check the keys here
1054
1058
  // and fallback to generating the currencies from the markets
1055
1059
  if (!this.checkRequiredCredentials(false)) {
1056
- return undefined;
1060
+ return {};
1057
1061
  }
1058
1062
  const response = await this.spotPrivateGetCapitalConfigGetall(params);
1059
1063
  //
@@ -5266,7 +5270,7 @@ class mexc extends mexc$1["default"] {
5266
5270
  const request = {
5267
5271
  'transact_id': id,
5268
5272
  };
5269
- const response = await this.spot2PrivateGetAssetInternalTransferInfo(this.extend(request, query));
5273
+ const response = await this.spotPrivateGetAssetInternalTransferRecord(this.extend(request, query));
5270
5274
  //
5271
5275
  // {
5272
5276
  // "code": "200",
@@ -5294,60 +5298,84 @@ class mexc extends mexc$1["default"] {
5294
5298
  * @description fetch a history of internal transfers made on an account
5295
5299
  * @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
5296
5300
  * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
5297
- * @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
5298
5303
  * @param {int} [since] the earliest time in ms to fetch transfers for
5299
5304
  * @param {int} [limit] the maximum number of transfers structures to retrieve
5300
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
5301
5308
  * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
5302
5309
  */
5303
5310
  async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
5304
- const [marketType, query] = this.handleMarketTypeAndParams('fetchTransfers', undefined, params);
5311
+ let marketType = undefined;
5312
+ [marketType, params] = this.handleMarketTypeAndParams('fetchTransfers', undefined, params);
5305
5313
  await this.loadMarkets();
5306
5314
  const request = {};
5307
5315
  let currency = undefined;
5308
- let resultList = undefined;
5309
5316
  if (code !== undefined) {
5310
5317
  currency = this.currency(code);
5311
- request['currency'] = currency['id'];
5312
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 = [];
5313
5343
  if (marketType === 'spot') {
5314
5344
  if (since !== undefined) {
5315
- request['start_time'] = since;
5345
+ request['startTime'] = since;
5316
5346
  }
5317
5347
  if (limit !== undefined) {
5318
- if (limit > 50) {
5348
+ if (limit > 100) {
5319
5349
  throw new errors.ExchangeError('This exchange supports a maximum limit of 50');
5320
5350
  }
5321
- request['page-size'] = limit;
5351
+ request['size'] = limit;
5322
5352
  }
5323
- const response = await this.spot2PrivateGetAssetInternalTransferRecord(this.extend(request, query));
5353
+ const response = await this.spotPrivateGetCapitalTransfer(this.extend(request, params));
5324
5354
  //
5325
- // {
5326
- // "code": "200",
5327
- // "data": {
5328
- // "total_page": "1",
5329
- // "total_size": "5",
5330
- // "result_list": [{
5331
- // "currency": "USDT",
5332
- // "amount": "1",
5333
- // "transact_id": "954877a2ef54499db9b28a7cf9ebcf41",
5334
- // "from": "MAIN",
5335
- // "to": "CONTRACT",
5336
- // "transact_state": "SUCCESS"
5337
- // },
5338
- // ...
5339
- // ]
5340
- // }
5341
- // }
5342
5355
  //
5343
- const data = this.safeValue(response, 'data', {});
5344
- 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', []);
5345
5373
  }
5346
5374
  else if (marketType === 'swap') {
5347
5375
  if (limit !== undefined) {
5348
5376
  request['page_size'] = limit;
5349
5377
  }
5350
- const response = await this.contractPrivateGetAccountTransferRecord(this.extend(request, query));
5378
+ const response = await this.contractPrivateGetAccountTransferRecord(this.extend(request, params));
5351
5379
  const data = this.safeValue(response, 'data');
5352
5380
  resultList = this.safeValue(data, 'resultList');
5353
5381
  //
@@ -5396,10 +5424,10 @@ class mexc extends mexc$1["default"] {
5396
5424
  const accounts = {
5397
5425
  'spot': 'SPOT',
5398
5426
  'swap': 'FUTURES',
5399
- 'margin': 'ISOLATED_MARGIN',
5427
+ 'future': 'FUTURES',
5400
5428
  };
5401
- const fromId = this.safeString(accounts, fromAccount);
5402
- const toId = this.safeString(accounts, toAccount);
5429
+ const fromId = this.safeString(accounts, fromAccount, fromAccount);
5430
+ const toId = this.safeString(accounts, toAccount, toAccount);
5403
5431
  if (fromId === undefined) {
5404
5432
  const keys = Object.keys(accounts);
5405
5433
  throw new errors.ExchangeError(this.id + ' fromAccount must be one of ' + keys.join(', '));
@@ -5461,6 +5489,17 @@ class mexc extends mexc$1["default"] {
5461
5489
  // "createTime": "1648849076000",
5462
5490
  // "updateTime": "1648849076000"
5463
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
+ // }
5464
5503
  //
5465
5504
  // transfer
5466
5505
  //
@@ -5468,14 +5507,20 @@ class mexc extends mexc$1["default"] {
5468
5507
  // "tranId": "ebb06123e6a64f4ab234b396c548d57e"
5469
5508
  // }
5470
5509
  //
5471
- const currencyId = this.safeString(transfer, 'currency');
5510
+ const currencyId = this.safeString2(transfer, 'currency', 'asset');
5472
5511
  const id = this.safeStringN(transfer, ['transact_id', 'txid', 'tranId']);
5473
- const timestamp = this.safeInteger(transfer, 'createTime');
5512
+ const timestamp = this.safeInteger2(transfer, 'createTime', 'timestamp');
5474
5513
  const datetime = (timestamp !== undefined) ? this.iso8601(timestamp) : undefined;
5475
5514
  const direction = this.safeString(transfer, 'type');
5476
5515
  let accountFrom = undefined;
5477
5516
  let accountTo = undefined;
5478
- 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) {
5479
5524
  accountFrom = (direction === 'IN') ? 'MAIN' : 'CONTRACT';
5480
5525
  accountTo = (direction === 'IN') ? 'CONTRACT' : 'MAIN';
5481
5526
  }
@@ -5492,11 +5537,13 @@ class mexc extends mexc$1["default"] {
5492
5537
  'amount': this.safeNumber(transfer, 'amount'),
5493
5538
  'fromAccount': this.parseAccountId(accountFrom),
5494
5539
  'toAccount': this.parseAccountId(accountTo),
5495
- 'status': this.parseTransferStatus(this.safeString2(transfer, 'transact_state', 'state')),
5540
+ 'status': this.parseTransferStatus(this.safeStringN(transfer, ['transact_state', 'state', 'status'])),
5496
5541
  };
5497
5542
  }
5498
5543
  parseAccountId(status) {
5499
5544
  const statuses = {
5545
+ 'SPOT': 'spot',
5546
+ 'FUTURES': 'swap',
5500
5547
  'MAIN': 'spot',
5501
5548
  'CONTRACT': 'swap',
5502
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,
@@ -210,6 +210,9 @@ class okcoin extends okcoin$1["default"] {
210
210
  'features': {
211
211
  'spot': {
212
212
  'sandbox': false,
213
+ 'fetchCurrencies': {
214
+ 'private': true,
215
+ },
213
216
  'createOrder': {
214
217
  'marginMode': true,
215
218
  'triggerPrice': true,
@@ -824,7 +827,7 @@ class okcoin extends okcoin$1["default"] {
824
827
  if (this.options['warnOnFetchCurrenciesWithoutAuthorization']) {
825
828
  throw new errors.ExchangeError(this.id + ' fetchCurrencies() is a private API endpoint that requires authentication with API keys. Set the API keys on the exchange instance or exchange.options["warnOnFetchCurrenciesWithoutAuthorization"] = false to suppress this warning message.');
826
829
  }
827
- return undefined;
830
+ return {};
828
831
  }
829
832
  else {
830
833
  const response = await this.privateGetAssetCurrencies(params);
@@ -507,6 +507,7 @@ class okx extends okx$1["default"] {
507
507
  'account/fixed-loan/repay-borrowing-order': 5,
508
508
  'account/bills-history-archive': 72000,
509
509
  'account/move-positions': 10,
510
+ 'account/set-settle-currency': 1,
510
511
  // subaccount
511
512
  'users/subaccount/modify-apikey': 10,
512
513
  'asset/subaccount/transfer': 10,
@@ -689,6 +690,7 @@ class okx extends okx$1["default"] {
689
690
  '51031': errors.InvalidOrder,
690
691
  '51046': errors.InvalidOrder,
691
692
  '51047': errors.InvalidOrder,
693
+ '51051': errors.InvalidOrder,
692
694
  '51072': errors.InvalidOrder,
693
695
  '51073': errors.InvalidOrder,
694
696
  '51074': errors.InvalidOrder,
@@ -828,6 +830,9 @@ class okx extends okx$1["default"] {
828
830
  '54008': errors.InvalidOrder,
829
831
  '54009': errors.InvalidOrder,
830
832
  '54011': errors.InvalidOrder,
833
+ '54072': errors.ExchangeError,
834
+ '54073': errors.BadRequest,
835
+ '54074': errors.ExchangeError,
831
836
  // Trading bot Error Code from 55100 to 55999
832
837
  '55100': errors.InvalidOrder,
833
838
  '55101': errors.InvalidOrder,
@@ -933,6 +938,9 @@ class okx extends okx$1["default"] {
933
938
  '59519': errors.ExchangeError,
934
939
  '59642': errors.BadRequest,
935
940
  '59643': errors.ExchangeError,
941
+ '59683': errors.ExchangeError,
942
+ '59684': errors.BadRequest,
943
+ '59686': errors.BadRequest,
936
944
  // WebSocket error Codes from 60000-63999
937
945
  '60001': errors.AuthenticationError,
938
946
  '60002': errors.AuthenticationError,
@@ -1299,6 +1307,9 @@ class okx extends okx$1["default"] {
1299
1307
  },
1300
1308
  'spot': {
1301
1309
  'extends': 'default',
1310
+ 'fetchCurrencies': {
1311
+ 'private': true,
1312
+ },
1302
1313
  },
1303
1314
  'swap': {
1304
1315
  'linear': {
@@ -1506,14 +1517,33 @@ class okx extends okx$1["default"] {
1506
1517
  // "data": [
1507
1518
  // {
1508
1519
  // "acctLv": "2",
1520
+ // "acctStpMode": "cancel_maker",
1509
1521
  // "autoLoan": false,
1510
1522
  // "ctIsoMode": "automatic",
1523
+ // "enableSpotBorrow": false,
1511
1524
  // "greeksType": "PA",
1525
+ // "feeType": "0",
1526
+ // "ip": "",
1527
+ // "type": "0",
1528
+ // "kycLv": "3",
1529
+ // "label": "v5 test",
1512
1530
  // "level": "Lv1",
1513
1531
  // "levelTmp": "",
1532
+ // "liquidationGear": "-1",
1533
+ // "mainUid": "44705892343619584",
1514
1534
  // "mgnIsoMode": "automatic",
1535
+ // "opAuth": "1",
1536
+ // "perm": "read_only,withdraw,trade",
1515
1537
  // "posMode": "long_short_mode",
1516
- // "uid": "88018754289672195"
1538
+ // "roleType": "0",
1539
+ // "spotBorrowAutoRepay": false,
1540
+ // "spotOffsetType": "",
1541
+ // "spotRoleType": "0",
1542
+ // "spotTraderInsts": [],
1543
+ // "traderInsts": [],
1544
+ // "uid": "44705892343619584",
1545
+ // "settleCcy": "USDT",
1546
+ // "settleCcyList": ["USD", "USDC", "USDG"],
1517
1547
  // }
1518
1548
  // ],
1519
1549
  // "msg": ""
@@ -1795,7 +1825,7 @@ class okx extends okx$1["default"] {
1795
1825
  // and fallback to generating the currencies from the markets
1796
1826
  const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1797
1827
  if (!this.checkRequiredCredentials(false) || isSandboxMode) {
1798
- return undefined;
1828
+ return {};
1799
1829
  }
1800
1830
  //
1801
1831
  // has['fetchCurrencies'] is currently set to true, but an unauthorized request returns
@@ -3159,7 +3189,8 @@ class okx extends okx$1["default"] {
3159
3189
  request['attachAlgoOrds'] = [attachAlgoOrd];
3160
3190
  }
3161
3191
  }
3162
- else if (trigger) {
3192
+ // algo order details
3193
+ if (trigger) {
3163
3194
  request['ordType'] = 'trigger';
3164
3195
  request['triggerPx'] = this.priceToPrecision(symbol, triggerPrice);
3165
3196
  request['orderPx'] = isMarketOrder ? '-1' : this.priceToPrecision(symbol, price);
@@ -3610,10 +3641,18 @@ class okx extends okx$1["default"] {
3610
3641
  }
3611
3642
  else {
3612
3643
  for (let i = 0; i < clientOrderIds.length; i++) {
3613
- request.push({
3614
- 'instId': market['id'],
3615
- 'clOrdId': clientOrderIds[i],
3616
- });
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
+ }
3617
3656
  }
3618
3657
  }
3619
3658
  let response = undefined;
@@ -3690,7 +3729,12 @@ class okx extends okx$1["default"] {
3690
3729
  idKey = 'algoId';
3691
3730
  }
3692
3731
  else if (clientOrderId !== undefined) {
3693
- idKey = 'clOrdId';
3732
+ if (isStopOrTrailing) {
3733
+ idKey = 'algoClOrdId';
3734
+ }
3735
+ else {
3736
+ idKey = 'clOrdId';
3737
+ }
3694
3738
  }
3695
3739
  const requestItem = {
3696
3740
  'instId': market['id'],
@@ -4072,7 +4072,7 @@ class phemex extends phemex$1["default"] {
4072
4072
  const isCross = this.safeValue(position, 'crossMargin');
4073
4073
  return this.safePosition({
4074
4074
  'info': position,
4075
- 'id': undefined,
4075
+ 'id': this.safeString(position, 'execSeq'),
4076
4076
  'symbol': symbol,
4077
4077
  'contracts': this.parseNumber(contracts),
4078
4078
  'contractSize': contractSize,
@@ -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;
@@ -964,6 +967,7 @@ class apex extends apex$1["default"] {
964
967
  }
965
968
  ping(client) {
966
969
  const timeStamp = this.milliseconds().toString();
970
+ client.lastPong = timeStamp; // server won't send a pong, so we set it here
967
971
  return {
968
972
  'args': [timeStamp],
969
973
  'op': 'ping',
@@ -802,7 +802,7 @@ class backpack extends backpack$1["default"] {
802
802
  }
803
803
  /**
804
804
  * @method
805
- * @name kucoin#unWatchOrderBookForSymbols
805
+ * @name backpack#unWatchOrderBookForSymbols
806
806
  * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
807
807
  * @param {string[]} symbols unified array of symbols
808
808
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -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
  }