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
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitget.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CrossBorrowRate, IsolatedBorrowRate, Dict, LeverageTier, int } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion, CrossBorrowRate, IsolatedBorrowRate, Dict, LeverageTier, int, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class bitget
5
5
  * @augments Exchange
@@ -12,7 +12,6 @@ export default class bitget extends Exchange {
12
12
  fetchTime(params?: {}): Promise<number>;
13
13
  fetchMarkets(params?: {}): Promise<Market[]>;
14
14
  parseMarket(market: Dict): Market;
15
- fetchMarketsByType(type: any, params?: {}): Promise<import("./base/types.js").MarketInterface[]>;
16
15
  fetchCurrencies(params?: {}): Promise<Currencies>;
17
16
  fetchMarketLeverageTiers(symbol: string, params?: {}): Promise<LeverageTier[]>;
18
17
  parseMarketLeverageTiers(info: any, market?: Market): LeverageTier[];
@@ -70,24 +69,8 @@ export default class bitget extends Exchange {
70
69
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
71
70
  fetchCanceledOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
72
71
  fetchCanceledAndClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
73
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
74
- parseLedgerEntry(item: Dict, currency?: Currency): {
75
- info: Dict;
76
- id: string;
77
- timestamp: number;
78
- datetime: string;
79
- direction: string;
80
- account: any;
81
- referenceId: any;
82
- referenceAccount: any;
83
- type: string;
84
- currency: string;
85
- amount: number;
86
- before: any;
87
- after: number;
88
- status: any;
89
- fee: number;
90
- };
72
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
73
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
91
74
  parseLedgerType(type: any): string;
92
75
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
93
76
  fetchPosition(symbol: string, params?: {}): Promise<Position>;
package/js/src/bitget.js CHANGED
@@ -1536,6 +1536,7 @@ export default class bitget extends Exchange {
1536
1536
  * @description retrieves data on all markets for bitget
1537
1537
  * @see https://www.bitget.com/api-doc/spot/market/Get-Symbols
1538
1538
  * @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
1539
+ * @see https://www.bitget.com/api-doc/margin/common/support-currencies
1539
1540
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1540
1541
  * @returns {object[]} an array of objects representing market data
1541
1542
  */
@@ -1544,10 +1545,11 @@ export default class bitget extends Exchange {
1544
1545
  if (sandboxMode) {
1545
1546
  types = ['swap'];
1546
1547
  }
1547
- let promises = [];
1548
+ const promises = [];
1549
+ let fetchMargins = false;
1548
1550
  for (let i = 0; i < types.length; i++) {
1549
1551
  const type = types[i];
1550
- if (type === 'swap') {
1552
+ if ((type === 'swap') || (type === 'future')) {
1551
1553
  let subTypes = undefined;
1552
1554
  if (sandboxMode) {
1553
1555
  // the following are simulated trading markets [ 'SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES' ];
@@ -1557,19 +1559,41 @@ export default class bitget extends Exchange {
1557
1559
  subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES'];
1558
1560
  }
1559
1561
  for (let j = 0; j < subTypes.length; j++) {
1560
- promises.push(this.fetchMarketsByType(type, this.extend(params, {
1562
+ promises.push(this.publicMixGetV2MixMarketContracts(this.extend(params, {
1561
1563
  'productType': subTypes[j],
1562
1564
  })));
1563
1565
  }
1564
1566
  }
1567
+ else if (type === 'spot') {
1568
+ promises.push(this.publicSpotGetV2SpotPublicSymbols(params));
1569
+ fetchMargins = true;
1570
+ promises.push(this.publicMarginGetV2MarginCurrencies(params));
1571
+ }
1572
+ else {
1573
+ throw new NotSupported(this.id + ' does not support ' + type + ' market');
1574
+ }
1575
+ }
1576
+ const results = await Promise.all(promises);
1577
+ let markets = [];
1578
+ this.options['crossMarginPairsData'] = [];
1579
+ this.options['isolatedMarginPairsData'] = [];
1580
+ for (let i = 0; i < results.length; i++) {
1581
+ const res = this.safeDict(results, i);
1582
+ const data = this.safeList(res, 'data', []);
1583
+ const firstData = this.safeDict(data, 0, {});
1584
+ const isBorrowable = this.safeString(firstData, 'isBorrowable');
1585
+ if (fetchMargins && isBorrowable !== undefined) {
1586
+ const keysList = Object.keys(this.indexBy(data, 'symbol'));
1587
+ this.options['crossMarginPairsData'] = keysList;
1588
+ this.options['isolatedMarginPairsData'] = keysList;
1589
+ }
1565
1590
  else {
1566
- promises.push(this.fetchMarketsByType(types[i], params));
1591
+ markets = this.arrayConcat(markets, data);
1567
1592
  }
1568
1593
  }
1569
- promises = await Promise.all(promises);
1570
- let result = promises[0];
1571
- for (let i = 1; i < promises.length; i++) {
1572
- result = this.arrayConcat(result, promises[i]);
1594
+ const result = [];
1595
+ for (let i = 0; i < markets.length; i++) {
1596
+ result.push(this.parseMarket(markets[i]));
1573
1597
  }
1574
1598
  return result;
1575
1599
  }
@@ -1661,11 +1685,20 @@ export default class bitget extends Exchange {
1661
1685
  let expiry = undefined;
1662
1686
  let expiryDatetime = undefined;
1663
1687
  const symbolType = this.safeString(market, 'symbolType');
1688
+ let marginModes = undefined;
1689
+ let isMarginTradingAllowed = false;
1664
1690
  if (symbolType === undefined) {
1665
1691
  type = 'spot';
1666
1692
  spot = true;
1667
1693
  pricePrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision')));
1668
1694
  amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityPrecision')));
1695
+ const hasCrossMargin = this.inArray(marketId, this.options['crossMarginPairsData']);
1696
+ const hasIsolatedMargin = this.inArray(marketId, this.options['isolatedMarginPairsData']);
1697
+ marginModes = {
1698
+ 'cross': hasCrossMargin,
1699
+ 'isolated': hasIsolatedMargin,
1700
+ };
1701
+ isMarginTradingAllowed = hasCrossMargin || hasCrossMargin;
1669
1702
  }
1670
1703
  else {
1671
1704
  if (symbolType === 'perpetual') {
@@ -1704,6 +1737,10 @@ export default class bitget extends Exchange {
1704
1737
  preciseAmount.reduce();
1705
1738
  const amountString = preciseAmount.toString();
1706
1739
  amountPrecision = this.parseNumber(amountString);
1740
+ marginModes = {
1741
+ 'cross': true,
1742
+ 'isolated': true,
1743
+ };
1707
1744
  }
1708
1745
  const status = this.safeString2(market, 'status', 'symbolStatus');
1709
1746
  let active = undefined;
@@ -1726,7 +1763,8 @@ export default class bitget extends Exchange {
1726
1763
  'settleId': settleId,
1727
1764
  'type': type,
1728
1765
  'spot': spot,
1729
- 'margin': undefined,
1766
+ 'margin': spot && isMarginTradingAllowed,
1767
+ 'marginModes': marginModes,
1730
1768
  'swap': swap,
1731
1769
  'future': future,
1732
1770
  'option': false,
@@ -1767,91 +1805,6 @@ export default class bitget extends Exchange {
1767
1805
  'info': market,
1768
1806
  };
1769
1807
  }
1770
- async fetchMarketsByType(type, params = {}) {
1771
- let response = undefined;
1772
- if (type === 'spot') {
1773
- response = await this.publicSpotGetV2SpotPublicSymbols(params);
1774
- }
1775
- else if ((type === 'swap') || (type === 'future')) {
1776
- response = await this.publicMixGetV2MixMarketContracts(params);
1777
- }
1778
- else {
1779
- throw new NotSupported(this.id + ' does not support ' + type + ' market');
1780
- }
1781
- //
1782
- // spot
1783
- //
1784
- // {
1785
- // "code": "00000",
1786
- // "msg": "success",
1787
- // "requestTime": 1700102364653,
1788
- // "data": [
1789
- // {
1790
- // "symbol": "TRXUSDT",
1791
- // "baseCoin": "TRX",
1792
- // "quoteCoin": "USDT",
1793
- // "minTradeAmount": "0",
1794
- // "maxTradeAmount": "10000000000",
1795
- // "takerFeeRate": "0.002",
1796
- // "makerFeeRate": "0.002",
1797
- // "pricePrecision": "6",
1798
- // "quantityPrecision": "4",
1799
- // "quotePrecision": "6",
1800
- // "status": "online",
1801
- // "minTradeUSDT": "5",
1802
- // "buyLimitPriceRatio": "0.05",
1803
- // "sellLimitPriceRatio": "0.05"
1804
- // },
1805
- // ]
1806
- // }
1807
- //
1808
- // swap and future
1809
- //
1810
- // {
1811
- // "code": "00000",
1812
- // "msg": "success",
1813
- // "requestTime": 1700102364709,
1814
- // "data": [
1815
- // {
1816
- // "symbol": "BTCUSDT",
1817
- // "baseCoin": "BTC",
1818
- // "quoteCoin": "USDT",
1819
- // "buyLimitPriceRatio": "0.01",
1820
- // "sellLimitPriceRatio": "0.01",
1821
- // "feeRateUpRatio": "0.005",
1822
- // "makerFeeRate": "0.0002",
1823
- // "takerFeeRate": "0.0006",
1824
- // "openCostUpRatio": "0.01",
1825
- // "supportMarginCoins": ["USDT"],
1826
- // "minTradeNum": "0.001",
1827
- // "priceEndStep": "1",
1828
- // "volumePlace": "3",
1829
- // "pricePlace": "1",
1830
- // "sizeMultiplier": "0.001",
1831
- // "symbolType": "perpetual",
1832
- // "minTradeUSDT": "5",
1833
- // "maxSymbolOrderNum": "200",
1834
- // "maxProductOrderNum": "400",
1835
- // "maxPositionNum": "150",
1836
- // "symbolStatus": "normal",
1837
- // "offTime": "-1",
1838
- // "limitOpenTime": "-1",
1839
- // "deliveryTime": "",
1840
- // "deliveryStartTime": "",
1841
- // "deliveryPeriod": "",
1842
- // "launchTime": "",
1843
- // "fundInterval": "8",
1844
- // "minLever": "1",
1845
- // "maxLever": "125",
1846
- // "posLimit": "0.05",
1847
- // "maintainTime": ""
1848
- // },
1849
- // ]
1850
- // }
1851
- //
1852
- const data = this.safeValue(response, 'data', []);
1853
- return this.parseMarkets(data);
1854
- }
1855
1808
  async fetchCurrencies(params = {}) {
1856
1809
  /**
1857
1810
  * @method
@@ -5904,12 +5857,12 @@ export default class bitget extends Exchange {
5904
5857
  /**
5905
5858
  * @method
5906
5859
  * @name bitget#fetchLedger
5860
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
5907
5861
  * @see https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
5908
5862
  * @see https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
5909
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
5910
- * @param {string} code unified currency code, default is undefined
5863
+ * @param {string} [code] unified currency code, default is undefined
5911
5864
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
5912
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
5865
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
5913
5866
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5914
5867
  * @param {int} [params.until] end time in ms
5915
5868
  * @param {string} [params.symbol] *contract only* unified market symbol
@@ -6049,6 +6002,7 @@ export default class bitget extends Exchange {
6049
6002
  //
6050
6003
  const currencyId = this.safeString(item, 'coin');
6051
6004
  const code = this.safeCurrencyCode(currencyId, currency);
6005
+ currency = this.safeCurrency(currencyId, currency);
6052
6006
  const timestamp = this.safeInteger(item, 'cTime');
6053
6007
  const after = this.safeNumber(item, 'balance');
6054
6008
  const fee = this.safeNumber2(item, 'fees', 'fee');
@@ -6058,7 +6012,7 @@ export default class bitget extends Exchange {
6058
6012
  if (amountRaw.indexOf('-') >= 0) {
6059
6013
  direction = 'out';
6060
6014
  }
6061
- return {
6015
+ return this.safeLedgerEntry({
6062
6016
  'info': item,
6063
6017
  'id': this.safeString(item, 'billId'),
6064
6018
  'timestamp': timestamp,
@@ -6073,8 +6027,11 @@ export default class bitget extends Exchange {
6073
6027
  'before': undefined,
6074
6028
  'after': after,
6075
6029
  'status': undefined,
6076
- 'fee': fee,
6077
- };
6030
+ 'fee': {
6031
+ 'currency': code,
6032
+ 'cost': fee,
6033
+ },
6034
+ }, currency);
6078
6035
  }
6079
6036
  parseLedgerType(type) {
6080
6037
  const types = {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitmex.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, Liquidation, OrderBook, Balances, Str, Dict, Transaction, Ticker, Tickers, Market, Strings, Currency, Leverage, Leverages, Num, Currencies, int } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, Liquidation, OrderBook, Balances, Str, Dict, Transaction, Ticker, Tickers, Market, Strings, Currency, Leverage, Leverages, Num, Currencies, int, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class bitmex
5
5
  * @augments Exchange
@@ -23,27 +23,8 @@ export default class bitmex extends Exchange {
23
23
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
24
24
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
25
25
  parseLedgerEntryType(type: any): string;
26
- parseLedgerEntry(item: Dict, currency?: Currency): {
27
- id: string;
28
- info: Dict;
29
- timestamp: number;
30
- datetime: string;
31
- direction: any;
32
- account: string;
33
- referenceId: string;
34
- referenceAccount: any;
35
- type: string;
36
- currency: string;
37
- amount: string;
38
- before: number;
39
- after: number;
40
- status: string;
41
- fee: {
42
- cost: number;
43
- currency: string;
44
- };
45
- };
46
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
26
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
27
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
47
28
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
48
29
  parseTransactionStatus(status: Str): string;
49
30
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
package/js/src/bitmex.js CHANGED
@@ -1146,6 +1146,7 @@ export default class bitmex extends Exchange {
1146
1146
  const type = this.parseLedgerEntryType(this.safeString(item, 'transactType'));
1147
1147
  const currencyId = this.safeString(item, 'currency');
1148
1148
  const code = this.safeCurrencyCode(currencyId, currency);
1149
+ currency = this.safeCurrency(currencyId, currency);
1149
1150
  const amountString = this.safeString(item, 'amount');
1150
1151
  let amount = this.convertToRealAmount(code, amountString);
1151
1152
  let timestamp = this.parse8601(this.safeString(item, 'transactTime'));
@@ -1160,14 +1161,14 @@ export default class bitmex extends Exchange {
1160
1161
  feeCost = this.convertToRealAmount(code, feeCost);
1161
1162
  }
1162
1163
  const fee = {
1163
- 'cost': this.parseNumber(feeCost),
1164
+ 'cost': this.parseToNumeric(feeCost),
1164
1165
  'currency': code,
1165
1166
  };
1166
1167
  let after = this.safeString(item, 'walletBalance');
1167
1168
  if (after !== undefined) {
1168
1169
  after = this.convertToRealAmount(code, after);
1169
1170
  }
1170
- const before = this.parseNumber(Precise.stringSub(this.numberToString(after), this.numberToString(amount)));
1171
+ const before = this.parseToNumeric(Precise.stringSub(this.numberToString(after), this.numberToString(amount)));
1171
1172
  let direction = undefined;
1172
1173
  if (Precise.stringLt(amountString, '0')) {
1173
1174
  direction = 'out';
@@ -1177,9 +1178,9 @@ export default class bitmex extends Exchange {
1177
1178
  direction = 'in';
1178
1179
  }
1179
1180
  const status = this.parseTransactionStatus(this.safeString(item, 'transactStatus'));
1180
- return {
1181
- 'id': id,
1181
+ return this.safeLedgerEntry({
1182
1182
  'info': item,
1183
+ 'id': id,
1183
1184
  'timestamp': timestamp,
1184
1185
  'datetime': this.iso8601(timestamp),
1185
1186
  'direction': direction,
@@ -1188,22 +1189,22 @@ export default class bitmex extends Exchange {
1188
1189
  'referenceAccount': referenceAccount,
1189
1190
  'type': type,
1190
1191
  'currency': code,
1191
- 'amount': amount,
1192
+ 'amount': this.parseToNumeric(amount),
1192
1193
  'before': before,
1193
- 'after': this.parseNumber(after),
1194
+ 'after': this.parseToNumeric(after),
1194
1195
  'status': status,
1195
1196
  'fee': fee,
1196
- };
1197
+ }, currency);
1197
1198
  }
1198
1199
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1199
1200
  /**
1200
1201
  * @method
1201
1202
  * @name bitmex#fetchLedger
1202
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1203
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
1203
1204
  * @see https://www.bitmex.com/api/explorer/#!/User/User_getWalletHistory
1204
- * @param {string} code unified currency code, default is undefined
1205
+ * @param {string} [code] unified currency code, default is undefined
1205
1206
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1206
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1207
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
1207
1208
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1208
1209
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1209
1210
  */
package/js/src/bitso.d.ts CHANGED
@@ -1,30 +1,14 @@
1
1
  import Exchange from './abstract/bitso.js';
2
- import type { Balances, Currency, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Trade, TradingFees, Transaction, int } from './base/types.js';
2
+ import type { Balances, Currency, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Trade, TradingFees, Transaction, int, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class bitso
5
5
  * @augments Exchange
6
6
  */
7
7
  export default class bitso extends Exchange {
8
8
  describe(): any;
9
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
9
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
10
10
  parseLedgerEntryType(type: any): string;
11
- parseLedgerEntry(item: Dict, currency?: Currency): {
12
- id: string;
13
- timestamp: number;
14
- datetime: string;
15
- direction: string;
16
- account: string;
17
- referenceId: string;
18
- referenceAccount: string;
19
- type: string;
20
- currency: string;
21
- amount: number;
22
- before: number;
23
- after: number;
24
- status: string;
25
- fee: any;
26
- info: import("./base/types.js").Dictionary<any>;
27
- };
11
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
28
12
  fetchMarkets(params?: {}): Promise<Market[]>;
29
13
  parseBalance(response: any): Balances;
30
14
  fetchBalance(params?: {}): Promise<Balances>;
package/js/src/bitso.js CHANGED
@@ -194,10 +194,10 @@ export default class bitso extends Exchange {
194
194
  /**
195
195
  * @method
196
196
  * @name bitso#fetchLedger
197
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
198
- * @param {string} code unified currency code, default is undefined
197
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
198
+ * @param {string} [code] unified currency code, default is undefined
199
199
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
200
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
200
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
201
201
  * @param {object} [params] extra parameters specific to the exchange API endpoint
202
202
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
203
203
  */
@@ -306,6 +306,7 @@ export default class bitso extends Exchange {
306
306
  const amount = this.safeString(firstBalance, 'amount');
307
307
  const currencyId = this.safeString(firstBalance, 'currency');
308
308
  const code = this.safeCurrencyCode(currencyId, currency);
309
+ currency = this.safeCurrency(currencyId, currency);
309
310
  const details = this.safeValue(item, 'details', {});
310
311
  let referenceId = this.safeString2(details, 'fid', 'wid');
311
312
  if (referenceId === undefined) {
@@ -330,6 +331,7 @@ export default class bitso extends Exchange {
330
331
  }
331
332
  const timestamp = this.parse8601(this.safeString(item, 'created_at'));
332
333
  return this.safeLedgerEntry({
334
+ 'info': item,
333
335
  'id': this.safeString(item, 'eid'),
334
336
  'direction': direction,
335
337
  'account': undefined,
@@ -344,7 +346,6 @@ export default class bitso extends Exchange {
344
346
  'after': undefined,
345
347
  'status': 'ok',
346
348
  'fee': fee,
347
- 'info': item,
348
349
  }, currency);
349
350
  }
350
351
  async fetchMarkets(params = {}) {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitstamp.js';
2
- import type { Balances, Currencies, Currency, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, int } from './base/types.js';
2
+ import type { Balances, Currencies, Currency, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, int, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class bitstamp
5
5
  * @augments Exchange
@@ -73,40 +73,8 @@ export default class bitstamp extends Exchange {
73
73
  parseTransactionStatus(status: Str): string;
74
74
  parseOrder(order: Dict, market?: Market): Order;
75
75
  parseLedgerEntryType(type: any): string;
76
- parseLedgerEntry(item: Dict, currency?: Currency): {
77
- id: string;
78
- info: Dict;
79
- timestamp: number;
80
- datetime: string;
81
- direction: string;
82
- account: any;
83
- referenceId: string;
84
- referenceAccount: any;
85
- type: string;
86
- currency: any;
87
- amount: number;
88
- before: any;
89
- after: any;
90
- status: string;
91
- fee: import("./base/types.js").FeeInterface;
92
- } | {
93
- id: string;
94
- info: Dict;
95
- timestamp: number;
96
- datetime: string;
97
- direction: any;
98
- account: any;
99
- referenceId: string;
100
- referenceAccount: any;
101
- type: string;
102
- currency: string;
103
- amount: number;
104
- before: any;
105
- after: any;
106
- status: string;
107
- fee: import("./base/types.js").FeeInterface;
108
- };
109
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
76
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
77
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
110
78
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
111
79
  getCurrencyName(code: any): any;
112
80
  isFiat(code: any): boolean;
@@ -1981,9 +1981,9 @@ export default class bitstamp extends Exchange {
1981
1981
  market = this.getMarketFromTrade(item);
1982
1982
  }
1983
1983
  const direction = (parsedTrade['side'] === 'buy') ? 'in' : 'out';
1984
- return {
1985
- 'id': parsedTrade['id'],
1984
+ return this.safeLedgerEntry({
1986
1985
  'info': item,
1986
+ 'id': parsedTrade['id'],
1987
1987
  'timestamp': parsedTrade['timestamp'],
1988
1988
  'datetime': parsedTrade['datetime'],
1989
1989
  'direction': direction,
@@ -1997,7 +1997,7 @@ export default class bitstamp extends Exchange {
1997
1997
  'after': undefined,
1998
1998
  'status': 'ok',
1999
1999
  'fee': parsedTrade['fee'],
2000
- };
2000
+ }, currency);
2001
2001
  }
2002
2002
  else {
2003
2003
  const parsedTransaction = this.parseTransaction(item, currency);
@@ -2012,9 +2012,9 @@ export default class bitstamp extends Exchange {
2012
2012
  const amount = this.safeString(item, currency['id']);
2013
2013
  direction = Precise.stringGt(amount, '0') ? 'in' : 'out';
2014
2014
  }
2015
- return {
2016
- 'id': parsedTransaction['id'],
2015
+ return this.safeLedgerEntry({
2017
2016
  'info': item,
2017
+ 'id': parsedTransaction['id'],
2018
2018
  'timestamp': parsedTransaction['timestamp'],
2019
2019
  'datetime': parsedTransaction['datetime'],
2020
2020
  'direction': direction,
@@ -2028,18 +2028,18 @@ export default class bitstamp extends Exchange {
2028
2028
  'after': undefined,
2029
2029
  'status': parsedTransaction['status'],
2030
2030
  'fee': parsedTransaction['fee'],
2031
- };
2031
+ }, currency);
2032
2032
  }
2033
2033
  }
2034
2034
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
2035
2035
  /**
2036
2036
  * @method
2037
2037
  * @name bitstamp#fetchLedger
2038
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
2038
+ * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
2039
2039
  * @see https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactions
2040
- * @param {string} code unified currency code, default is undefined
2040
+ * @param {string} [code] unified currency code, default is undefined
2041
2041
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2042
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
2042
+ * @param {int} [limit] max number of ledger entries to return, default is undefined
2043
2043
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2044
2044
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
2045
2045
  */
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/blofin.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage, Leverages, MarginMode, Num, TradingFeeInterface, Dict, int } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage, Leverages, MarginMode, Num, TradingFeeInterface, Dict, int, LedgerEntry } from './base/types.js';
3
3
  /**
4
4
  * @class blofin
5
5
  * @augments Exchange
@@ -71,23 +71,11 @@ export default class blofin extends Exchange {
71
71
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
72
72
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
73
73
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
74
- fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
74
+ fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
75
75
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
76
76
  parseTransactionStatus(status: Str): string;
77
77
  parseLedgerEntryType(type: any): string;
78
- parseLedgerEntry(item: Dict, currency?: Currency): {
79
- id: string;
80
- info: Dict;
81
- timestamp: number;
82
- datetime: string;
83
- fromAccount: string;
84
- toAccount: string;
85
- type: string;
86
- currency: string;
87
- amount: number;
88
- clientId: string;
89
- status: string;
90
- };
78
+ parseLedgerEntry(item: Dict, currency?: Currency): LedgerEntry;
91
79
  parseIds(ids: any): any;
92
80
  cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
93
81
  transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;