ccxt 4.4.3 → 4.4.5

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 (134) 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 +42 -15
  9. package/dist/cjs/src/binanceus.js +1 -0
  10. package/dist/cjs/src/bingx.js +1 -0
  11. package/dist/cjs/src/bitfinex2.js +7 -6
  12. package/dist/cjs/src/bitget.js +57 -100
  13. package/dist/cjs/src/bitmex.js +11 -10
  14. package/dist/cjs/src/bitso.js +5 -4
  15. package/dist/cjs/src/bitstamp.js +9 -9
  16. package/dist/cjs/src/blofin.js +21 -23
  17. package/dist/cjs/src/bybit.js +100 -26
  18. package/dist/cjs/src/coinbase.js +28 -7
  19. package/dist/cjs/src/coinbaseexchange.js +11 -11
  20. package/dist/cjs/src/coinlist.js +6 -5
  21. package/dist/cjs/src/coinmetro.js +3 -3
  22. package/dist/cjs/src/cryptocom.js +7 -5
  23. package/dist/cjs/src/currencycom.js +6 -6
  24. package/dist/cjs/src/delta.js +5 -5
  25. package/dist/cjs/src/digifinex.js +8 -6
  26. package/dist/cjs/src/gate.js +6 -5
  27. package/dist/cjs/src/hashkey.js +9 -7
  28. package/dist/cjs/src/htx.js +13 -16
  29. package/dist/cjs/src/hyperliquid.js +67 -114
  30. package/dist/cjs/src/kraken.js +8 -6
  31. package/dist/cjs/src/kucoin.js +9 -8
  32. package/dist/cjs/src/luno.js +10 -9
  33. package/dist/cjs/src/lykke.js +2 -2
  34. package/dist/cjs/src/mexc.js +42 -3
  35. package/dist/cjs/src/ndax.js +6 -5
  36. package/dist/cjs/src/okcoin.js +18 -27
  37. package/dist/cjs/src/okx.js +18 -26
  38. package/dist/cjs/src/p2b.js +2 -2
  39. package/dist/cjs/src/paradex.js +1 -1
  40. package/dist/cjs/src/pro/binance.js +6 -2
  41. package/dist/cjs/src/pro/binanceus.js +2 -1
  42. package/dist/cjs/src/pro/bybit.js +56 -0
  43. package/dist/cjs/src/pro/hyperliquid.js +16 -1
  44. package/dist/cjs/src/pro/mexc.js +83 -0
  45. package/dist/cjs/src/pro/paradex.js +1 -0
  46. package/dist/cjs/src/woo.js +7 -6
  47. package/dist/cjs/src/woofipro.js +8 -6
  48. package/dist/cjs/src/xt.js +4 -3
  49. package/dist/cjs/src/zonda.js +6 -5
  50. package/js/ccxt.d.ts +1 -1
  51. package/js/ccxt.js +1 -1
  52. package/js/src/base/Exchange.d.ts +2 -2
  53. package/js/src/base/Exchange.js +2 -2
  54. package/js/src/base/functions/misc.d.ts +2 -1
  55. package/js/src/base/functions/misc.js +11 -1
  56. package/js/src/base/types.d.ts +1 -1
  57. package/js/src/base/ws/WsClient.js +2 -2
  58. package/js/src/binance.d.ts +4 -20
  59. package/js/src/binance.js +42 -15
  60. package/js/src/binanceus.js +1 -0
  61. package/js/src/bingx.js +1 -0
  62. package/js/src/bitfinex2.d.ts +3 -19
  63. package/js/src/bitfinex2.js +7 -6
  64. package/js/src/bitget.d.ts +3 -20
  65. package/js/src/bitget.js +57 -100
  66. package/js/src/bitmex.d.ts +3 -22
  67. package/js/src/bitmex.js +11 -10
  68. package/js/src/bitso.d.ts +3 -19
  69. package/js/src/bitso.js +5 -4
  70. package/js/src/bitstamp.d.ts +3 -35
  71. package/js/src/bitstamp.js +9 -9
  72. package/js/src/blofin.d.ts +3 -15
  73. package/js/src/blofin.js +21 -23
  74. package/js/src/bybit.d.ts +3 -19
  75. package/js/src/bybit.js +100 -26
  76. package/js/src/coinbase.d.ts +3 -19
  77. package/js/src/coinbase.js +28 -7
  78. package/js/src/coinbaseexchange.d.ts +3 -19
  79. package/js/src/coinbaseexchange.js +11 -11
  80. package/js/src/coinlist.d.ts +3 -19
  81. package/js/src/coinlist.js +6 -5
  82. package/js/src/coinmetro.d.ts +3 -19
  83. package/js/src/coinmetro.js +3 -3
  84. package/js/src/cryptocom.d.ts +3 -22
  85. package/js/src/cryptocom.js +7 -5
  86. package/js/src/currencycom.d.ts +3 -3
  87. package/js/src/currencycom.js +6 -6
  88. package/js/src/delta.d.ts +3 -19
  89. package/js/src/delta.js +5 -5
  90. package/js/src/digifinex.d.ts +3 -19
  91. package/js/src/digifinex.js +8 -6
  92. package/js/src/gate.d.ts +3 -19
  93. package/js/src/gate.js +6 -5
  94. package/js/src/hashkey.d.ts +3 -20
  95. package/js/src/hashkey.js +9 -7
  96. package/js/src/htx.d.ts +3 -19
  97. package/js/src/htx.js +13 -16
  98. package/js/src/hyperliquid.d.ts +3 -19
  99. package/js/src/hyperliquid.js +68 -115
  100. package/js/src/kraken.d.ts +5 -24
  101. package/js/src/kraken.js +8 -6
  102. package/js/src/kucoin.d.ts +3 -19
  103. package/js/src/kucoin.js +9 -8
  104. package/js/src/luno.d.ts +4 -20
  105. package/js/src/luno.js +10 -9
  106. package/js/src/lykke.js +2 -2
  107. package/js/src/mexc.js +42 -3
  108. package/js/src/ndax.d.ts +3 -19
  109. package/js/src/ndax.js +6 -5
  110. package/js/src/okcoin.d.ts +3 -19
  111. package/js/src/okcoin.js +18 -27
  112. package/js/src/okx.d.ts +3 -19
  113. package/js/src/okx.js +18 -26
  114. package/js/src/p2b.js +2 -2
  115. package/js/src/paradex.js +1 -1
  116. package/js/src/pro/binance.d.ts +140 -0
  117. package/js/src/pro/binance.js +6 -2
  118. package/js/src/pro/binanceus.js +2 -1
  119. package/js/src/pro/bybit.d.ts +2 -0
  120. package/js/src/pro/bybit.js +56 -0
  121. package/js/src/pro/hyperliquid.d.ts +1 -0
  122. package/js/src/pro/hyperliquid.js +16 -1
  123. package/js/src/pro/mexc.d.ts +4 -1
  124. package/js/src/pro/mexc.js +84 -1
  125. package/js/src/pro/paradex.js +1 -0
  126. package/js/src/woo.d.ts +3 -19
  127. package/js/src/woo.js +7 -6
  128. package/js/src/woofipro.d.ts +3 -19
  129. package/js/src/woofipro.js +8 -6
  130. package/js/src/xt.d.ts +3 -22
  131. package/js/src/xt.js +4 -3
  132. package/js/src/zonda.d.ts +3 -19
  133. package/js/src/zonda.js +6 -5
  134. package/package.json +1 -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 = {
@@ -221,6 +221,7 @@ class paradex extends paradex$1 {
221
221
  * @method
222
222
  * @name paradex#watchTickers
223
223
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
224
+ * @see https://docs.api.testnet.paradex.trade/#sub-markets_summary-operation
224
225
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
225
226
  * @param {object} [params] extra parameters specific to the exchange API endpoint
226
227
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -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
  */
@@ -3597,8 +3597,10 @@ class xt extends xt$1 {
3597
3597
  const side = this.safeString(item, 'side');
3598
3598
  const direction = (side === 'ADD') ? 'in' : 'out';
3599
3599
  const currencyId = this.safeString(item, 'coin');
3600
+ currency = this.safeCurrency(currencyId, currency);
3600
3601
  const timestamp = this.safeInteger(item, 'createdTime');
3601
- return {
3602
+ return this.safeLedgerEntry({
3603
+ 'info': item,
3602
3604
  'id': this.safeString(item, 'id'),
3603
3605
  'direction': direction,
3604
3606
  'account': undefined,
@@ -3616,8 +3618,7 @@ class xt extends xt$1 {
3616
3618
  'currency': undefined,
3617
3619
  'cost': undefined,
3618
3620
  },
3619
- 'info': item,
3620
- };
3621
+ }, currency);
3621
3622
  }
3622
3623
  parseLedgerEntryType(type) {
3623
3624
  const ledgerType = {
@@ -819,11 +819,11 @@ class zonda extends zonda$1 {
819
819
  /**
820
820
  * @method
821
821
  * @name zonda#fetchLedger
822
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
822
823
  * @see https://docs.zondacrypto.exchange/reference/operations-history
823
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
824
- * @param {string} code unified currency code, default is undefined
824
+ * @param {string} [code] unified currency code, default is undefined
825
825
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
826
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
826
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
827
827
  * @param {object} [params] extra parameters specific to the exchange API endpoint
828
828
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
829
829
  */
@@ -1117,6 +1117,7 @@ class zonda extends zonda$1 {
1117
1117
  const timestamp = this.safeInteger(item, 'time');
1118
1118
  const balance = this.safeValue(item, 'balance', {});
1119
1119
  const currencyId = this.safeString(balance, 'currency');
1120
+ currency = this.safeCurrency(currencyId, currency);
1120
1121
  const change = this.safeValue(item, 'change', {});
1121
1122
  let amount = this.safeString(change, 'total');
1122
1123
  let direction = 'in';
@@ -1128,7 +1129,7 @@ class zonda extends zonda$1 {
1128
1129
  // that can be used to enrich the transfers with txid, address etc (you need to use info.detailId as a parameter)
1129
1130
  const fundsBefore = this.safeValue(item, 'fundsBefore', {});
1130
1131
  const fundsAfter = this.safeValue(item, 'fundsAfter', {});
1131
- return {
1132
+ return this.safeLedgerEntry({
1132
1133
  'info': item,
1133
1134
  'id': this.safeString(item, 'historyId'),
1134
1135
  'direction': direction,
@@ -1144,7 +1145,7 @@ class zonda extends zonda$1 {
1144
1145
  'timestamp': timestamp,
1145
1146
  'datetime': this.iso8601(timestamp),
1146
1147
  'fee': undefined,
1147
- };
1148
+ }, currency);
1148
1149
  }
1149
1150
  parseLedgerEntryType(type) {
1150
1151
  const types = {
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.4.2";
7
+ declare const version = "4.4.4";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.4.3';
41
+ const version = '4.4.5';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -756,7 +756,7 @@ export default class Exchange {
756
756
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
757
757
  parseTransfer(transfer: Dict, currency?: Currency): TransferEntry;
758
758
  parseAccount(account: Dict): Account;
759
- parseLedgerEntry(item: Dict, currency?: Currency): object;
759
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
760
760
  parseOrder(order: Dict, market?: Market): Order;
761
761
  fetchCrossBorrowRates(params?: {}): Promise<CrossBorrowRates>;
762
762
  fetchIsolatedBorrowRates(params?: {}): Promise<IsolatedBorrowRates>;
@@ -888,7 +888,7 @@ export default class Exchange {
888
888
  parseTrades(trades: any[], market?: Market, since?: Int, limit?: Int, params?: {}): Trade[];
889
889
  parseTransactions(transactions: any[], currency?: Currency, since?: Int, limit?: Int, params?: {}): Transaction[];
890
890
  parseTransfers(transfers: any[], currency?: Currency, since?: Int, limit?: Int, params?: {}): TransferEntry[];
891
- parseLedger(data: any, currency?: Currency, since?: Int, limit?: Int, params?: {}): any;
891
+ parseLedger(data: any, currency?: Currency, since?: Int, limit?: Int, params?: {}): LedgerEntry[];
892
892
  nonce(): number;
893
893
  setHeaders(headers: any): any;
894
894
  marketId(symbol: string): string;
@@ -7,7 +7,7 @@
7
7
  // ----------------------------------------------------------------------------
8
8
  /* eslint-disable */
9
9
  import * as functions from './functions.js';
10
- const { isNode, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep } = functions;
10
+ const { isNode, selfIsDefined, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep } = functions;
11
11
  import { keys as keysFunc, values as valuesFunc, vwap as vwapFunc } from './functions.js';
12
12
  // import exceptions from "./errors.js"
13
13
  import { // eslint-disable-line object-curly-newline
@@ -621,7 +621,7 @@ export default class Exchange {
621
621
  }
622
622
  }
623
623
  else {
624
- this.fetchImplementation = self.fetch;
624
+ this.fetchImplementation = (selfIsDefined()) ? self.fetch : fetch;
625
625
  this.AbortError = DOMException;
626
626
  this.FetchError = TypeError;
627
627
  }
@@ -5,4 +5,5 @@ declare const extractParams: (string: string) => string[];
5
5
  declare const implodeParams: (string: string, params: Dictionary<any> | any[]) => string;
6
6
  declare function vwap(baseVolume: number, quoteVolume: number): Num;
7
7
  declare function aggregate(bidasks: any): number[][];
8
- export { aggregate, parseTimeframe, roundTimeframe, implodeParams, extractParams, vwap, };
8
+ declare function selfIsDefined(): boolean;
9
+ export { aggregate, parseTimeframe, roundTimeframe, implodeParams, extractParams, vwap, selfIsDefined };
@@ -87,5 +87,15 @@ function aggregate(bidasks) {
87
87
  }
88
88
  return Object.keys(result).map((price) => [parseFloat(price), parseFloat(result[price])]); // TODO: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}', No index signature with a parameter of type 'string' was found on type '{}'.ts(7053)
89
89
  }
90
- export { aggregate, parseTimeframe, roundTimeframe, implodeParams, extractParams, vwap, };
90
+ function selfIsDefined() {
91
+ let selfIsDefined = false;
92
+ try {
93
+ selfIsDefined = self !== undefined;
94
+ }
95
+ catch (e) {
96
+ selfIsDefined = false;
97
+ }
98
+ return selfIsDefined;
99
+ }
100
+ export { aggregate, parseTimeframe, roundTimeframe, implodeParams, extractParams, vwap, selfIsDefined };
91
101
  /* ------------------------------------------------------------------------ */
@@ -324,8 +324,8 @@ export interface LeverageTier {
324
324
  info: any;
325
325
  }
326
326
  export interface LedgerEntry {
327
- id?: Str;
328
327
  info: any;
328
+ id?: Str;
329
329
  timestamp?: number;
330
330
  datetime?: Str;
331
331
  direction?: Str;
@@ -7,10 +7,10 @@
7
7
  // eslint-disable-next-line no-shadow
8
8
  import WebSocket from 'ws';
9
9
  import Client from './Client.js';
10
- import { sleep, isNode, milliseconds, } from '../../base/functions.js';
10
+ import { sleep, isNode, milliseconds, selfIsDefined, } from '../../base/functions.js';
11
11
  import { Future } from './Future.js';
12
12
  // eslint-disable-next-line no-restricted-globals
13
- const WebSocketPlatform = isNode ? WebSocket : self.WebSocket;
13
+ const WebSocketPlatform = isNode || !selfIsDefined() ? WebSocket : self.WebSocket;
14
14
  export default class WsClient extends Client {
15
15
  constructor() {
16
16
  super(...arguments);
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/binance.js';
2
- import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CrossBorrowRate, IsolatedBorrowRates, IsolatedBorrowRate, Dict, LeverageTier, LeverageTiers, int } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, Str, Transaction, Ticker, OrderBook, Tickers, Market, Greeks, Strings, Currency, MarketInterface, MarginMode, MarginModes, Leverage, Leverages, Num, Option, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CrossBorrowRate, IsolatedBorrowRates, IsolatedBorrowRate, Dict, LeverageTier, LeverageTiers, int, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class binance
5
5
  * @augments Exchange
@@ -246,25 +246,9 @@ export default class binance extends Exchange {
246
246
  datetime: string;
247
247
  };
248
248
  parseSettlements(settlements: any, market: any): any[];
249
- fetchLedgerEntry(id: string, code?: Str, params?: {}): Promise<any>;
250
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
251
- parseLedgerEntry(item: Dict, currency?: Currency): {
252
- id: string;
253
- direction: any;
254
- account: any;
255
- referenceAccount: any;
256
- referenceId: string;
257
- type: string;
258
- currency: string;
259
- amount: number;
260
- timestamp: number;
261
- datetime: string;
262
- before: any;
263
- after: any;
264
- status: any;
265
- fee: any;
266
- info: Dict;
267
- };
249
+ fetchLedgerEntry(id: string, code?: Str, params?: {}): Promise<LedgerEntry>;
250
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
251
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
268
252
  parseLedgerEntryType(type: any): string;
269
253
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
270
254
  url: any;
package/js/src/binance.js CHANGED
@@ -1202,6 +1202,7 @@ export default class binance extends Exchange {
1202
1202
  // exchange-specific options
1203
1203
  'options': {
1204
1204
  'sandboxMode': false,
1205
+ 'fetchMargins': true,
1205
1206
  'fetchMarkets': [
1206
1207
  'spot',
1207
1208
  'linear',
@@ -2875,13 +2876,12 @@ export default class binance extends Exchange {
2875
2876
  }
2876
2877
  fetchMarkets.push(type);
2877
2878
  }
2878
- let fetchMargins = false;
2879
+ const fetchMargins = this.safeBool(this.options, 'fetchMargins', false);
2879
2880
  for (let i = 0; i < fetchMarkets.length; i++) {
2880
2881
  const marketType = fetchMarkets[i];
2881
2882
  if (marketType === 'spot') {
2882
2883
  promisesRaw.push(this.publicGetExchangeInfo(params));
2883
- if (this.checkRequiredCredentials(false) && !sandboxMode) {
2884
- fetchMargins = true;
2884
+ if (fetchMargins && this.checkRequiredCredentials(false) && !sandboxMode) {
2885
2885
  promisesRaw.push(this.sapiGetMarginAllPairs(params));
2886
2886
  promisesRaw.push(this.sapiGetMarginIsolatedAllPairs(params));
2887
2887
  }
@@ -11222,17 +11222,42 @@ export default class binance extends Exchange {
11222
11222
  return result;
11223
11223
  }
11224
11224
  async fetchLedgerEntry(id, code = undefined, params = {}) {
11225
+ /**
11226
+ * @method
11227
+ * @name binance#fetchLedgerEntry
11228
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
11229
+ * @see https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
11230
+ * @param {string} id the identification number of the ledger entry
11231
+ * @param {string} code unified currency code
11232
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
11233
+ * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
11234
+ */
11225
11235
  await this.loadMarkets();
11226
11236
  let type = undefined;
11227
11237
  [type, params] = this.handleMarketTypeAndParams('fetchLedgerEntry', undefined, params);
11228
- const query = {
11229
- 'recordId': id,
11230
- 'type': type,
11231
- };
11232
11238
  if (type !== 'option') {
11233
- throw new BadRequest(this.id + ' fetchLedgerEntry () can only be used for type option');
11239
+ throw new BadRequest(this.id + ' fetchLedgerEntry() can only be used for type option');
11234
11240
  }
11235
- return await this.fetchLedger(code, undefined, undefined, this.extend(query, params));
11241
+ this.checkRequiredArgument('fetchLedgerEntry', code, 'code');
11242
+ const currency = this.currency(code);
11243
+ const request = {
11244
+ 'recordId': id,
11245
+ 'currency': currency['id'],
11246
+ };
11247
+ const response = await this.eapiPrivateGetBill(this.extend(request, params));
11248
+ //
11249
+ // [
11250
+ // {
11251
+ // "id": "1125899906845701870",
11252
+ // "asset": "USDT",
11253
+ // "amount": "-0.16518203",
11254
+ // "type": "FEE",
11255
+ // "createDate": 1676621042489
11256
+ // }
11257
+ // ]
11258
+ //
11259
+ const first = this.safeDict(response, 0, response);
11260
+ return this.parseLedgerEntry(first, currency);
11236
11261
  }
11237
11262
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
11238
11263
  /**
@@ -11244,9 +11269,9 @@ export default class binance extends Exchange {
11244
11269
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Get-Income-History
11245
11270
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
11246
11271
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History
11247
- * @param {string} code unified currency code
11272
+ * @param {string} [code] unified currency code
11248
11273
  * @param {int} [since] timestamp in ms of the earliest ledger entry
11249
- * @param {int} [limit] max number of ledger entrys to return
11274
+ * @param {int} [limit] max number of ledger entries to return
11250
11275
  * @param {object} [params] extra parameters specific to the exchange API endpoint
11251
11276
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
11252
11277
  * @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)
@@ -11372,16 +11397,19 @@ export default class binance extends Exchange {
11372
11397
  direction = 'in';
11373
11398
  }
11374
11399
  const currencyId = this.safeString(item, 'asset');
11400
+ const code = this.safeCurrencyCode(currencyId, currency);
11401
+ currency = this.safeCurrency(currencyId, currency);
11375
11402
  const timestamp = this.safeInteger2(item, 'createDate', 'time');
11376
11403
  const type = this.safeString2(item, 'type', 'incomeType');
11377
- return {
11404
+ return this.safeLedgerEntry({
11405
+ 'info': item,
11378
11406
  'id': this.safeString2(item, 'id', 'tranId'),
11379
11407
  'direction': direction,
11380
11408
  'account': undefined,
11381
11409
  'referenceAccount': undefined,
11382
11410
  'referenceId': this.safeString(item, 'tradeId'),
11383
11411
  'type': this.parseLedgerEntryType(type),
11384
- 'currency': this.safeCurrencyCode(currencyId, currency),
11412
+ 'currency': code,
11385
11413
  'amount': this.parseNumber(amount),
11386
11414
  'timestamp': timestamp,
11387
11415
  'datetime': this.iso8601(timestamp),
@@ -11389,8 +11417,7 @@ export default class binance extends Exchange {
11389
11417
  'after': undefined,
11390
11418
  'status': undefined,
11391
11419
  'fee': undefined,
11392
- 'info': item,
11393
- };
11420
+ }, currency);
11394
11421
  }
11395
11422
  parseLedgerEntryType(type) {
11396
11423
  const ledgerType = {
@@ -43,6 +43,7 @@ export default class binanceus extends binance {
43
43
  'options': {
44
44
  'fetchMarkets': ['spot'],
45
45
  'defaultType': 'spot',
46
+ 'fetchMargins': false,
46
47
  'quoteOrderQty': false,
47
48
  },
48
49
  'has': {
package/js/src/bingx.js CHANGED
@@ -468,6 +468,7 @@ export default class bingx extends Exchange {
468
468
  'commonCurrencies': {
469
469
  'SNOW': 'Snowman',
470
470
  'OMNI': 'OmniCat',
471
+ 'NAP': '$NAP', // NAP on SOL = SNAP
471
472
  },
472
473
  'options': {
473
474
  'defaultType': 'spot',
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitfinex2.js';
2
- import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderBook, Str, Transaction, Ticker, Balances, Tickers, Strings, Currency, Market, OpenInterest, Liquidation, OrderRequest, Num, MarginModification, Currencies, TradingFees, Dict } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderBook, Str, Transaction, Ticker, Balances, Tickers, Strings, Currency, Market, OpenInterest, Liquidation, OrderRequest, Num, MarginModification, Currencies, TradingFees, Dict, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class bitfinex2
5
5
  * @augments Exchange
@@ -79,24 +79,8 @@ export default class bitfinex2 extends Exchange {
79
79
  };
80
80
  handleErrors(statusCode: any, statusText: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
81
81
  parseLedgerEntryType(type: Str): string;
82
- parseLedgerEntry(item: Dict, currency?: Currency): {
83
- id: string;
84
- direction: any;
85
- account: any;
86
- referenceId: string;
87
- referenceAccount: any;
88
- type: any;
89
- currency: string;
90
- amount: number;
91
- timestamp: number;
92
- datetime: string;
93
- before: any;
94
- after: number;
95
- status: any;
96
- fee: any;
97
- info: Dict;
98
- };
99
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
82
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
83
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
100
84
  fetchFundingRate(symbol: string, params?: {}): Promise<any>;
101
85
  fetchFundingRates(symbols?: Strings, params?: {}): Promise<{}>;
102
86
  fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
@@ -2920,6 +2920,7 @@ export default class bitfinex2 extends Exchange {
2920
2920
  const id = this.safeString(itemList, 0);
2921
2921
  const currencyId = this.safeString(itemList, 1);
2922
2922
  const code = this.safeCurrencyCode(currencyId, currency);
2923
+ currency = this.safeCurrency(currencyId, currency);
2923
2924
  const timestamp = this.safeInteger(itemList, 3);
2924
2925
  const amount = this.safeNumber(itemList, 5);
2925
2926
  const after = this.safeNumber(itemList, 6);
@@ -2929,7 +2930,8 @@ export default class bitfinex2 extends Exchange {
2929
2930
  const first = this.safeStringLower(parts, 0);
2930
2931
  type = this.parseLedgerEntryType(first);
2931
2932
  }
2932
- return {
2933
+ return this.safeLedgerEntry({
2934
+ 'info': item,
2933
2935
  'id': id,
2934
2936
  'direction': undefined,
2935
2937
  'account': undefined,
@@ -2944,18 +2946,17 @@ export default class bitfinex2 extends Exchange {
2944
2946
  'after': after,
2945
2947
  'status': undefined,
2946
2948
  'fee': undefined,
2947
- 'info': item,
2948
- };
2949
+ }, currency);
2949
2950
  }
2950
2951
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
2951
2952
  /**
2952
2953
  * @method
2953
2954
  * @name bitfinex2#fetchLedger
2954
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2955
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2955
2956
  * @see https://docs.bitfinex.com/reference/rest-auth-ledgers
2956
- * @param {string} code unified currency code, default is undefined
2957
+ * @param {string} [code] unified currency code, default is undefined
2957
2958
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2958
- * @param {int} [limit] max number of ledger entrys to return, default is undefined max is 2500
2959
+ * @param {int} [limit] max number of ledger entries to return, default is undefined, max is 2500
2959
2960
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2960
2961
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
2961
2962
  * @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)