ccxt 4.4.4 → 4.4.6

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 (48) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/binance.js +3 -3
  5. package/dist/cjs/src/binanceus.js +1 -0
  6. package/dist/cjs/src/bitflyer.js +2 -2
  7. package/dist/cjs/src/bitget.js +56 -95
  8. package/dist/cjs/src/bitmart.js +186 -127
  9. package/dist/cjs/src/bybit.js +90 -7
  10. package/dist/cjs/src/coinbase.js +6 -8
  11. package/dist/cjs/src/kraken.js +6 -1
  12. package/dist/cjs/src/lykke.js +2 -2
  13. package/dist/cjs/src/mexc.js +37 -7
  14. package/dist/cjs/src/paradex.js +1 -1
  15. package/dist/cjs/src/pro/binance.js +6 -2
  16. package/dist/cjs/src/pro/binanceus.js +2 -1
  17. package/dist/cjs/src/pro/htx.js +14 -0
  18. package/dist/cjs/src/pro/hyperliquid.js +16 -1
  19. package/dist/cjs/src/pro/kraken.js +60 -0
  20. package/dist/cjs/src/pro/paradex.js +1 -0
  21. package/js/ccxt.d.ts +1 -1
  22. package/js/ccxt.js +1 -1
  23. package/js/src/abstract/bitmart.d.ts +4 -0
  24. package/js/src/binance.js +3 -3
  25. package/js/src/binanceus.js +1 -0
  26. package/js/src/bitflyer.js +2 -2
  27. package/js/src/bitget.d.ts +1 -1
  28. package/js/src/bitget.js +56 -95
  29. package/js/src/bitmart.js +186 -127
  30. package/js/src/bybit.js +90 -7
  31. package/js/src/coinbase.js +6 -8
  32. package/js/src/kraken.js +6 -1
  33. package/js/src/lykke.js +2 -2
  34. package/js/src/mexc.d.ts +1 -0
  35. package/js/src/mexc.js +37 -7
  36. package/js/src/paradex.js +1 -1
  37. package/js/src/pro/binance.d.ts +140 -0
  38. package/js/src/pro/binance.js +6 -2
  39. package/js/src/pro/binanceus.js +2 -1
  40. package/js/src/pro/htx.js +14 -0
  41. package/js/src/pro/hyperliquid.d.ts +1 -0
  42. package/js/src/pro/hyperliquid.js +16 -1
  43. package/js/src/pro/kraken.d.ts +3 -0
  44. package/js/src/pro/kraken.js +60 -0
  45. package/js/src/pro/paradex.js +1 -0
  46. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  47. package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
  48. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -194,7 +194,7 @@ var xt$1 = require('./src/pro/xt.js');
194
194
 
195
195
  //-----------------------------------------------------------------------------
196
196
  // this is updated by vss.js when building
197
- const version = '4.4.4';
197
+ const version = '4.4.6';
198
198
  Exchange["default"].ccxtVersion = version;
199
199
  const exchanges = {
200
200
  'ace': ace,
@@ -1199,6 +1199,7 @@ class binance extends binance$1 {
1199
1199
  // exchange-specific options
1200
1200
  'options': {
1201
1201
  'sandboxMode': false,
1202
+ 'fetchMargins': true,
1202
1203
  'fetchMarkets': [
1203
1204
  'spot',
1204
1205
  'linear',
@@ -2872,13 +2873,12 @@ class binance extends binance$1 {
2872
2873
  }
2873
2874
  fetchMarkets.push(type);
2874
2875
  }
2875
- let fetchMargins = false;
2876
+ const fetchMargins = this.safeBool(this.options, 'fetchMargins', false);
2876
2877
  for (let i = 0; i < fetchMarkets.length; i++) {
2877
2878
  const marketType = fetchMarkets[i];
2878
2879
  if (marketType === 'spot') {
2879
2880
  promisesRaw.push(this.publicGetExchangeInfo(params));
2880
- if (this.checkRequiredCredentials(false) && !sandboxMode) {
2881
- fetchMargins = true;
2881
+ if (fetchMargins && this.checkRequiredCredentials(false) && !sandboxMode) {
2882
2882
  promisesRaw.push(this.sapiGetMarginAllPairs(params));
2883
2883
  promisesRaw.push(this.sapiGetMarginIsolatedAllPairs(params));
2884
2884
  }
@@ -40,6 +40,7 @@ class binanceus extends binance {
40
40
  'options': {
41
41
  'fetchMarkets': ['spot'],
42
42
  'defaultType': 'spot',
43
+ 'fetchMargins': false,
43
44
  'quoteOrderQty': false,
44
45
  },
45
46
  'has': {
@@ -1062,10 +1062,10 @@ class bitflyer extends bitflyer$1 {
1062
1062
  const feedback = this.id + ' ' + body;
1063
1063
  // i.e. {"status":-2,"error_message":"Under maintenance","data":null}
1064
1064
  const errorMessage = this.safeString(response, 'error_message');
1065
- const statusCode = this.safeNumber(response, 'status');
1065
+ const statusCode = this.safeInteger(response, 'status');
1066
1066
  if (errorMessage !== undefined) {
1067
1067
  this.throwExactlyMatchedException(this.exceptions['exact'], statusCode, feedback);
1068
- this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
1068
+ throw new errors.ExchangeError(feedback);
1069
1069
  }
1070
1070
  return undefined;
1071
1071
  }
@@ -1315,6 +1315,8 @@ class bitget extends bitget$1 {
1315
1315
  'TONCOIN': 'TON',
1316
1316
  },
1317
1317
  'options': {
1318
+ 'timeDifference': 0,
1319
+ 'adjustForTimeDifference': false,
1318
1320
  'timeframes': {
1319
1321
  'spot': {
1320
1322
  '1m': '1min',
@@ -1533,18 +1535,23 @@ class bitget extends bitget$1 {
1533
1535
  * @description retrieves data on all markets for bitget
1534
1536
  * @see https://www.bitget.com/api-doc/spot/market/Get-Symbols
1535
1537
  * @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
1538
+ * @see https://www.bitget.com/api-doc/margin/common/support-currencies
1536
1539
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1537
1540
  * @returns {object[]} an array of objects representing market data
1538
1541
  */
1542
+ if (this.options['adjustForTimeDifference']) {
1543
+ await this.loadTimeDifference();
1544
+ }
1539
1545
  const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1540
1546
  let types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
1541
1547
  if (sandboxMode) {
1542
1548
  types = ['swap'];
1543
1549
  }
1544
- let promises = [];
1550
+ const promises = [];
1551
+ let fetchMargins = false;
1545
1552
  for (let i = 0; i < types.length; i++) {
1546
1553
  const type = types[i];
1547
- if (type === 'swap') {
1554
+ if ((type === 'swap') || (type === 'future')) {
1548
1555
  let subTypes = undefined;
1549
1556
  if (sandboxMode) {
1550
1557
  // the following are simulated trading markets [ 'SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES' ];
@@ -1554,19 +1561,41 @@ class bitget extends bitget$1 {
1554
1561
  subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES'];
1555
1562
  }
1556
1563
  for (let j = 0; j < subTypes.length; j++) {
1557
- promises.push(this.fetchMarketsByType(type, this.extend(params, {
1564
+ promises.push(this.publicMixGetV2MixMarketContracts(this.extend(params, {
1558
1565
  'productType': subTypes[j],
1559
1566
  })));
1560
1567
  }
1561
1568
  }
1569
+ else if (type === 'spot') {
1570
+ promises.push(this.publicSpotGetV2SpotPublicSymbols(params));
1571
+ fetchMargins = true;
1572
+ promises.push(this.publicMarginGetV2MarginCurrencies(params));
1573
+ }
1562
1574
  else {
1563
- promises.push(this.fetchMarketsByType(types[i], params));
1575
+ throw new errors.NotSupported(this.id + ' does not support ' + type + ' market');
1576
+ }
1577
+ }
1578
+ const results = await Promise.all(promises);
1579
+ let markets = [];
1580
+ this.options['crossMarginPairsData'] = [];
1581
+ this.options['isolatedMarginPairsData'] = [];
1582
+ for (let i = 0; i < results.length; i++) {
1583
+ const res = this.safeDict(results, i);
1584
+ const data = this.safeList(res, 'data', []);
1585
+ const firstData = this.safeDict(data, 0, {});
1586
+ const isBorrowable = this.safeString(firstData, 'isBorrowable');
1587
+ if (fetchMargins && isBorrowable !== undefined) {
1588
+ const keysList = Object.keys(this.indexBy(data, 'symbol'));
1589
+ this.options['crossMarginPairsData'] = keysList;
1590
+ this.options['isolatedMarginPairsData'] = keysList;
1591
+ }
1592
+ else {
1593
+ markets = this.arrayConcat(markets, data);
1564
1594
  }
1565
1595
  }
1566
- promises = await Promise.all(promises);
1567
- let result = promises[0];
1568
- for (let i = 1; i < promises.length; i++) {
1569
- result = this.arrayConcat(result, promises[i]);
1596
+ const result = [];
1597
+ for (let i = 0; i < markets.length; i++) {
1598
+ result.push(this.parseMarket(markets[i]));
1570
1599
  }
1571
1600
  return result;
1572
1601
  }
@@ -1658,11 +1687,20 @@ class bitget extends bitget$1 {
1658
1687
  let expiry = undefined;
1659
1688
  let expiryDatetime = undefined;
1660
1689
  const symbolType = this.safeString(market, 'symbolType');
1690
+ let marginModes = undefined;
1691
+ let isMarginTradingAllowed = false;
1661
1692
  if (symbolType === undefined) {
1662
1693
  type = 'spot';
1663
1694
  spot = true;
1664
1695
  pricePrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision')));
1665
1696
  amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityPrecision')));
1697
+ const hasCrossMargin = this.inArray(marketId, this.options['crossMarginPairsData']);
1698
+ const hasIsolatedMargin = this.inArray(marketId, this.options['isolatedMarginPairsData']);
1699
+ marginModes = {
1700
+ 'cross': hasCrossMargin,
1701
+ 'isolated': hasIsolatedMargin,
1702
+ };
1703
+ isMarginTradingAllowed = hasCrossMargin || hasCrossMargin;
1666
1704
  }
1667
1705
  else {
1668
1706
  if (symbolType === 'perpetual') {
@@ -1701,6 +1739,10 @@ class bitget extends bitget$1 {
1701
1739
  preciseAmount.reduce();
1702
1740
  const amountString = preciseAmount.toString();
1703
1741
  amountPrecision = this.parseNumber(amountString);
1742
+ marginModes = {
1743
+ 'cross': true,
1744
+ 'isolated': true,
1745
+ };
1704
1746
  }
1705
1747
  const status = this.safeString2(market, 'status', 'symbolStatus');
1706
1748
  let active = undefined;
@@ -1723,7 +1765,8 @@ class bitget extends bitget$1 {
1723
1765
  'settleId': settleId,
1724
1766
  'type': type,
1725
1767
  'spot': spot,
1726
- 'margin': undefined,
1768
+ 'margin': spot && isMarginTradingAllowed,
1769
+ 'marginModes': marginModes,
1727
1770
  'swap': swap,
1728
1771
  'future': future,
1729
1772
  'option': false,
@@ -1764,91 +1807,6 @@ class bitget extends bitget$1 {
1764
1807
  'info': market,
1765
1808
  };
1766
1809
  }
1767
- async fetchMarketsByType(type, params = {}) {
1768
- let response = undefined;
1769
- if (type === 'spot') {
1770
- response = await this.publicSpotGetV2SpotPublicSymbols(params);
1771
- }
1772
- else if ((type === 'swap') || (type === 'future')) {
1773
- response = await this.publicMixGetV2MixMarketContracts(params);
1774
- }
1775
- else {
1776
- throw new errors.NotSupported(this.id + ' does not support ' + type + ' market');
1777
- }
1778
- //
1779
- // spot
1780
- //
1781
- // {
1782
- // "code": "00000",
1783
- // "msg": "success",
1784
- // "requestTime": 1700102364653,
1785
- // "data": [
1786
- // {
1787
- // "symbol": "TRXUSDT",
1788
- // "baseCoin": "TRX",
1789
- // "quoteCoin": "USDT",
1790
- // "minTradeAmount": "0",
1791
- // "maxTradeAmount": "10000000000",
1792
- // "takerFeeRate": "0.002",
1793
- // "makerFeeRate": "0.002",
1794
- // "pricePrecision": "6",
1795
- // "quantityPrecision": "4",
1796
- // "quotePrecision": "6",
1797
- // "status": "online",
1798
- // "minTradeUSDT": "5",
1799
- // "buyLimitPriceRatio": "0.05",
1800
- // "sellLimitPriceRatio": "0.05"
1801
- // },
1802
- // ]
1803
- // }
1804
- //
1805
- // swap and future
1806
- //
1807
- // {
1808
- // "code": "00000",
1809
- // "msg": "success",
1810
- // "requestTime": 1700102364709,
1811
- // "data": [
1812
- // {
1813
- // "symbol": "BTCUSDT",
1814
- // "baseCoin": "BTC",
1815
- // "quoteCoin": "USDT",
1816
- // "buyLimitPriceRatio": "0.01",
1817
- // "sellLimitPriceRatio": "0.01",
1818
- // "feeRateUpRatio": "0.005",
1819
- // "makerFeeRate": "0.0002",
1820
- // "takerFeeRate": "0.0006",
1821
- // "openCostUpRatio": "0.01",
1822
- // "supportMarginCoins": ["USDT"],
1823
- // "minTradeNum": "0.001",
1824
- // "priceEndStep": "1",
1825
- // "volumePlace": "3",
1826
- // "pricePlace": "1",
1827
- // "sizeMultiplier": "0.001",
1828
- // "symbolType": "perpetual",
1829
- // "minTradeUSDT": "5",
1830
- // "maxSymbolOrderNum": "200",
1831
- // "maxProductOrderNum": "400",
1832
- // "maxPositionNum": "150",
1833
- // "symbolStatus": "normal",
1834
- // "offTime": "-1",
1835
- // "limitOpenTime": "-1",
1836
- // "deliveryTime": "",
1837
- // "deliveryStartTime": "",
1838
- // "deliveryPeriod": "",
1839
- // "launchTime": "",
1840
- // "fundInterval": "8",
1841
- // "minLever": "1",
1842
- // "maxLever": "125",
1843
- // "posLimit": "0.05",
1844
- // "maintainTime": ""
1845
- // },
1846
- // ]
1847
- // }
1848
- //
1849
- const data = this.safeValue(response, 'data', []);
1850
- return this.parseMarkets(data);
1851
- }
1852
1810
  async fetchCurrencies(params = {}) {
1853
1811
  /**
1854
1812
  * @method
@@ -8869,6 +8827,9 @@ class bitget extends bitget$1 {
8869
8827
  }
8870
8828
  return undefined;
8871
8829
  }
8830
+ nonce() {
8831
+ return this.milliseconds() - this.options['timeDifference'];
8832
+ }
8872
8833
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
8873
8834
  const signed = api[0] === 'private';
8874
8835
  const endpoint = api[1];
@@ -8886,7 +8847,7 @@ class bitget extends bitget$1 {
8886
8847
  }
8887
8848
  if (signed) {
8888
8849
  this.checkRequiredCredentials();
8889
- const timestamp = this.milliseconds().toString();
8850
+ const timestamp = this.nonce().toString();
8890
8851
  let auth = timestamp + method + payload;
8891
8852
  if (method === 'POST') {
8892
8853
  body = this.json(params);