ccxt 4.2.94 → 4.2.95
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.
- package/README.md +3 -3
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +285 -287
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/errors.js +25 -64
- package/dist/cjs/src/base/ws/OrderBookSide.js +5 -0
- package/dist/cjs/src/bitstamp.js +6 -0
- package/dist/cjs/src/coinex.js +61 -55
- package/dist/cjs/src/gemini.js +2 -1
- package/dist/cjs/src/htx.js +127 -125
- package/dist/cjs/src/okx.js +40 -40
- package/dist/cjs/src/pro/coinbase.js +18 -0
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +3 -3
- package/js/src/abstract/bitstamp.d.ts +6 -0
- package/js/src/base/errorHierarchy.d.ts +1 -1
- package/js/src/base/errorHierarchy.js +1 -1
- package/js/src/base/errors.d.ts +26 -26
- package/js/src/base/errors.js +26 -66
- package/js/src/base/ws/OrderBook.d.ts +7 -0
- package/js/src/base/ws/OrderBook.js +1 -6
- package/js/src/base/ws/OrderBookSide.d.ts +9 -3
- package/js/src/base/ws/OrderBookSide.js +6 -1
- package/js/src/bitstamp.js +6 -0
- package/js/src/coinex.js +61 -55
- package/js/src/gemini.js +2 -1
- package/js/src/htx.d.ts +1 -0
- package/js/src/htx.js +128 -126
- package/js/src/okx.js +40 -40
- package/js/src/pro/coinbase.js +18 -0
- package/package.json +1 -1
- package/skip-tests.json +1 -0
package/js/src/htx.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/htx.js';
|
|
9
|
-
import { AccountNotEnabled, ArgumentsRequired, AuthenticationError, ExchangeError, PermissionDenied, ExchangeNotAvailable, OnMaintenance, InvalidOrder, OrderNotFound, InsufficientFunds, BadSymbol, BadRequest, RateLimitExceeded, RequestTimeout,
|
|
9
|
+
import { AccountNotEnabled, ArgumentsRequired, AuthenticationError, ExchangeError, PermissionDenied, ExchangeNotAvailable, OnMaintenance, InvalidOrder, OrderNotFound, InsufficientFunds, BadSymbol, BadRequest, RateLimitExceeded, RequestTimeout, OperationFailed, NotSupported } from './base/errors.js';
|
|
10
10
|
import { Precise } from './base/Precise.js';
|
|
11
11
|
import { TICK_SIZE, TRUNCATE } from './base/functions/number.js';
|
|
12
12
|
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
|
|
@@ -943,14 +943,8 @@ export default class htx extends Exchange {
|
|
|
943
943
|
'fetchMarkets': {
|
|
944
944
|
'types': {
|
|
945
945
|
'spot': true,
|
|
946
|
-
'
|
|
947
|
-
|
|
948
|
-
'inverse': true,
|
|
949
|
-
},
|
|
950
|
-
'swap': {
|
|
951
|
-
'linear': true,
|
|
952
|
-
'inverse': true,
|
|
953
|
-
},
|
|
946
|
+
'linear': true,
|
|
947
|
+
'inverse': true,
|
|
954
948
|
},
|
|
955
949
|
},
|
|
956
950
|
'fetchOHLCV': {
|
|
@@ -1617,25 +1611,23 @@ export default class htx extends Exchange {
|
|
|
1617
1611
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1618
1612
|
* @returns {object[]} an array of objects representing market data
|
|
1619
1613
|
*/
|
|
1620
|
-
|
|
1621
|
-
|
|
1614
|
+
let types = undefined;
|
|
1615
|
+
[types, params] = this.handleOptionAndParams(params, 'fetchMarkets', 'types', {});
|
|
1622
1616
|
let allMarkets = [];
|
|
1623
1617
|
let promises = [];
|
|
1624
1618
|
const keys = Object.keys(types);
|
|
1625
1619
|
for (let i = 0; i < keys.length; i++) {
|
|
1626
|
-
const
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
promises.push(this.fetchMarketsByTypeAndSubType(type, subType, params));
|
|
1638
|
-
}
|
|
1620
|
+
const key = keys[i];
|
|
1621
|
+
if (this.safeBool(types, key)) {
|
|
1622
|
+
if (key === 'spot') {
|
|
1623
|
+
promises.push(this.fetchMarketsByTypeAndSubType('spot', undefined, params));
|
|
1624
|
+
}
|
|
1625
|
+
else if (key === 'linear') {
|
|
1626
|
+
promises.push(this.fetchMarketsByTypeAndSubType(undefined, 'linear', params));
|
|
1627
|
+
}
|
|
1628
|
+
else if (key === 'inverse') {
|
|
1629
|
+
promises.push(this.fetchMarketsByTypeAndSubType('swap', 'inverse', params));
|
|
1630
|
+
promises.push(this.fetchMarketsByTypeAndSubType('future', 'inverse', params));
|
|
1639
1631
|
}
|
|
1640
1632
|
}
|
|
1641
1633
|
}
|
|
@@ -1646,35 +1638,25 @@ export default class htx extends Exchange {
|
|
|
1646
1638
|
return allMarkets;
|
|
1647
1639
|
}
|
|
1648
1640
|
async fetchMarketsByTypeAndSubType(type, subType, params = {}) {
|
|
1649
|
-
const
|
|
1650
|
-
const spot = (type === 'spot');
|
|
1651
|
-
const contract = (type !== 'spot');
|
|
1652
|
-
const future = (type === 'future');
|
|
1653
|
-
const swap = (type === 'swap');
|
|
1654
|
-
let linear = undefined;
|
|
1655
|
-
let inverse = undefined;
|
|
1641
|
+
const isSpot = (type === 'spot');
|
|
1656
1642
|
const request = {};
|
|
1657
1643
|
let response = undefined;
|
|
1658
|
-
if (
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
if (future) {
|
|
1663
|
-
request['business_type'] = 'futures';
|
|
1664
|
-
}
|
|
1665
|
-
response = await this.contractPublicGetLinearSwapApiV1SwapContractInfo(this.extend(request, query));
|
|
1644
|
+
if (!isSpot) {
|
|
1645
|
+
if (subType === 'linear') {
|
|
1646
|
+
request['business_type'] = 'all'; // override default to fetch all linear markets
|
|
1647
|
+
response = await this.contractPublicGetLinearSwapApiV1SwapContractInfo(this.extend(request, params));
|
|
1666
1648
|
}
|
|
1667
|
-
else if (inverse) {
|
|
1668
|
-
if (future) {
|
|
1669
|
-
response = await this.contractPublicGetApiV1ContractContractInfo(this.extend(request,
|
|
1649
|
+
else if (subType === 'inverse') {
|
|
1650
|
+
if (type === 'future') {
|
|
1651
|
+
response = await this.contractPublicGetApiV1ContractContractInfo(this.extend(request, params));
|
|
1670
1652
|
}
|
|
1671
|
-
else if (swap) {
|
|
1672
|
-
response = await this.contractPublicGetSwapApiV1SwapContractInfo(this.extend(request,
|
|
1653
|
+
else if (type === 'swap') {
|
|
1654
|
+
response = await this.contractPublicGetSwapApiV1SwapContractInfo(this.extend(request, params));
|
|
1673
1655
|
}
|
|
1674
1656
|
}
|
|
1675
1657
|
}
|
|
1676
1658
|
else {
|
|
1677
|
-
response = await this.spotPublicGetV1CommonSymbols(this.extend(request,
|
|
1659
|
+
response = await this.spotPublicGetV1CommonSymbols(this.extend(request, params));
|
|
1678
1660
|
}
|
|
1679
1661
|
//
|
|
1680
1662
|
// spot
|
|
@@ -1714,75 +1696,58 @@ export default class htx extends Exchange {
|
|
|
1714
1696
|
// ]
|
|
1715
1697
|
// }
|
|
1716
1698
|
//
|
|
1717
|
-
// inverse future
|
|
1699
|
+
// inverse (swap & future)
|
|
1718
1700
|
//
|
|
1719
1701
|
// {
|
|
1720
1702
|
// "status":"ok",
|
|
1721
1703
|
// "data":[
|
|
1722
1704
|
// {
|
|
1723
1705
|
// "symbol":"BTC",
|
|
1724
|
-
// "contract_code":"BTC211126",
|
|
1725
|
-
// "contract_type":"this_week",
|
|
1726
|
-
// "contract_size":100
|
|
1727
|
-
// "price_tick":0.
|
|
1728
|
-
// "delivery_date":"20211126",
|
|
1729
|
-
// "delivery_time":"1637913600000",
|
|
1706
|
+
// "contract_code":"BTC211126", /// BTC-USD in swap
|
|
1707
|
+
// "contract_type":"this_week", // only in future
|
|
1708
|
+
// "contract_size":100,
|
|
1709
|
+
// "price_tick":0.1,
|
|
1710
|
+
// "delivery_date":"20211126", // only in future
|
|
1711
|
+
// "delivery_time":"1637913600000", // empty in swap
|
|
1730
1712
|
// "create_date":"20211112",
|
|
1731
1713
|
// "contract_status":1,
|
|
1732
|
-
// "settlement_time":"1637481600000"
|
|
1714
|
+
// "settlement_time":"1637481600000" // only in future
|
|
1715
|
+
// "settlement_date":"16xxxxxxxxxxx" // only in swap
|
|
1733
1716
|
// },
|
|
1717
|
+
// ...
|
|
1734
1718
|
// ],
|
|
1735
1719
|
// "ts":1637474595140
|
|
1736
1720
|
// }
|
|
1737
1721
|
//
|
|
1738
|
-
// linear
|
|
1722
|
+
// linear (swap & future)
|
|
1739
1723
|
//
|
|
1740
1724
|
// {
|
|
1741
1725
|
// "status":"ok",
|
|
1742
1726
|
// "data":[
|
|
1743
1727
|
// {
|
|
1744
1728
|
// "symbol":"BTC",
|
|
1745
|
-
// "contract_code":"BTC-USDT-211231",
|
|
1746
|
-
// "contract_size":0.
|
|
1747
|
-
// "price_tick":0.
|
|
1748
|
-
// "delivery_date":"20211231",
|
|
1749
|
-
// "delivery_time":"1640937600000",
|
|
1729
|
+
// "contract_code":"BTC-USDT-211231", // or "BTC-USDT" in swap
|
|
1730
|
+
// "contract_size":0.001,
|
|
1731
|
+
// "price_tick":0.1,
|
|
1732
|
+
// "delivery_date":"20211231", // empty in swap
|
|
1733
|
+
// "delivery_time":"1640937600000", // empty in swap
|
|
1750
1734
|
// "create_date":"20211228",
|
|
1751
1735
|
// "contract_status":1,
|
|
1752
1736
|
// "settlement_date":"1640764800000",
|
|
1753
|
-
// "support_margin_mode":"cross",
|
|
1754
|
-
// "business_type":"futures",
|
|
1737
|
+
// "support_margin_mode":"cross", // "all" or "cross"
|
|
1738
|
+
// "business_type":"futures", // "swap" or "futures"
|
|
1755
1739
|
// "pair":"BTC-USDT",
|
|
1756
|
-
// "contract_type":"this_week" // next_week, quarter
|
|
1757
|
-
//
|
|
1740
|
+
// "contract_type":"this_week", // "swap", "this_week", "next_week", "quarter"
|
|
1741
|
+
// "trade_partition":"USDT",
|
|
1742
|
+
// }
|
|
1758
1743
|
// ],
|
|
1759
1744
|
// "ts":1640736207263
|
|
1760
1745
|
// }
|
|
1761
1746
|
//
|
|
1762
|
-
|
|
1763
|
-
//
|
|
1764
|
-
// {
|
|
1765
|
-
// "status":"ok",
|
|
1766
|
-
// "data":[
|
|
1767
|
-
// {
|
|
1768
|
-
// "symbol":"BTC",
|
|
1769
|
-
// "contract_code":"BTC-USDT",
|
|
1770
|
-
// "contract_size":0.001000000000000000,
|
|
1771
|
-
// "price_tick":0.100000000000000000,
|
|
1772
|
-
// "delivery_time":"",
|
|
1773
|
-
// "create_date":"20201021",
|
|
1774
|
-
// "contract_status":1,
|
|
1775
|
-
// "settlement_date":"1637481600000",
|
|
1776
|
-
// "support_margin_mode":"all", // isolated
|
|
1777
|
-
// },
|
|
1778
|
-
// ],
|
|
1779
|
-
// "ts":1637474774467
|
|
1780
|
-
// }
|
|
1781
|
-
//
|
|
1782
|
-
const markets = this.safeValue(response, 'data', []);
|
|
1747
|
+
const markets = this.safeList(response, 'data', []);
|
|
1783
1748
|
const numMarkets = markets.length;
|
|
1784
1749
|
if (numMarkets < 1) {
|
|
1785
|
-
throw new
|
|
1750
|
+
throw new OperationFailed(this.id + ' fetchMarkets() returned an empty response: ' + this.json(response));
|
|
1786
1751
|
}
|
|
1787
1752
|
const result = [];
|
|
1788
1753
|
for (let i = 0; i < markets.length; i++) {
|
|
@@ -1792,16 +1757,31 @@ export default class htx extends Exchange {
|
|
|
1792
1757
|
let settleId = undefined;
|
|
1793
1758
|
let id = undefined;
|
|
1794
1759
|
let lowercaseId = undefined;
|
|
1760
|
+
const contract = ('contract_code' in market);
|
|
1761
|
+
const spot = !contract;
|
|
1762
|
+
let swap = false;
|
|
1763
|
+
let future = false;
|
|
1764
|
+
let linear = undefined;
|
|
1765
|
+
let inverse = undefined;
|
|
1766
|
+
// check if parsed market is contract
|
|
1795
1767
|
if (contract) {
|
|
1796
1768
|
id = this.safeString(market, 'contract_code');
|
|
1797
1769
|
lowercaseId = id.toLowerCase();
|
|
1770
|
+
const delivery_date = this.safeString(market, 'delivery_date');
|
|
1771
|
+
const business_type = this.safeString(market, 'business_type');
|
|
1772
|
+
future = delivery_date !== undefined;
|
|
1773
|
+
swap = !future;
|
|
1774
|
+
linear = business_type !== undefined;
|
|
1775
|
+
inverse = !linear;
|
|
1798
1776
|
if (swap) {
|
|
1777
|
+
type = 'swap';
|
|
1799
1778
|
const parts = id.split('-');
|
|
1800
1779
|
baseId = this.safeStringLower(market, 'symbol');
|
|
1801
1780
|
quoteId = this.safeStringLower(parts, 1);
|
|
1802
1781
|
settleId = inverse ? baseId : quoteId;
|
|
1803
1782
|
}
|
|
1804
1783
|
else if (future) {
|
|
1784
|
+
type = 'future';
|
|
1805
1785
|
baseId = this.safeStringLower(market, 'symbol');
|
|
1806
1786
|
if (inverse) {
|
|
1807
1787
|
quoteId = 'USD';
|
|
@@ -1816,6 +1796,7 @@ export default class htx extends Exchange {
|
|
|
1816
1796
|
}
|
|
1817
1797
|
}
|
|
1818
1798
|
else {
|
|
1799
|
+
type = 'spot';
|
|
1819
1800
|
baseId = this.safeString(market, 'base-currency');
|
|
1820
1801
|
quoteId = this.safeString(market, 'quote-currency');
|
|
1821
1802
|
id = baseId + quoteId;
|
|
@@ -1950,6 +1931,45 @@ export default class htx extends Exchange {
|
|
|
1950
1931
|
}
|
|
1951
1932
|
return result;
|
|
1952
1933
|
}
|
|
1934
|
+
tryGetSymbolFromFutureMarkets(symbolOrMarketId) {
|
|
1935
|
+
if (symbolOrMarketId in this.markets) {
|
|
1936
|
+
return symbolOrMarketId;
|
|
1937
|
+
}
|
|
1938
|
+
// only on "future" market type (inverse & linear), market-id differs between "fetchMarkets" and "fetchTicker"
|
|
1939
|
+
// so we have to create a mapping
|
|
1940
|
+
// - market-id from fetchMarkts: `BTC-USDT-240419` (linear future) or `BTC240412` (inverse future)
|
|
1941
|
+
// - market-id from fetchTciker[s]: `BTC-USDT-CW` (linear future) or `BTC_CW` (inverse future)
|
|
1942
|
+
if (!('futureMarketIdsForSymbols' in this.options)) {
|
|
1943
|
+
this.options['futureMarketIdsForSymbols'] = {};
|
|
1944
|
+
}
|
|
1945
|
+
const futureMarketIdsForSymbols = this.safeDict(this.options, 'futureMarketIdsForSymbols', {});
|
|
1946
|
+
if (symbolOrMarketId in futureMarketIdsForSymbols) {
|
|
1947
|
+
return futureMarketIdsForSymbols[symbolOrMarketId];
|
|
1948
|
+
}
|
|
1949
|
+
const futureMarkets = this.filterBy(this.markets, 'future', true);
|
|
1950
|
+
const futuresCharsMaps = {
|
|
1951
|
+
'this_week': 'CW',
|
|
1952
|
+
'next_week': 'NW',
|
|
1953
|
+
'quarter': 'CQ',
|
|
1954
|
+
'next_quarter': 'NQ',
|
|
1955
|
+
};
|
|
1956
|
+
for (let i = 0; i < futureMarkets.length; i++) {
|
|
1957
|
+
const market = futureMarkets[i];
|
|
1958
|
+
const info = this.safeValue(market, 'info', {});
|
|
1959
|
+
const contractType = this.safeString(info, 'contract_type');
|
|
1960
|
+
const contractSuffix = futuresCharsMaps[contractType];
|
|
1961
|
+
// see comment on formats a bit above
|
|
1962
|
+
const constructedId = market['linear'] ? market['base'] + '-' + market['quote'] + '-' + contractSuffix : market['base'] + '_' + contractSuffix;
|
|
1963
|
+
if (constructedId === symbolOrMarketId) {
|
|
1964
|
+
const symbol = market['symbol'];
|
|
1965
|
+
this.options['futureMarketIdsForSymbols'][symbolOrMarketId] = symbol;
|
|
1966
|
+
return symbol;
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
// if not found, just save it to avoid unnecessary future iterations
|
|
1970
|
+
this.options['futureMarketIdsForSymbols'][symbolOrMarketId] = symbolOrMarketId;
|
|
1971
|
+
return symbolOrMarketId;
|
|
1972
|
+
}
|
|
1953
1973
|
parseTicker(ticker, market = undefined) {
|
|
1954
1974
|
//
|
|
1955
1975
|
// fetchTicker
|
|
@@ -1997,7 +2017,8 @@ export default class htx extends Exchange {
|
|
|
1997
2017
|
// }
|
|
1998
2018
|
//
|
|
1999
2019
|
const marketId = this.safeString2(ticker, 'symbol', 'contract_code');
|
|
2000
|
-
|
|
2020
|
+
let symbol = this.safeSymbol(marketId, market);
|
|
2021
|
+
symbol = this.tryGetSymbolFromFutureMarkets(symbol);
|
|
2001
2022
|
const timestamp = this.safeInteger2(ticker, 'ts', 'quoteTime');
|
|
2002
2023
|
let bid = undefined;
|
|
2003
2024
|
let bidVolume = undefined;
|
|
@@ -2140,7 +2161,7 @@ export default class htx extends Exchange {
|
|
|
2140
2161
|
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-a-batch-of-market-data-overview
|
|
2141
2162
|
* @see https://huobiapi.github.io/docs/dm/v1/en/#get-a-batch-of-market-data-overview
|
|
2142
2163
|
* @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-a-batch-of-market-data-overview-v2
|
|
2143
|
-
* @param {string[]
|
|
2164
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
2144
2165
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2145
2166
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
2146
2167
|
*/
|
|
@@ -2151,22 +2172,30 @@ export default class htx extends Exchange {
|
|
|
2151
2172
|
if (first !== undefined) {
|
|
2152
2173
|
market = this.market(first);
|
|
2153
2174
|
}
|
|
2175
|
+
const isSubTypeRequested = ('subType' in params) || ('business_type' in params);
|
|
2154
2176
|
let type = undefined;
|
|
2155
2177
|
let subType = undefined;
|
|
2156
2178
|
[type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
2157
2179
|
[subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
|
|
2158
2180
|
const request = {};
|
|
2181
|
+
const isSpot = (type === 'spot');
|
|
2159
2182
|
const future = (type === 'future');
|
|
2160
2183
|
const swap = (type === 'swap');
|
|
2161
2184
|
const linear = (subType === 'linear');
|
|
2162
2185
|
const inverse = (subType === 'inverse');
|
|
2163
|
-
params = this.omit(params, ['type', 'subType']);
|
|
2164
2186
|
let response = undefined;
|
|
2165
|
-
if (
|
|
2187
|
+
if (!isSpot || isSubTypeRequested) {
|
|
2166
2188
|
if (linear) {
|
|
2189
|
+
// independently of type, supports calling all linear symbols i.e. fetchTickers(undefined, {subType:'linear'})
|
|
2167
2190
|
if (future) {
|
|
2168
2191
|
request['business_type'] = 'futures';
|
|
2169
2192
|
}
|
|
2193
|
+
else if (swap) {
|
|
2194
|
+
request['business_type'] = 'swap';
|
|
2195
|
+
}
|
|
2196
|
+
else {
|
|
2197
|
+
request['business_type'] = 'all';
|
|
2198
|
+
}
|
|
2170
2199
|
response = await this.contractPublicGetLinearSwapExMarketDetailBatchMerged(this.extend(request, params));
|
|
2171
2200
|
}
|
|
2172
2201
|
else if (inverse) {
|
|
@@ -2176,6 +2205,12 @@ export default class htx extends Exchange {
|
|
|
2176
2205
|
else if (swap) {
|
|
2177
2206
|
response = await this.contractPublicGetSwapExMarketDetailBatchMerged(this.extend(request, params));
|
|
2178
2207
|
}
|
|
2208
|
+
else {
|
|
2209
|
+
throw new NotSupported(this.id + ' fetchTickers() you have to set params["type"] to either "swap" or "future" for inverse contracts');
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
else {
|
|
2213
|
+
throw new NotSupported(this.id + ' fetchTickers() you have to set params["subType"] to either "linear" or "inverse" for contracts');
|
|
2179
2214
|
}
|
|
2180
2215
|
}
|
|
2181
2216
|
else {
|
|
@@ -2231,42 +2266,9 @@ export default class htx extends Exchange {
|
|
|
2231
2266
|
// "ts":1637504679376
|
|
2232
2267
|
// }
|
|
2233
2268
|
//
|
|
2234
|
-
const
|
|
2235
|
-
const
|
|
2236
|
-
|
|
2237
|
-
for (let i = 0; i < tickers.length; i++) {
|
|
2238
|
-
const ticker = this.parseTicker(tickers[i]);
|
|
2239
|
-
// the market ids for linear futures are non-standard and differ from all the other endpoints
|
|
2240
|
-
// we are doing a linear-matching here
|
|
2241
|
-
if (future && linear) {
|
|
2242
|
-
for (let j = 0; j < this.symbols.length; j++) {
|
|
2243
|
-
const symbolInner = this.symbols[j];
|
|
2244
|
-
const marketInner = this.market(symbolInner);
|
|
2245
|
-
const contractType = this.safeString(marketInner['info'], 'contract_type');
|
|
2246
|
-
if ((contractType === 'this_week') && (ticker['symbol'] === (marketInner['baseId'] + '-' + marketInner['quoteId'] + '-CW'))) {
|
|
2247
|
-
ticker['symbol'] = marketInner['symbol'];
|
|
2248
|
-
break;
|
|
2249
|
-
}
|
|
2250
|
-
else if ((contractType === 'next_week') && (ticker['symbol'] === (marketInner['baseId'] + '-' + marketInner['quoteId'] + '-NW'))) {
|
|
2251
|
-
ticker['symbol'] = marketInner['symbol'];
|
|
2252
|
-
break;
|
|
2253
|
-
}
|
|
2254
|
-
else if ((contractType === 'this_quarter') && (ticker['symbol'] === (marketInner['baseId'] + '-' + marketInner['quoteId'] + '-CQ'))) {
|
|
2255
|
-
ticker['symbol'] = marketInner['symbol'];
|
|
2256
|
-
break;
|
|
2257
|
-
}
|
|
2258
|
-
else if ((contractType === 'next_quarter') && (ticker['symbol'] === (marketInner['baseId'] + '-' + marketInner['quoteId'] + '-NQ'))) {
|
|
2259
|
-
ticker['symbol'] = marketInner['symbol'];
|
|
2260
|
-
break;
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
}
|
|
2264
|
-
const symbol = ticker['symbol'];
|
|
2265
|
-
ticker['timestamp'] = timestamp;
|
|
2266
|
-
ticker['datetime'] = this.iso8601(timestamp);
|
|
2267
|
-
result[symbol] = ticker;
|
|
2268
|
-
}
|
|
2269
|
-
return this.filterByArrayTickers(result, 'symbol', symbols);
|
|
2269
|
+
const rawTickers = this.safeList2(response, 'data', 'ticks', []);
|
|
2270
|
+
const tickers = this.parseTickers(rawTickers, symbols, params);
|
|
2271
|
+
return this.filterByArrayTickers(tickers, 'symbol', symbols);
|
|
2270
2272
|
}
|
|
2271
2273
|
async fetchLastPrices(symbols = undefined, params = {}) {
|
|
2272
2274
|
/**
|
|
@@ -2276,7 +2278,7 @@ export default class htx extends Exchange {
|
|
|
2276
2278
|
* @see https://www.htx.com/en-us/opend/newApiPages/?id=8cb81024-77b5-11ed-9966-0242ac110003 linear swap & linear future
|
|
2277
2279
|
* @see https://www.htx.com/en-us/opend/newApiPages/?id=28c2e8fc-77ae-11ed-9966-0242ac110003 inverse future
|
|
2278
2280
|
* @see https://www.htx.com/en-us/opend/newApiPages/?id=5d517ef5-77b6-11ed-9966-0242ac110003 inverse swap
|
|
2279
|
-
* @param {string[]
|
|
2281
|
+
* @param {string[]} [symbols] unified symbols of the markets to fetch the last prices
|
|
2280
2282
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2281
2283
|
* @returns {object} a dictionary of lastprices structures
|
|
2282
2284
|
*/
|