ccxt 4.4.3 → 4.4.4

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 (120) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +2 -2
  5. package/dist/cjs/src/base/functions/misc.js +11 -0
  6. package/dist/cjs/src/base/functions.js +1 -0
  7. package/dist/cjs/src/base/ws/WsClient.js +2 -1
  8. package/dist/cjs/src/binance.js +39 -12
  9. package/dist/cjs/src/bingx.js +1 -0
  10. package/dist/cjs/src/bitfinex2.js +7 -6
  11. package/dist/cjs/src/bitget.js +10 -6
  12. package/dist/cjs/src/bitmex.js +11 -10
  13. package/dist/cjs/src/bitso.js +5 -4
  14. package/dist/cjs/src/bitstamp.js +9 -9
  15. package/dist/cjs/src/blofin.js +21 -23
  16. package/dist/cjs/src/bybit.js +21 -20
  17. package/dist/cjs/src/coinbase.js +28 -7
  18. package/dist/cjs/src/coinbaseexchange.js +11 -11
  19. package/dist/cjs/src/coinlist.js +6 -5
  20. package/dist/cjs/src/coinmetro.js +3 -3
  21. package/dist/cjs/src/cryptocom.js +7 -5
  22. package/dist/cjs/src/currencycom.js +6 -6
  23. package/dist/cjs/src/delta.js +5 -5
  24. package/dist/cjs/src/digifinex.js +8 -6
  25. package/dist/cjs/src/gate.js +6 -5
  26. package/dist/cjs/src/hashkey.js +9 -7
  27. package/dist/cjs/src/htx.js +13 -16
  28. package/dist/cjs/src/hyperliquid.js +67 -114
  29. package/dist/cjs/src/kraken.js +8 -6
  30. package/dist/cjs/src/kucoin.js +9 -8
  31. package/dist/cjs/src/luno.js +10 -9
  32. package/dist/cjs/src/mexc.js +35 -2
  33. package/dist/cjs/src/ndax.js +6 -5
  34. package/dist/cjs/src/okcoin.js +18 -27
  35. package/dist/cjs/src/okx.js +18 -26
  36. package/dist/cjs/src/p2b.js +2 -2
  37. package/dist/cjs/src/pro/bybit.js +56 -0
  38. package/dist/cjs/src/pro/mexc.js +83 -0
  39. package/dist/cjs/src/woo.js +7 -6
  40. package/dist/cjs/src/woofipro.js +8 -6
  41. package/dist/cjs/src/xt.js +4 -3
  42. package/dist/cjs/src/zonda.js +6 -5
  43. package/js/ccxt.d.ts +1 -1
  44. package/js/ccxt.js +1 -1
  45. package/js/src/base/Exchange.d.ts +2 -2
  46. package/js/src/base/Exchange.js +2 -2
  47. package/js/src/base/functions/misc.d.ts +2 -1
  48. package/js/src/base/functions/misc.js +11 -1
  49. package/js/src/base/types.d.ts +1 -1
  50. package/js/src/base/ws/WsClient.js +2 -2
  51. package/js/src/binance.d.ts +4 -20
  52. package/js/src/binance.js +39 -12
  53. package/js/src/bingx.js +1 -0
  54. package/js/src/bitfinex2.d.ts +3 -19
  55. package/js/src/bitfinex2.js +7 -6
  56. package/js/src/bitget.d.ts +3 -19
  57. package/js/src/bitget.js +10 -6
  58. package/js/src/bitmex.d.ts +3 -22
  59. package/js/src/bitmex.js +11 -10
  60. package/js/src/bitso.d.ts +3 -19
  61. package/js/src/bitso.js +5 -4
  62. package/js/src/bitstamp.d.ts +3 -35
  63. package/js/src/bitstamp.js +9 -9
  64. package/js/src/blofin.d.ts +3 -15
  65. package/js/src/blofin.js +21 -23
  66. package/js/src/bybit.d.ts +3 -19
  67. package/js/src/bybit.js +21 -20
  68. package/js/src/coinbase.d.ts +3 -19
  69. package/js/src/coinbase.js +28 -7
  70. package/js/src/coinbaseexchange.d.ts +3 -19
  71. package/js/src/coinbaseexchange.js +11 -11
  72. package/js/src/coinlist.d.ts +3 -19
  73. package/js/src/coinlist.js +6 -5
  74. package/js/src/coinmetro.d.ts +3 -19
  75. package/js/src/coinmetro.js +3 -3
  76. package/js/src/cryptocom.d.ts +3 -22
  77. package/js/src/cryptocom.js +7 -5
  78. package/js/src/currencycom.d.ts +3 -3
  79. package/js/src/currencycom.js +6 -6
  80. package/js/src/delta.d.ts +3 -19
  81. package/js/src/delta.js +5 -5
  82. package/js/src/digifinex.d.ts +3 -19
  83. package/js/src/digifinex.js +8 -6
  84. package/js/src/gate.d.ts +3 -19
  85. package/js/src/gate.js +6 -5
  86. package/js/src/hashkey.d.ts +3 -20
  87. package/js/src/hashkey.js +9 -7
  88. package/js/src/htx.d.ts +3 -19
  89. package/js/src/htx.js +13 -16
  90. package/js/src/hyperliquid.d.ts +3 -19
  91. package/js/src/hyperliquid.js +68 -115
  92. package/js/src/kraken.d.ts +5 -24
  93. package/js/src/kraken.js +8 -6
  94. package/js/src/kucoin.d.ts +3 -19
  95. package/js/src/kucoin.js +9 -8
  96. package/js/src/luno.d.ts +4 -20
  97. package/js/src/luno.js +10 -9
  98. package/js/src/mexc.js +35 -2
  99. package/js/src/ndax.d.ts +3 -19
  100. package/js/src/ndax.js +6 -5
  101. package/js/src/okcoin.d.ts +3 -19
  102. package/js/src/okcoin.js +18 -27
  103. package/js/src/okx.d.ts +3 -19
  104. package/js/src/okx.js +18 -26
  105. package/js/src/p2b.js +2 -2
  106. package/js/src/pro/bybit.d.ts +2 -0
  107. package/js/src/pro/bybit.js +56 -0
  108. package/js/src/pro/mexc.d.ts +4 -1
  109. package/js/src/pro/mexc.js +84 -1
  110. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  111. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
  112. package/js/src/woo.d.ts +3 -19
  113. package/js/src/woo.js +7 -6
  114. package/js/src/woofipro.d.ts +3 -19
  115. package/js/src/woofipro.js +8 -6
  116. package/js/src/xt.d.ts +3 -22
  117. package/js/src/xt.js +4 -3
  118. package/js/src/zonda.d.ts +3 -19
  119. package/js/src/zonda.js +6 -5
  120. package/package.json +1 -1
@@ -1014,8 +1014,9 @@ class mexc extends mexc$1 {
1014
1014
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1015
1015
  * @returns {object[]} an array of objects representing market data
1016
1016
  */
1017
- const spotMarket = await this.fetchSpotMarkets(params);
1018
- const swapMarket = await this.fetchSwapMarkets(params);
1017
+ const spotMarketPromise = this.fetchSpotMarkets(params);
1018
+ const swapMarketPromise = this.fetchSwapMarkets(params);
1019
+ const [spotMarket, swapMarket] = await Promise.all([spotMarketPromise, swapMarketPromise]);
1019
1020
  return this.arrayConcat(spotMarket, swapMarket);
1020
1021
  }
1021
1022
  async fetchSpotMarkets(params = {}) {
@@ -1154,7 +1155,10 @@ class mexc extends mexc$1 {
1154
1155
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1155
1156
  * @returns {object[]} an array of objects representing market data
1156
1157
  */
1158
+ const currentRl = this.rateLimit;
1159
+ this.setProperty(this, 'rateLimit', 10); // see comment: https://github.com/ccxt/ccxt/pull/23698
1157
1160
  const response = await this.contractPublicGetDetail(params);
1161
+ this.setProperty(this, 'rateLimit', currentRl);
1158
1162
  //
1159
1163
  // {
1160
1164
  // "success":true,
@@ -3061,6 +3065,9 @@ class mexc extends mexc$1 {
3061
3065
  * @method
3062
3066
  * @name mexc#cancelAllOrders
3063
3067
  * @description cancel all open orders
3068
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-all-open-orders-on-a-symbol
3069
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-orders-under-a-contract-under-maintenance
3070
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-trigger-orders-under-maintenance
3064
3071
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
3065
3072
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3066
3073
  * @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
@@ -3464,6 +3471,8 @@ class mexc extends mexc$1 {
3464
3471
  * @method
3465
3472
  * @name mexc#fetchAccounts
3466
3473
  * @description fetch all the accounts associated with a profile
3474
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3475
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3467
3476
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3468
3477
  * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
3469
3478
  */
@@ -3491,6 +3500,8 @@ class mexc extends mexc$1 {
3491
3500
  * @method
3492
3501
  * @name mexc#fetchTradingFees
3493
3502
  * @description fetch the trading fees for multiple markets
3503
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3504
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3494
3505
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3495
3506
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
3496
3507
  */
@@ -3776,6 +3787,8 @@ class mexc extends mexc$1 {
3776
3787
  * @method
3777
3788
  * @name mexc#fetchMyTrades
3778
3789
  * @description fetch all trades made by the user
3790
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
3791
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-transaction-details-of-the-user-s-order
3779
3792
  * @param {string} symbol unified market symbol
3780
3793
  * @param {int} [since] the earliest time in ms to fetch trades for
3781
3794
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -3866,6 +3879,8 @@ class mexc extends mexc$1 {
3866
3879
  * @method
3867
3880
  * @name mexc#fetchOrderTrades
3868
3881
  * @description fetch all the trades made from a single order
3882
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
3883
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
3869
3884
  * @param {string} id order id
3870
3885
  * @param {string} symbol unified market symbol
3871
3886
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -3964,6 +3979,7 @@ class mexc extends mexc$1 {
3964
3979
  * @method
3965
3980
  * @name mexc#reduceMargin
3966
3981
  * @description remove margin from a position
3982
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
3967
3983
  * @param {string} symbol unified market symbol
3968
3984
  * @param {float} amount the amount of margin to remove
3969
3985
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3976,6 +3992,7 @@ class mexc extends mexc$1 {
3976
3992
  * @method
3977
3993
  * @name mexc#addMargin
3978
3994
  * @description add margin
3995
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
3979
3996
  * @param {string} symbol unified market symbol
3980
3997
  * @param {float} amount amount of margin to add
3981
3998
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -3988,6 +4005,7 @@ class mexc extends mexc$1 {
3988
4005
  * @method
3989
4006
  * @name mexc#setLeverage
3990
4007
  * @description set the level of leverage for a market
4008
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
3991
4009
  * @param {float} leverage the rate of leverage
3992
4010
  * @param {string} symbol unified market symbol
3993
4011
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -4021,6 +4039,7 @@ class mexc extends mexc$1 {
4021
4039
  * @method
4022
4040
  * @name mexc#fetchFundingHistory
4023
4041
  * @description fetch the history of funding payments paid and received on this account
4042
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-details-of-user-s-funding-rate
4024
4043
  * @param {string} symbol unified market symbol
4025
4044
  * @param {int} [since] the earliest time in ms to fetch funding history for
4026
4045
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -4136,6 +4155,7 @@ class mexc extends mexc$1 {
4136
4155
  * @method
4137
4156
  * @name mexc#fetchFundingRate
4138
4157
  * @description fetch the current funding rate
4158
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
4139
4159
  * @param {string} symbol unified market symbol
4140
4160
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4141
4161
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -4169,6 +4189,7 @@ class mexc extends mexc$1 {
4169
4189
  * @method
4170
4190
  * @name mexc#fetchFundingRateHistory
4171
4191
  * @description fetches historical funding rate prices
4192
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate-history
4172
4193
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
4173
4194
  * @param {int} [since] not used by mexc, but filtered internally by ccxt
4174
4195
  * @param {int} [limit] mexc limit is page_size default 20, maximum is 100
@@ -4902,6 +4923,16 @@ class mexc extends mexc$1 {
4902
4923
  });
4903
4924
  }
4904
4925
  async fetchTransfer(id, code = undefined, params = {}) {
4926
+ /**
4927
+ * @method
4928
+ * @name mexc#fetchTransfer
4929
+ * @description fetches a transfer
4930
+ * @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#internal-assets-transfer-order-inquiry
4931
+ * @param {string} id transfer id
4932
+ * @param {string} [code] not used by mexc fetchTransfer
4933
+ * @param {object} params extra parameters specific to the exchange api endpoint
4934
+ * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
4935
+ */
4905
4936
  const [marketType, query] = this.handleMarketTypeAndParams('fetchTransfer', undefined, params);
4906
4937
  await this.loadMarkets();
4907
4938
  if (marketType === 'spot') {
@@ -4935,6 +4966,8 @@ class mexc extends mexc$1 {
4935
4966
  * @method
4936
4967
  * @name mexc#fetchTransfers
4937
4968
  * @description fetch a history of internal transfers made on an account
4969
+ * @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
4970
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
4938
4971
  * @param {string} code unified currency code of the currency transferred
4939
4972
  * @param {int} [since] the earliest time in ms to fetch transfers for
4940
4973
  * @param {int} [limit] the maximum number of transfers structures to retrieve
@@ -1138,6 +1138,7 @@ class ndax extends ndax$1 {
1138
1138
  // }
1139
1139
  //
1140
1140
  const currencyId = this.safeString(item, 'ProductId');
1141
+ currency = this.safeCurrency(currencyId, currency);
1141
1142
  const credit = this.safeString(item, 'CR');
1142
1143
  const debit = this.safeString(item, 'DR');
1143
1144
  let amount = undefined;
@@ -1159,7 +1160,7 @@ class ndax extends ndax$1 {
1159
1160
  before = Precise["default"].stringMax('0', Precise["default"].stringSub(after, amount));
1160
1161
  }
1161
1162
  const timestamp = this.safeInteger(item, 'TimeStamp');
1162
- return {
1163
+ return this.safeLedgerEntry({
1163
1164
  'info': item,
1164
1165
  'id': this.safeString(item, 'TransactionId'),
1165
1166
  'direction': direction,
@@ -1175,17 +1176,17 @@ class ndax extends ndax$1 {
1175
1176
  'timestamp': timestamp,
1176
1177
  'datetime': this.iso8601(timestamp),
1177
1178
  'fee': undefined,
1178
- };
1179
+ }, currency);
1179
1180
  }
1180
1181
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1181
1182
  /**
1182
1183
  * @method
1183
1184
  * @name ndax#fetchLedger
1184
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1185
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1185
1186
  * @see https://apidoc.ndax.io/#getaccounttransactions
1186
- * @param {string} code unified currency code, default is undefined
1187
+ * @param {string} [code] unified currency code, default is undefined
1187
1188
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1188
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1189
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1189
1190
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1190
1191
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1191
1192
  */
@@ -2858,13 +2858,13 @@ class okcoin extends okcoin$1 {
2858
2858
  /**
2859
2859
  * @method
2860
2860
  * @name okcoin#fetchLedger
2861
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2861
2862
  * @see https://www.okcoin.com/docs-v5/en/#rest-api-funding-asset-bills-details
2862
2863
  * @see https://www.okcoin.com/docs-v5/en/#rest-api-account-get-bills-details-last-7-days
2863
2864
  * @see https://www.okcoin.com/docs-v5/en/#rest-api-account-get-bills-details-last-3-months
2864
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2865
- * @param {string} code unified currency code, default is undefined
2865
+ * @param {string} [code] unified currency code, default is undefined
2866
2866
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2867
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2867
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2868
2868
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2869
2869
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2870
2870
  */
@@ -3006,46 +3006,37 @@ class okcoin extends okcoin$1 {
3006
3006
  // "ts": "1597026383085"
3007
3007
  // }
3008
3008
  //
3009
- const id = this.safeString(item, 'billId');
3010
- const account = undefined;
3011
- const referenceId = this.safeString(item, 'ordId');
3012
- const referenceAccount = undefined;
3013
- const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
3014
- const code = this.safeCurrencyCode(this.safeString(item, 'ccy'), currency);
3015
- const amountString = this.safeString(item, 'balChg');
3016
- const amount = this.parseNumber(amountString);
3009
+ const currencyId = this.safeString(item, 'ccy');
3010
+ const code = this.safeCurrencyCode(currencyId, currency);
3011
+ currency = this.safeCurrency(currencyId, currency);
3017
3012
  const timestamp = this.safeInteger(item, 'ts');
3018
3013
  const feeCostString = this.safeString(item, 'fee');
3019
3014
  let fee = undefined;
3020
3015
  if (feeCostString !== undefined) {
3021
3016
  fee = {
3022
- 'cost': this.parseNumber(Precise["default"].stringNeg(feeCostString)),
3017
+ 'cost': this.parseToNumeric(Precise["default"].stringNeg(feeCostString)),
3023
3018
  'currency': code,
3024
3019
  };
3025
3020
  }
3026
- const before = undefined;
3027
- const afterString = this.safeString(item, 'bal');
3028
- const after = this.parseNumber(afterString);
3029
- const status = 'ok';
3030
3021
  const marketId = this.safeString(item, 'instId');
3031
3022
  const symbol = this.safeSymbol(marketId, undefined, '-');
3032
- return {
3033
- 'id': id,
3023
+ return this.safeLedgerEntry({
3034
3024
  'info': item,
3025
+ 'id': this.safeString(item, 'billId'),
3035
3026
  'timestamp': timestamp,
3036
3027
  'datetime': this.iso8601(timestamp),
3037
- 'account': account,
3038
- 'referenceId': referenceId,
3039
- 'referenceAccount': referenceAccount,
3040
- 'type': type,
3028
+ 'account': undefined,
3029
+ 'referenceId': this.safeString(item, 'ordId'),
3030
+ 'referenceAccount': undefined,
3031
+ 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
3041
3032
  'currency': code,
3042
3033
  'symbol': symbol,
3043
- 'amount': amount,
3044
- 'before': before,
3045
- 'after': after,
3046
- 'status': status,
3034
+ 'amount': this.safeNumber(item, 'balChg'),
3035
+ 'before': undefined,
3036
+ 'after': this.safeNumber(item, 'bal'),
3037
+ 'status': 'ok',
3047
3038
  'fee': fee,
3048
- };
3039
+ }, currency);
3049
3040
  }
3050
3041
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3051
3042
  const isArray = Array.isArray(params);
@@ -790,6 +790,7 @@ class okx extends okx$1 {
790
790
  // SPOT/MARGIN error codes 54000-54999
791
791
  '54000': errors.ExchangeError,
792
792
  '54001': errors.ExchangeError,
793
+ '54011': errors.InvalidOrder,
793
794
  // Trading bot Error Code from 55100 to 55999
794
795
  '55100': errors.InvalidOrder,
795
796
  '55101': errors.InvalidOrder,
@@ -4471,13 +4472,13 @@ class okx extends okx$1 {
4471
4472
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-get-bills-details-last-7-days
4472
4473
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-get-bills-details-last-3-months
4473
4474
  * @see https://www.okx.com/docs-v5/en/#rest-api-funding-asset-bills-details
4474
- * @param {string} code unified currency code, default is undefined
4475
+ * @param {string} [code] unified currency code, default is undefined
4475
4476
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
4476
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
4477
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
4477
4478
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4478
4479
  * @param {string} [params.marginMode] 'cross' or 'isolated'
4479
4480
  * @param {int} [params.until] the latest time in ms to fetch entries for
4480
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4481
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4481
4482
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
4482
4483
  */
4483
4484
  await this.loadMarkets();
@@ -4640,14 +4641,9 @@ class okx extends okx$1 {
4640
4641
  // "ts": "1597026383085"
4641
4642
  // }
4642
4643
  //
4643
- const id = this.safeString(item, 'billId');
4644
- const account = undefined;
4645
- const referenceId = this.safeString(item, 'ordId');
4646
- const referenceAccount = undefined;
4647
- const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
4648
- const code = this.safeCurrencyCode(this.safeString(item, 'ccy'), currency);
4649
- const amountString = this.safeString(item, 'balChg');
4650
- const amount = this.parseNumber(amountString);
4644
+ const currencyId = this.safeString(item, 'ccy');
4645
+ const code = this.safeCurrencyCode(currencyId, currency);
4646
+ currency = this.safeCurrency(currencyId, currency);
4651
4647
  const timestamp = this.safeInteger(item, 'ts');
4652
4648
  const feeCostString = this.safeString(item, 'fee');
4653
4649
  let fee = undefined;
@@ -4657,29 +4653,25 @@ class okx extends okx$1 {
4657
4653
  'currency': code,
4658
4654
  };
4659
4655
  }
4660
- const before = undefined;
4661
- const afterString = this.safeString(item, 'bal');
4662
- const after = this.parseNumber(afterString);
4663
- const status = 'ok';
4664
4656
  const marketId = this.safeString(item, 'instId');
4665
4657
  const symbol = this.safeSymbol(marketId, undefined, '-');
4666
- return {
4667
- 'id': id,
4658
+ return this.safeLedgerEntry({
4668
4659
  'info': item,
4660
+ 'id': this.safeString(item, 'billId'),
4669
4661
  'timestamp': timestamp,
4670
4662
  'datetime': this.iso8601(timestamp),
4671
- 'account': account,
4672
- 'referenceId': referenceId,
4673
- 'referenceAccount': referenceAccount,
4674
- 'type': type,
4663
+ 'account': undefined,
4664
+ 'referenceId': this.safeString(item, 'ordId'),
4665
+ 'referenceAccount': undefined,
4666
+ 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
4675
4667
  'currency': code,
4676
4668
  'symbol': symbol,
4677
- 'amount': amount,
4678
- 'before': before,
4679
- 'after': after,
4680
- 'status': status,
4669
+ 'amount': this.safeNumber(item, 'balChg'),
4670
+ 'before': undefined,
4671
+ 'after': this.safeNumber(item, 'bal'),
4672
+ 'status': 'ok',
4681
4673
  'fee': fee,
4682
- };
4674
+ }, currency);
4683
4675
  }
4684
4676
  parseDepositAddress(depositAddress, currency = undefined) {
4685
4677
  //
@@ -474,7 +474,7 @@ class p2b extends p2b$1 {
474
474
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
475
475
  /**
476
476
  * @method
477
- * @name p2bfutures#fetchOrderBook
477
+ * @name p2b#fetchOrderBook
478
478
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
479
479
  * @see https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#depth-result
480
480
  * @param {string} symbol unified symbol of the market to fetch the order book for
@@ -643,7 +643,7 @@ class p2b extends p2b$1 {
643
643
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
644
644
  /**
645
645
  * @method
646
- * @name poloniexfutures#fetchOHLCV
646
+ * @name p2b#fetchOHLCV
647
647
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
648
648
  * @see https://github.com/P2B-team/p2b-api-docs/blob/master/api-doc.md#kline
649
649
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
@@ -22,6 +22,7 @@ class bybit extends bybit$1 {
22
22
  'fetchTradesWs': false,
23
23
  'fetchBalanceWs': false,
24
24
  'watchBalance': true,
25
+ 'watchBidsAsks': true,
25
26
  'watchLiquidations': true,
26
27
  'watchLiquidationsForSymbols': false,
27
28
  'watchMyLiquidations': false,
@@ -578,6 +579,52 @@ class bybit extends bybit$1 {
578
579
  const messageHash = 'ticker:' + symbol;
579
580
  client.resolve(this.tickers[symbol], messageHash);
580
581
  }
582
+ async watchBidsAsks(symbols = undefined, params = {}) {
583
+ /**
584
+ * @method
585
+ * @name bybit#watchBidsAsks
586
+ * @description watches best bid & ask for symbols
587
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/orderbook
588
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
589
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
590
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
591
+ */
592
+ await this.loadMarkets();
593
+ symbols = this.marketSymbols(symbols, undefined, false);
594
+ const messageHashes = [];
595
+ const url = await this.getUrlByMarketType(symbols[0], false, 'watchBidsAsks', params);
596
+ params = this.cleanParams(params);
597
+ const marketIds = this.marketIds(symbols);
598
+ const topics = [];
599
+ for (let i = 0; i < marketIds.length; i++) {
600
+ const marketId = marketIds[i];
601
+ const topic = 'orderbook.1.' + marketId;
602
+ topics.push(topic);
603
+ messageHashes.push('bidask:' + symbols[i]);
604
+ }
605
+ const ticker = await this.watchTopics(url, messageHashes, topics, params);
606
+ if (this.newUpdates) {
607
+ return ticker;
608
+ }
609
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
610
+ }
611
+ parseWsBidAsk(orderbook, market = undefined) {
612
+ const timestamp = this.safeInteger(orderbook, 'timestamp');
613
+ const bids = this.sortBy(this.aggregate(orderbook['bids']), 0);
614
+ const asks = this.sortBy(this.aggregate(orderbook['asks']), 0);
615
+ const bestBid = this.safeList(bids, 0, []);
616
+ const bestAsk = this.safeList(asks, 0, []);
617
+ return this.safeTicker({
618
+ 'symbol': market['symbol'],
619
+ 'timestamp': timestamp,
620
+ 'datetime': this.iso8601(timestamp),
621
+ 'ask': this.safeNumber(bestAsk, 0),
622
+ 'askVolume': this.safeNumber(bestAsk, 1),
623
+ 'bid': this.safeNumber(bestBid, 0),
624
+ 'bidVolume': this.safeNumber(bestBid, 1),
625
+ 'info': orderbook,
626
+ }, market);
627
+ }
581
628
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
582
629
  /**
583
630
  * @method
@@ -902,6 +949,8 @@ class bybit extends bybit$1 {
902
949
  // }
903
950
  // }
904
951
  //
952
+ const topic = this.safeString(message, 'topic');
953
+ const limit = topic.split('.')[1];
905
954
  const isSpot = client.url.indexOf('spot') >= 0;
906
955
  const type = this.safeString(message, 'type');
907
956
  const isSnapshot = (type === 'snapshot');
@@ -930,6 +979,13 @@ class bybit extends bybit$1 {
930
979
  const messageHash = 'orderbook' + ':' + symbol;
931
980
  this.orderbooks[symbol] = orderbook;
932
981
  client.resolve(orderbook, messageHash);
982
+ if (limit === '1') {
983
+ const bidask = this.parseWsBidAsk(this.orderbooks[symbol], market);
984
+ const newBidsAsks = {};
985
+ newBidsAsks[symbol] = bidask;
986
+ this.bidsasks[symbol] = bidask;
987
+ client.resolve(newBidsAsks, 'bidask:' + symbol);
988
+ }
933
989
  }
934
990
  handleDelta(bookside, delta) {
935
991
  const bidAsk = this.parseBidAsk(delta, 0, 1);
@@ -28,6 +28,7 @@ class mexc extends mexc$1 {
28
28
  'watchOrders': true,
29
29
  'watchTicker': true,
30
30
  'watchTickers': true,
31
+ 'watchBidsAsks': true,
31
32
  'watchTrades': true,
32
33
  'watchTradesForSymbols': false,
33
34
  },
@@ -107,6 +108,7 @@ class mexc extends mexc$1 {
107
108
  // "t": 1678643605721
108
109
  // }
109
110
  //
111
+ this.handleBidAsk(client, message);
110
112
  const rawTicker = this.safeValue2(message, 'd', 'data');
111
113
  const marketId = this.safeString2(message, 's', 'symbol');
112
114
  const timestamp = this.safeInteger(message, 't');
@@ -235,6 +237,87 @@ class mexc extends mexc$1 {
235
237
  'info': ticker,
236
238
  }, market);
237
239
  }
240
+ async watchBidsAsks(symbols = undefined, params = {}) {
241
+ /**
242
+ * @method
243
+ * @name mexc#watchBidsAsks
244
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#individual-symbol-book-ticker-streams
245
+ * @description watches best bid & ask for symbols
246
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
247
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
248
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
249
+ */
250
+ await this.loadMarkets();
251
+ symbols = this.marketSymbols(symbols, undefined, true, false, true);
252
+ let marketType = undefined;
253
+ if (symbols === undefined) {
254
+ throw new errors.ArgumentsRequired(this.id + 'watchBidsAsks required symbols argument');
255
+ }
256
+ const markets = this.marketsForSymbols(symbols);
257
+ [marketType, params] = this.handleMarketTypeAndParams('watchBidsAsks', markets[0], params);
258
+ const isSpot = marketType === 'spot';
259
+ if (!isSpot) {
260
+ throw new errors.NotSupported(this.id + 'watchBidsAsks only support spot market');
261
+ }
262
+ const messageHashes = [];
263
+ const topics = [];
264
+ for (let i = 0; i < symbols.length; i++) {
265
+ if (isSpot) {
266
+ const market = this.market(symbols[i]);
267
+ topics.push('spot@public.bookTicker.v3.api@' + market['id']);
268
+ }
269
+ messageHashes.push('bidask:' + symbols[i]);
270
+ }
271
+ const url = this.urls['api']['ws']['spot'];
272
+ const request = {
273
+ 'method': 'SUBSCRIPTION',
274
+ 'params': topics,
275
+ };
276
+ const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
277
+ if (this.newUpdates) {
278
+ const tickers = {};
279
+ tickers[ticker['symbol']] = ticker;
280
+ return tickers;
281
+ }
282
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
283
+ }
284
+ handleBidAsk(client, message) {
285
+ //
286
+ // {
287
+ // "c": "spot@public.bookTicker.v3.api@BTCUSDT",
288
+ // "d": {
289
+ // "A": "4.70432",
290
+ // "B": "6.714863",
291
+ // "a": "20744.54",
292
+ // "b": "20744.17"
293
+ // },
294
+ // "s": "BTCUSDT",
295
+ // "t": 1678643605721
296
+ // }
297
+ //
298
+ const parsedTicker = this.parseWsBidAsk(message);
299
+ const symbol = parsedTicker['symbol'];
300
+ this.bidsasks[symbol] = parsedTicker;
301
+ const messageHash = 'bidask:' + symbol;
302
+ client.resolve(parsedTicker, messageHash);
303
+ }
304
+ parseWsBidAsk(ticker, market = undefined) {
305
+ const data = this.safeDict(ticker, 'd');
306
+ const marketId = this.safeString(ticker, 's');
307
+ market = this.safeMarket(marketId, market);
308
+ const symbol = this.safeString(market, 'symbol');
309
+ const timestamp = this.safeInteger(ticker, 't');
310
+ return this.safeTicker({
311
+ 'symbol': symbol,
312
+ 'timestamp': timestamp,
313
+ 'datetime': this.iso8601(timestamp),
314
+ 'ask': this.safeNumber(data, 'a'),
315
+ 'askVolume': this.safeNumber(data, 'A'),
316
+ 'bid': this.safeNumber(data, 'b'),
317
+ 'bidVolume': this.safeNumber(data, 'B'),
318
+ 'info': ticker,
319
+ }, market);
320
+ }
238
321
  async watchSpotPublic(channel, messageHash, params = {}) {
239
322
  const url = this.urls['api']['ws']['spot'];
240
323
  const request = {
@@ -2141,9 +2141,9 @@ class woo extends woo$1 {
2141
2141
  * @name woo#fetchLedger
2142
2142
  * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2143
2143
  * @see https://docs.woo.org/#get-asset-history
2144
- * @param {string} code unified currency code, default is undefined
2144
+ * @param {string} [code] unified currency code, default is undefined
2145
2145
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2146
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2146
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2147
2147
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2148
2148
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2149
2149
  */
@@ -2154,12 +2154,14 @@ class woo extends woo$1 {
2154
2154
  const networkizedCode = this.safeString(item, 'token');
2155
2155
  const currencyDefined = this.getCurrencyFromChaincode(networkizedCode, currency);
2156
2156
  const code = currencyDefined['code'];
2157
+ currency = this.safeCurrency(code, currency);
2157
2158
  const amount = this.safeNumber(item, 'amount');
2158
2159
  const side = this.safeString(item, 'token_side');
2159
2160
  const direction = (side === 'DEPOSIT') ? 'in' : 'out';
2160
2161
  const timestamp = this.safeTimestamp(item, 'created_time');
2161
2162
  const fee = this.parseTokenAndFeeTemp(item, 'fee_token', 'fee_amount');
2162
- return {
2163
+ return this.safeLedgerEntry({
2164
+ 'info': item,
2163
2165
  'id': this.safeString(item, 'id'),
2164
2166
  'currency': code,
2165
2167
  'account': this.safeString(item, 'account'),
@@ -2169,13 +2171,12 @@ class woo extends woo$1 {
2169
2171
  'amount': amount,
2170
2172
  'before': undefined,
2171
2173
  'after': undefined,
2172
- 'fee': fee,
2173
2174
  'direction': direction,
2174
2175
  'timestamp': timestamp,
2175
2176
  'datetime': this.iso8601(timestamp),
2176
2177
  'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
2177
- 'info': item,
2178
- };
2178
+ 'fee': fee,
2179
+ }, currency);
2179
2180
  }
2180
2181
  parseLedgerEntryType(type) {
2181
2182
  const types = {
@@ -2119,13 +2119,15 @@ class woofipro extends woofipro$1 {
2119
2119
  return [currency, this.safeList(data, 'rows', [])];
2120
2120
  }
2121
2121
  parseLedgerEntry(item, currency = undefined) {
2122
- const code = this.safeString(item, 'token');
2122
+ const currencyId = this.safeString(item, 'token');
2123
+ const code = this.safeCurrencyCode(currencyId, currency);
2124
+ currency = this.safeCurrency(currencyId, currency);
2123
2125
  const amount = this.safeNumber(item, 'amount');
2124
2126
  const side = this.safeString(item, 'token_side');
2125
2127
  const direction = (side === 'DEPOSIT') ? 'in' : 'out';
2126
2128
  const timestamp = this.safeInteger(item, 'created_time');
2127
2129
  const fee = this.parseTokenAndFeeTemp(item, 'fee_token', 'fee_amount');
2128
- return {
2130
+ return this.safeLedgerEntry({
2129
2131
  'id': this.safeString(item, 'id'),
2130
2132
  'currency': code,
2131
2133
  'account': this.safeString(item, 'account'),
@@ -2141,7 +2143,7 @@ class woofipro extends woofipro$1 {
2141
2143
  'datetime': this.iso8601(timestamp),
2142
2144
  'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
2143
2145
  'info': item,
2144
- };
2146
+ }, currency);
2145
2147
  }
2146
2148
  parseLedgerEntryType(type) {
2147
2149
  const types = {
@@ -2154,11 +2156,11 @@ class woofipro extends woofipro$1 {
2154
2156
  /**
2155
2157
  * @method
2156
2158
  * @name woofipro#fetchLedger
2157
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2159
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2158
2160
  * @see https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/get-asset-history
2159
- * @param {string} code unified currency code, default is undefined
2161
+ * @param {string} [code] unified currency code, default is undefined
2160
2162
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2161
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2163
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2162
2164
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2163
2165
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2164
2166
  */