ccxt 4.4.88 → 4.4.90

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 (85) hide show
  1. package/README.md +61 -19
  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 +6 -3
  5. package/dist/cjs/src/base/functions/encode.js +1 -1
  6. package/dist/cjs/src/base/functions/generic.js +6 -0
  7. package/dist/cjs/src/base/functions.js +1 -0
  8. package/dist/cjs/src/binance.js +1 -1
  9. package/dist/cjs/src/bingx.js +60 -32
  10. package/dist/cjs/src/bitget.js +493 -154
  11. package/dist/cjs/src/bitrue.js +72 -66
  12. package/dist/cjs/src/bitvavo.js +34 -0
  13. package/dist/cjs/src/btcalpha.js +35 -0
  14. package/dist/cjs/src/btcbox.js +35 -0
  15. package/dist/cjs/src/btcmarkets.js +35 -0
  16. package/dist/cjs/src/btcturk.js +35 -0
  17. package/dist/cjs/src/bybit.js +9 -3
  18. package/dist/cjs/src/coinbase.js +1 -4
  19. package/dist/cjs/src/cryptocom.js +54 -0
  20. package/dist/cjs/src/delta.js +2 -2
  21. package/dist/cjs/src/digifinex.js +40 -109
  22. package/dist/cjs/src/gate.js +12 -5
  23. package/dist/cjs/src/hashkey.js +15 -28
  24. package/dist/cjs/src/hollaex.js +28 -24
  25. package/dist/cjs/src/kraken.js +30 -53
  26. package/dist/cjs/src/luno.js +92 -0
  27. package/dist/cjs/src/okx.js +2 -1
  28. package/dist/cjs/src/phemex.js +16 -8
  29. package/dist/cjs/src/pro/coinbase.js +2 -0
  30. package/dist/cjs/src/pro/cryptocom.js +27 -0
  31. package/dist/cjs/src/pro/kraken.js +3 -11
  32. package/dist/cjs/src/tradeogre.js +3 -3
  33. package/dist/cjs/src/xt.js +1 -1
  34. package/js/ccxt.d.ts +1 -1
  35. package/js/ccxt.js +1 -1
  36. package/js/src/abstract/bitget.d.ts +58 -0
  37. package/js/src/abstract/cryptocom.d.ts +2 -0
  38. package/js/src/abstract/luno.d.ts +1 -0
  39. package/js/src/base/Exchange.d.ts +4 -1
  40. package/js/src/base/Exchange.js +6 -3
  41. package/js/src/base/functions/encode.d.ts +1 -1
  42. package/js/src/base/functions/encode.js +1 -1
  43. package/js/src/base/functions/generic.d.ts +2 -1
  44. package/js/src/base/functions/generic.js +6 -1
  45. package/js/src/binance.js +1 -1
  46. package/js/src/bingx.d.ts +9 -5
  47. package/js/src/bingx.js +60 -32
  48. package/js/src/bitget.d.ts +4 -1
  49. package/js/src/bitget.js +493 -154
  50. package/js/src/bitrue.js +72 -66
  51. package/js/src/bitvavo.js +34 -0
  52. package/js/src/btcalpha.js +35 -0
  53. package/js/src/btcbox.js +35 -0
  54. package/js/src/btcmarkets.js +35 -0
  55. package/js/src/btcturk.js +35 -0
  56. package/js/src/bybit.js +9 -3
  57. package/js/src/coinbase.d.ts +1 -1
  58. package/js/src/coinbase.js +1 -4
  59. package/js/src/cryptocom.d.ts +17 -0
  60. package/js/src/cryptocom.js +54 -0
  61. package/js/src/delta.js +2 -2
  62. package/js/src/digifinex.js +40 -109
  63. package/js/src/gate.d.ts +1 -1
  64. package/js/src/gate.js +12 -5
  65. package/js/src/hashkey.d.ts +0 -1
  66. package/js/src/hashkey.js +15 -28
  67. package/js/src/hollaex.d.ts +1 -2
  68. package/js/src/hollaex.js +29 -25
  69. package/js/src/kraken.d.ts +0 -1
  70. package/js/src/kraken.js +30 -53
  71. package/js/src/luno.d.ts +9 -1
  72. package/js/src/luno.js +92 -0
  73. package/js/src/okx.js +2 -1
  74. package/js/src/phemex.d.ts +1 -0
  75. package/js/src/phemex.js +16 -8
  76. package/js/src/pro/coinbase.js +2 -0
  77. package/js/src/pro/cryptocom.d.ts +16 -0
  78. package/js/src/pro/cryptocom.js +27 -0
  79. package/js/src/pro/kraken.js +3 -11
  80. package/js/src/tradeogre.js +3 -3
  81. package/js/src/xt.js +1 -1
  82. package/package.json +4 -7
  83. package/examples/README.md +0 -316
  84. package/examples/js/README.md +0 -15
  85. package/examples/js/cli.js +0 -559
@@ -173,6 +173,7 @@ class bitget extends bitget$1 {
173
173
  'convert': 'https://api.{hostname}',
174
174
  'copy': 'https://api.{hostname}',
175
175
  'earn': 'https://api.{hostname}',
176
+ 'uta': 'https://api.{hostname}',
176
177
  },
177
178
  'www': 'https://www.bitget.com',
178
179
  'doc': [
@@ -289,6 +290,24 @@ class bitget extends bitget$1 {
289
290
  'v2/earn/loan/public/hour-interest': 2,
290
291
  },
291
292
  },
293
+ 'uta': {
294
+ 'get': {
295
+ 'v3/market/instruments': 1,
296
+ 'v3/market/tickers': 1,
297
+ 'v3/market/orderbook': 1,
298
+ 'v3/market/fills': 1,
299
+ 'v3/market/open-interest': 1,
300
+ 'v3/market/candles': 1,
301
+ 'v3/market/history-candles': 1,
302
+ 'v3/market/current-fund-rate': 1,
303
+ 'v3/market/history-fund-rate': 1,
304
+ 'v3/market/risk-reserve': 1,
305
+ 'v3/market/discount-rate': 1,
306
+ 'v3/market/margin-loans': 1,
307
+ 'v3/market/position-tier': 1,
308
+ 'v3/market/oi-limit': 2,
309
+ },
310
+ },
292
311
  },
293
312
  'private': {
294
313
  'spot': {
@@ -782,6 +801,56 @@ class bitget extends bitget$1 {
782
801
  'v2/common/trade-rate': 2,
783
802
  },
784
803
  },
804
+ 'uta': {
805
+ 'get': {
806
+ 'v3/account/assets': 1,
807
+ 'v3/account/settings': 1,
808
+ 'v3/account/financial-records': 1,
809
+ 'v3/account/repayable-coins': 2,
810
+ 'v3/account/payment-coins': 2,
811
+ 'v3/account/convert-records': 1,
812
+ 'v3/account/transferable-coins': 2,
813
+ 'v3/account/sub-transfer-record': 4,
814
+ 'v3/ins-loan/transfered': 6.6667,
815
+ 'v3/ins-loan/symbols': 6.6667,
816
+ 'v3/ins-loan/risk-unit': 6.6667,
817
+ 'v3/ins-loan/repaid-history': 6.6667,
818
+ 'v3/ins-loan/product-infos': 6.6667,
819
+ 'v3/ins-loan/loan-order': 6.6667,
820
+ 'v3/ins-loan/ltv-convert': 6.6667,
821
+ 'v3/ins-loan/ensure-coins-convert': 6.6667,
822
+ 'v3/position/current-position': 1,
823
+ 'v3/position/history-position': 1,
824
+ 'v3/trade/order-info': 1,
825
+ 'v3/trade/unfilled-orders': 1,
826
+ 'v3/trade/history-orders': 1,
827
+ 'v3/trade/fills': 1,
828
+ 'v3/user/sub-list': 2,
829
+ 'v3/user/sub-api-list': 2,
830
+ },
831
+ 'post': {
832
+ 'v3/account/set-leverage': 2,
833
+ 'v3/account/set-hold-mode': 2,
834
+ 'v3/account/repay': 4,
835
+ 'v3/account/transfer': 4,
836
+ 'v3/account/sub-transfer': 4,
837
+ 'v3/account/max-open-available': 4,
838
+ 'v3/ins-loan/bind-uid': 6.6667,
839
+ 'v3/trade/place-order': 2,
840
+ 'v3/trade/modify-order': 2,
841
+ 'v3/trade/cancel-order': 2,
842
+ 'v3/trade/place-batch': 4,
843
+ 'v3/trade/batch-modify-order': 2,
844
+ 'v3/trade/cancel-batch': 4,
845
+ 'v3/trade/cancel-symbol-order': 4,
846
+ 'v3/trade/close-positions': 4,
847
+ 'v3/user/create-sub': 2,
848
+ 'v3/user/freeze-sub': 2,
849
+ 'v3/user/create-sub-api': 2,
850
+ 'v3/user/update-sub-api': 2,
851
+ 'v3/user/delete-sub-api': 2,
852
+ },
853
+ },
785
854
  },
786
855
  },
787
856
  'fees': {
@@ -1325,6 +1394,7 @@ class bitget extends bitget$1 {
1325
1394
  'TONCOIN': 'TON',
1326
1395
  },
1327
1396
  'options': {
1397
+ 'uta': false,
1328
1398
  'timeDifference': 0,
1329
1399
  'adjustForTimeDifference': false,
1330
1400
  'timeframes': {
@@ -1359,10 +1429,9 @@ class bitget extends bitget$1 {
1359
1429
  '1M': '1Mutc',
1360
1430
  },
1361
1431
  },
1362
- 'fetchMarkets': [
1363
- 'spot',
1364
- 'swap', // there is future markets but they use the same endpoints as swap
1365
- ],
1432
+ 'fetchMarkets': {
1433
+ 'types': ['spot', 'swap'], // there is future markets but they use the same endpoints as swap
1434
+ },
1366
1435
  'defaultType': 'spot',
1367
1436
  'defaultSubType': 'linear',
1368
1437
  'createMarketBuyOrderRequiresPrice': true,
@@ -1760,14 +1829,35 @@ class bitget extends bitget$1 {
1760
1829
  * @see https://www.bitget.com/api-doc/spot/market/Get-Symbols
1761
1830
  * @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
1762
1831
  * @see https://www.bitget.com/api-doc/margin/common/support-currencies
1832
+ * @see https://www.bitget.bike/api-doc/uta/public/Instruments
1763
1833
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1834
+ * @param {string} [params.uta] set to true to fetch markets for the unified trading account (uta), defaults to false
1764
1835
  * @returns {object[]} an array of objects representing market data
1765
1836
  */
1766
1837
  async fetchMarkets(params = {}) {
1767
1838
  if (this.options['adjustForTimeDifference']) {
1768
1839
  await this.loadTimeDifference();
1769
1840
  }
1770
- const types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
1841
+ let uta = undefined;
1842
+ [uta, params] = this.handleOptionAndParams(params, 'fetchMarkets', 'uta', false);
1843
+ if (uta) {
1844
+ return await this.fetchUtaMarkets(params);
1845
+ }
1846
+ else {
1847
+ return await this.fetchDefaultMarkets(params);
1848
+ }
1849
+ }
1850
+ async fetchDefaultMarkets(params) {
1851
+ let types = undefined;
1852
+ const fetchMarketsOptions = this.safeDict(this.options, 'fetchMarkets');
1853
+ const defaultMarkets = ['spot', 'swap'];
1854
+ if (fetchMarketsOptions !== undefined) {
1855
+ types = this.safeList(fetchMarketsOptions, 'types', defaultMarkets);
1856
+ }
1857
+ else {
1858
+ // for backward-compatibility
1859
+ types = this.safeList(this.options, 'fetchMarkets', defaultMarkets);
1860
+ }
1771
1861
  const promises = [];
1772
1862
  let fetchMargins = false;
1773
1863
  for (let i = 0; i < types.length; i++) {
@@ -1807,13 +1897,6 @@ class bitget extends bitget$1 {
1807
1897
  markets = this.arrayConcat(markets, data);
1808
1898
  }
1809
1899
  }
1810
- const result = [];
1811
- for (let i = 0; i < markets.length; i++) {
1812
- result.push(this.parseMarket(markets[i]));
1813
- }
1814
- return result;
1815
- }
1816
- parseMarket(market) {
1817
1900
  //
1818
1901
  // spot
1819
1902
  //
@@ -1871,155 +1954,411 @@ class bitget extends bitget$1 {
1871
1954
  // "maintainTime": ""
1872
1955
  // }
1873
1956
  //
1874
- const marketId = this.safeString(market, 'symbol');
1875
- const quoteId = this.safeString(market, 'quoteCoin');
1876
- const baseId = this.safeString(market, 'baseCoin');
1877
- const quote = this.safeCurrencyCode(quoteId);
1878
- const base = this.safeCurrencyCode(baseId);
1879
- const supportMarginCoins = this.safeValue(market, 'supportMarginCoins', []);
1880
- let settleId = undefined;
1881
- if (this.inArray(baseId, supportMarginCoins)) {
1882
- settleId = baseId;
1957
+ const result = [];
1958
+ for (let i = 0; i < markets.length; i++) {
1959
+ const market = markets[i];
1960
+ const marketId = this.safeString(market, 'symbol');
1961
+ const quoteId = this.safeString(market, 'quoteCoin');
1962
+ const baseId = this.safeString(market, 'baseCoin');
1963
+ const quote = this.safeCurrencyCode(quoteId);
1964
+ const base = this.safeCurrencyCode(baseId);
1965
+ const supportMarginCoins = this.safeValue(market, 'supportMarginCoins', []);
1966
+ let settleId = undefined;
1967
+ if (this.inArray(baseId, supportMarginCoins)) {
1968
+ settleId = baseId;
1969
+ }
1970
+ else if (this.inArray(quoteId, supportMarginCoins)) {
1971
+ settleId = quoteId;
1972
+ }
1973
+ else {
1974
+ settleId = this.safeString(supportMarginCoins, 0);
1975
+ }
1976
+ const settle = this.safeCurrencyCode(settleId);
1977
+ let symbol = base + '/' + quote;
1978
+ let type = undefined;
1979
+ let swap = false;
1980
+ let spot = false;
1981
+ let future = false;
1982
+ let contract = false;
1983
+ let pricePrecision = undefined;
1984
+ let amountPrecision = undefined;
1985
+ let linear = undefined;
1986
+ let inverse = undefined;
1987
+ let expiry = undefined;
1988
+ let expiryDatetime = undefined;
1989
+ const symbolType = this.safeString(market, 'symbolType');
1990
+ let marginModes = undefined;
1991
+ let isMarginTradingAllowed = false;
1992
+ if (symbolType === undefined) {
1993
+ type = 'spot';
1994
+ spot = true;
1995
+ pricePrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision')));
1996
+ amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityPrecision')));
1997
+ const hasCrossMargin = this.inArray(marketId, this.options['crossMarginPairsData']);
1998
+ const hasIsolatedMargin = this.inArray(marketId, this.options['isolatedMarginPairsData']);
1999
+ marginModes = {
2000
+ 'cross': hasCrossMargin,
2001
+ 'isolated': hasIsolatedMargin,
2002
+ };
2003
+ isMarginTradingAllowed = hasCrossMargin || hasCrossMargin;
2004
+ }
2005
+ else {
2006
+ if (symbolType === 'perpetual') {
2007
+ type = 'swap';
2008
+ swap = true;
2009
+ symbol = symbol + ':' + settle;
2010
+ }
2011
+ else if (symbolType === 'delivery') {
2012
+ expiry = this.safeInteger(market, 'deliveryTime');
2013
+ expiryDatetime = this.iso8601(expiry);
2014
+ const expiryParts = expiryDatetime.split('-');
2015
+ const yearPart = this.safeString(expiryParts, 0);
2016
+ const dayPart = this.safeString(expiryParts, 2);
2017
+ const year = yearPart.slice(2, 4);
2018
+ const month = this.safeString(expiryParts, 1);
2019
+ const day = dayPart.slice(0, 2);
2020
+ const expiryString = year + month + day;
2021
+ type = 'future';
2022
+ future = true;
2023
+ symbol = symbol + ':' + settle + '-' + expiryString;
2024
+ }
2025
+ contract = true;
2026
+ inverse = (base === settle);
2027
+ linear = !inverse;
2028
+ const priceDecimals = this.safeInteger(market, 'pricePlace');
2029
+ const amountDecimals = this.safeInteger(market, 'volumePlace');
2030
+ const priceStep = this.safeString(market, 'priceEndStep');
2031
+ const amountStep = this.safeString(market, 'sizeMultiplier');
2032
+ const precise = new Precise["default"](priceStep);
2033
+ precise.decimals = Math.max(precise.decimals, priceDecimals);
2034
+ precise.reduce();
2035
+ const priceString = precise.toString();
2036
+ pricePrecision = this.parseNumber(priceString);
2037
+ const preciseAmount = new Precise["default"](amountStep);
2038
+ preciseAmount.decimals = Math.max(preciseAmount.decimals, amountDecimals);
2039
+ preciseAmount.reduce();
2040
+ const amountString = preciseAmount.toString();
2041
+ amountPrecision = this.parseNumber(amountString);
2042
+ marginModes = {
2043
+ 'cross': true,
2044
+ 'isolated': true,
2045
+ };
2046
+ }
2047
+ const status = this.safeString2(market, 'status', 'symbolStatus');
2048
+ let active = undefined;
2049
+ if (status !== undefined) {
2050
+ active = ((status === 'online') || (status === 'normal'));
2051
+ }
2052
+ let minCost = undefined;
2053
+ if (quote === 'USDT') {
2054
+ minCost = this.safeNumber(market, 'minTradeUSDT');
2055
+ }
2056
+ const contractSize = contract ? 1 : undefined;
2057
+ result.push(this.safeMarketStructure({
2058
+ 'id': marketId,
2059
+ 'symbol': symbol,
2060
+ 'base': base,
2061
+ 'quote': quote,
2062
+ 'settle': settle,
2063
+ 'baseId': baseId,
2064
+ 'quoteId': quoteId,
2065
+ 'settleId': settleId,
2066
+ 'type': type,
2067
+ 'spot': spot,
2068
+ 'margin': spot && isMarginTradingAllowed,
2069
+ 'marginModes': marginModes,
2070
+ 'swap': swap,
2071
+ 'future': future,
2072
+ 'option': false,
2073
+ 'active': active,
2074
+ 'contract': contract,
2075
+ 'linear': linear,
2076
+ 'inverse': inverse,
2077
+ 'taker': this.safeNumber(market, 'takerFeeRate'),
2078
+ 'maker': this.safeNumber(market, 'makerFeeRate'),
2079
+ 'contractSize': contractSize,
2080
+ 'expiry': expiry,
2081
+ 'expiryDatetime': expiryDatetime,
2082
+ 'strike': undefined,
2083
+ 'optionType': undefined,
2084
+ 'precision': {
2085
+ 'amount': amountPrecision,
2086
+ 'price': pricePrecision,
2087
+ },
2088
+ 'limits': {
2089
+ 'leverage': {
2090
+ 'min': this.safeNumber(market, 'minLever'),
2091
+ 'max': this.safeNumber(market, 'maxLever'),
2092
+ },
2093
+ 'amount': {
2094
+ 'min': this.safeNumber2(market, 'minTradeNum', 'minTradeAmount'),
2095
+ 'max': this.safeNumber(market, 'maxTradeAmount'),
2096
+ },
2097
+ 'price': {
2098
+ 'min': undefined,
2099
+ 'max': undefined,
2100
+ },
2101
+ 'cost': {
2102
+ 'min': minCost,
2103
+ 'max': undefined,
2104
+ },
2105
+ },
2106
+ 'created': this.safeInteger(market, 'launchTime'),
2107
+ 'info': market,
2108
+ }));
1883
2109
  }
1884
- else if (this.inArray(quoteId, supportMarginCoins)) {
1885
- settleId = quoteId;
2110
+ return result;
2111
+ }
2112
+ async fetchUtaMarkets(params) {
2113
+ const subTypes = ['SPOT', 'USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES'];
2114
+ const promises = [];
2115
+ for (let i = 0; i < subTypes.length; i++) {
2116
+ const req = this.extend(params, {
2117
+ 'category': subTypes[i],
2118
+ });
2119
+ promises.push(this.publicUtaGetV3MarketInstruments(req));
1886
2120
  }
1887
- else {
1888
- settleId = this.safeString(supportMarginCoins, 0);
2121
+ const results = await Promise.all(promises);
2122
+ let markets = [];
2123
+ for (let i = 0; i < results.length; i++) {
2124
+ const res = this.safeDict(results, i);
2125
+ const data = this.safeList(res, 'data', []);
2126
+ markets = this.arrayConcat(markets, data);
1889
2127
  }
1890
- const settle = this.safeCurrencyCode(settleId);
1891
- let symbol = base + '/' + quote;
1892
- let type = undefined;
1893
- let swap = false;
1894
- let spot = false;
1895
- let future = false;
1896
- let contract = false;
1897
- let pricePrecision = undefined;
1898
- let amountPrecision = undefined;
1899
- let linear = undefined;
1900
- let inverse = undefined;
1901
- let expiry = undefined;
1902
- let expiryDatetime = undefined;
1903
- const symbolType = this.safeString(market, 'symbolType');
1904
- let marginModes = undefined;
1905
- let isMarginTradingAllowed = false;
1906
- if (symbolType === undefined) {
1907
- type = 'spot';
1908
- spot = true;
2128
+ //
2129
+ // spot uta
2130
+ //
2131
+ // {
2132
+ // "symbol": "BTCUSDT",
2133
+ // "category": "SPOT",
2134
+ // "baseCoin": "BTC",
2135
+ // "quoteCoin": "USDT",
2136
+ // "buyLimitPriceRatio": "0.05",
2137
+ // "sellLimitPriceRatio": "0.05",
2138
+ // "minOrderQty": "0.000001",
2139
+ // "maxOrderQty": "0",
2140
+ // "pricePrecision": "2",
2141
+ // "quantityPrecision": "6",
2142
+ // "quotePrecision": "8",
2143
+ // "minOrderAmount": "1",
2144
+ // "maxSymbolOrderNum": "400",
2145
+ // "maxProductOrderNum": "400",
2146
+ // "status": "online",
2147
+ // "maintainTime": ""
2148
+ // }
2149
+ //
2150
+ // margin uta
2151
+ //
2152
+ // {
2153
+ // "symbol": "BTCUSDC",
2154
+ // "category": "MARGIN",
2155
+ // "baseCoin": "BTC",
2156
+ // "quoteCoin": "USDC",
2157
+ // "buyLimitPriceRatio": "0.05",
2158
+ // "sellLimitPriceRatio": "0.05",
2159
+ // "minOrderQty": "0.00001",
2160
+ // "maxOrderQty": "0",
2161
+ // "pricePrecision": "2",
2162
+ // "quantityPrecision": "5",
2163
+ // "quotePrecision": "7",
2164
+ // "minOrderAmount": "1",
2165
+ // "maxSymbolOrderNum": "400",
2166
+ // "maxProductOrderNum": "400",
2167
+ // "status": "online",
2168
+ // "maintainTime": "",
2169
+ // "isIsolatedBaseBorrowable": "NO",
2170
+ // "isIsolatedQuotedBorrowable": "NO",
2171
+ // "warningRiskRatio": "0.8",
2172
+ // "liquidationRiskRatio": "1",
2173
+ // "maxCrossedLeverage": "3",
2174
+ // "maxIsolatedLeverage": "0",
2175
+ // "userMinBorrow": "0.00000001",
2176
+ // "areaSymbol": "no"
2177
+ // }
2178
+ //
2179
+ // swap and future uta
2180
+ //
2181
+ // {
2182
+ // "symbol": "BTCPERP",
2183
+ // "category": "USDC-FUTURES",
2184
+ // "baseCoin": "BTC",
2185
+ // "quoteCoin": "USDC",
2186
+ // "buyLimitPriceRatio": "0.02",
2187
+ // "sellLimitPriceRatio": "0.02",
2188
+ // "feeRateUpRatio": "0.005",
2189
+ // "makerFeeRate": "0.0002",
2190
+ // "takerFeeRate": "0.0006",
2191
+ // "openCostUpRatio": "0.01",
2192
+ // "minOrderQty": "0.0001",
2193
+ // "maxOrderQty": "",
2194
+ // "pricePrecision": "1",
2195
+ // "quantityPrecision": "4",
2196
+ // "quotePrecision": null,
2197
+ // "priceMultiplier": "0.5",
2198
+ // "quantityMultiplier": "0.0001",
2199
+ // "type": "perpetual",
2200
+ // "minOrderAmount": "5",
2201
+ // "maxSymbolOrderNum": "200",
2202
+ // "maxProductOrderNum": "1000",
2203
+ // "maxPositionNum": "150",
2204
+ // "status": "online",
2205
+ // "offTime": "-1",
2206
+ // "limitOpenTime": "-1",
2207
+ // "deliveryTime": "",
2208
+ // "deliveryStartTime": "",
2209
+ // "deliveryPeriod": "",
2210
+ // "launchTime": "",
2211
+ // "fundInterval": "8",
2212
+ // "minLeverage": "1",
2213
+ // "maxLeverage": "125",
2214
+ // "maintainTime": ""
2215
+ // }
2216
+ //
2217
+ const result = [];
2218
+ for (let i = 0; i < markets.length; i++) {
2219
+ const market = markets[i];
2220
+ const category = this.safeString(market, 'category');
2221
+ const marketId = this.safeString(market, 'symbol');
2222
+ const quoteId = this.safeString(market, 'quoteCoin');
2223
+ const baseId = this.safeString(market, 'baseCoin');
2224
+ const quote = this.safeCurrencyCode(quoteId);
2225
+ const base = this.safeCurrencyCode(baseId);
2226
+ let settleId = undefined;
2227
+ let settle = undefined;
2228
+ if (category === 'USDT-FUTURES') {
2229
+ settleId = 'USDT';
2230
+ }
2231
+ else if (category === 'USDC-FUTURES') {
2232
+ settleId = 'USDC';
2233
+ }
2234
+ else if (category === 'COIN-FUTURES') {
2235
+ settleId = base;
2236
+ }
2237
+ if (settleId !== undefined) {
2238
+ settle = this.safeCurrencyCode(settleId);
2239
+ }
2240
+ let symbol = base + '/' + quote;
2241
+ let type = undefined;
2242
+ let swap = false;
2243
+ let spot = false;
2244
+ let future = false;
2245
+ let contract = false;
2246
+ let pricePrecision = undefined;
2247
+ let amountPrecision = undefined;
2248
+ let linear = undefined;
2249
+ let inverse = undefined;
2250
+ let expiry = undefined;
2251
+ let expiryDatetime = undefined;
2252
+ const symbolType = this.safeString(market, 'type');
2253
+ let marginModes = undefined;
2254
+ let isMarginTradingAllowed = false;
2255
+ const isUtaMargin = (category === 'MARGIN');
2256
+ if (isUtaMargin || (category === 'SPOT')) {
2257
+ type = 'spot';
2258
+ spot = true;
2259
+ if (isUtaMargin) {
2260
+ const isolatedBase = this.safeString(market, 'isIsolatedBaseBorrowable');
2261
+ const isolatedQuote = this.safeString(market, 'isIsolatedQuotedBorrowable');
2262
+ const isolated = (isolatedBase === 'YES') || (isolatedQuote === 'YES');
2263
+ const maxCrossLeverage = this.safeString(market, 'maxCrossedLeverage');
2264
+ const cross = (maxCrossLeverage !== '0');
2265
+ marginModes = {
2266
+ 'cross': cross,
2267
+ 'isolated': isolated,
2268
+ };
2269
+ isMarginTradingAllowed = true;
2270
+ }
2271
+ }
2272
+ else {
2273
+ if (symbolType === 'perpetual') {
2274
+ type = 'swap';
2275
+ swap = true;
2276
+ symbol = symbol + ':' + settle;
2277
+ }
2278
+ else if (symbolType === 'delivery') {
2279
+ expiry = this.safeInteger(market, 'deliveryTime');
2280
+ expiryDatetime = this.iso8601(expiry);
2281
+ const expiryParts = expiryDatetime.split('-');
2282
+ const yearPart = this.safeString(expiryParts, 0);
2283
+ const dayPart = this.safeString(expiryParts, 2);
2284
+ const year = yearPart.slice(2, 4);
2285
+ const month = this.safeString(expiryParts, 1);
2286
+ const day = dayPart.slice(0, 2);
2287
+ const expiryString = year + month + day;
2288
+ type = 'future';
2289
+ future = true;
2290
+ symbol = symbol + ':' + settle + '-' + expiryString;
2291
+ }
2292
+ contract = true;
2293
+ inverse = (base === settle);
2294
+ linear = !inverse;
2295
+ marginModes = {
2296
+ 'cross': true,
2297
+ 'isolated': true,
2298
+ };
2299
+ }
1909
2300
  pricePrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision')));
1910
2301
  amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'quantityPrecision')));
1911
- const hasCrossMargin = this.inArray(marketId, this.options['crossMarginPairsData']);
1912
- const hasIsolatedMargin = this.inArray(marketId, this.options['isolatedMarginPairsData']);
1913
- marginModes = {
1914
- 'cross': hasCrossMargin,
1915
- 'isolated': hasIsolatedMargin,
1916
- };
1917
- isMarginTradingAllowed = hasCrossMargin || hasCrossMargin;
1918
- }
1919
- else {
1920
- if (symbolType === 'perpetual') {
1921
- type = 'swap';
1922
- swap = true;
1923
- symbol = symbol + ':' + settle;
1924
- }
1925
- else if (symbolType === 'delivery') {
1926
- expiry = this.safeInteger(market, 'deliveryTime');
1927
- expiryDatetime = this.iso8601(expiry);
1928
- const expiryParts = expiryDatetime.split('-');
1929
- const yearPart = this.safeString(expiryParts, 0);
1930
- const dayPart = this.safeString(expiryParts, 2);
1931
- const year = yearPart.slice(2, 4);
1932
- const month = this.safeString(expiryParts, 1);
1933
- const day = dayPart.slice(0, 2);
1934
- const expiryString = year + month + day;
1935
- type = 'future';
1936
- future = true;
1937
- symbol = symbol + ':' + settle + '-' + expiryString;
1938
- }
1939
- contract = true;
1940
- inverse = (base === settle);
1941
- linear = !inverse;
1942
- const priceDecimals = this.safeInteger(market, 'pricePlace');
1943
- const amountDecimals = this.safeInteger(market, 'volumePlace');
1944
- const priceStep = this.safeString(market, 'priceEndStep');
1945
- const amountStep = this.safeString(market, 'sizeMultiplier');
1946
- const precise = new Precise["default"](priceStep);
1947
- precise.decimals = Math.max(precise.decimals, priceDecimals);
1948
- precise.reduce();
1949
- const priceString = precise.toString();
1950
- pricePrecision = this.parseNumber(priceString);
1951
- const preciseAmount = new Precise["default"](amountStep);
1952
- preciseAmount.decimals = Math.max(preciseAmount.decimals, amountDecimals);
1953
- preciseAmount.reduce();
1954
- const amountString = preciseAmount.toString();
1955
- amountPrecision = this.parseNumber(amountString);
1956
- marginModes = {
1957
- 'cross': true,
1958
- 'isolated': true,
1959
- };
1960
- }
1961
- const status = this.safeString2(market, 'status', 'symbolStatus');
1962
- let active = undefined;
1963
- if (status !== undefined) {
1964
- active = ((status === 'online') || (status === 'normal'));
1965
- }
1966
- let minCost = undefined;
1967
- if (quote === 'USDT') {
1968
- minCost = this.safeNumber(market, 'minTradeUSDT');
1969
- }
1970
- const contractSize = contract ? 1 : undefined;
1971
- return {
1972
- 'id': marketId,
1973
- 'symbol': symbol,
1974
- 'base': base,
1975
- 'quote': quote,
1976
- 'settle': settle,
1977
- 'baseId': baseId,
1978
- 'quoteId': quoteId,
1979
- 'settleId': settleId,
1980
- 'type': type,
1981
- 'spot': spot,
1982
- 'margin': spot && isMarginTradingAllowed,
1983
- 'marginModes': marginModes,
1984
- 'swap': swap,
1985
- 'future': future,
1986
- 'option': false,
1987
- 'active': active,
1988
- 'contract': contract,
1989
- 'linear': linear,
1990
- 'inverse': inverse,
1991
- 'taker': this.safeNumber(market, 'takerFeeRate'),
1992
- 'maker': this.safeNumber(market, 'makerFeeRate'),
1993
- 'contractSize': contractSize,
1994
- 'expiry': expiry,
1995
- 'expiryDatetime': expiryDatetime,
1996
- 'strike': undefined,
1997
- 'optionType': undefined,
1998
- 'precision': {
1999
- 'amount': amountPrecision,
2000
- 'price': pricePrecision,
2001
- },
2002
- 'limits': {
2003
- 'leverage': {
2004
- 'min': this.safeNumber(market, 'minLever'),
2005
- 'max': this.safeNumber(market, 'maxLever'),
2006
- },
2007
- 'amount': {
2008
- 'min': this.safeNumber2(market, 'minTradeNum', 'minTradeAmount'),
2009
- 'max': this.safeNumber(market, 'maxTradeAmount'),
2010
- },
2011
- 'price': {
2012
- 'min': undefined,
2013
- 'max': undefined,
2302
+ const status = this.safeString(market, 'status');
2303
+ let active = undefined;
2304
+ if (status !== undefined) {
2305
+ active = ((status === 'online') || (status === 'normal'));
2306
+ }
2307
+ const contractSize = contract ? 1 : undefined;
2308
+ result.push(this.safeMarketStructure({
2309
+ 'id': marketId,
2310
+ 'symbol': symbol,
2311
+ 'base': base,
2312
+ 'quote': quote,
2313
+ 'settle': settle,
2314
+ 'baseId': baseId,
2315
+ 'quoteId': quoteId,
2316
+ 'settleId': settleId,
2317
+ 'type': type,
2318
+ 'spot': spot,
2319
+ 'margin': spot && isMarginTradingAllowed,
2320
+ 'marginModes': marginModes,
2321
+ 'swap': swap,
2322
+ 'future': future,
2323
+ 'option': false,
2324
+ 'active': active,
2325
+ 'contract': contract,
2326
+ 'linear': linear,
2327
+ 'inverse': inverse,
2328
+ 'taker': this.safeNumber(market, 'takerFeeRate'),
2329
+ 'maker': this.safeNumber(market, 'makerFeeRate'),
2330
+ 'contractSize': contractSize,
2331
+ 'expiry': expiry,
2332
+ 'expiryDatetime': expiryDatetime,
2333
+ 'strike': undefined,
2334
+ 'optionType': undefined,
2335
+ 'precision': {
2336
+ 'amount': amountPrecision,
2337
+ 'price': pricePrecision,
2014
2338
  },
2015
- 'cost': {
2016
- 'min': minCost,
2017
- 'max': undefined,
2339
+ 'limits': {
2340
+ 'leverage': {
2341
+ 'min': this.safeNumber(market, 'minLeverage'),
2342
+ 'max': this.safeNumber(market, 'maxLeverage'),
2343
+ },
2344
+ 'amount': {
2345
+ 'min': this.safeNumber(market, 'minOrderQty'),
2346
+ 'max': this.safeNumber(market, 'maxOrderQty'),
2347
+ },
2348
+ 'price': {
2349
+ 'min': undefined,
2350
+ 'max': undefined,
2351
+ },
2352
+ 'cost': {
2353
+ 'min': undefined,
2354
+ 'max': undefined,
2355
+ },
2018
2356
  },
2019
- },
2020
- 'created': this.safeInteger(market, 'launchTime'),
2021
- 'info': market,
2022
- };
2357
+ 'created': this.safeInteger(market, 'launchTime'),
2358
+ 'info': market,
2359
+ }));
2360
+ }
2361
+ return result;
2023
2362
  }
2024
2363
  /**
2025
2364
  * @method