ccxt 4.2.94__py2.py3-none-any.whl → 4.2.96__py2.py3-none-any.whl

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 (185) hide show
  1. ccxt/__init__.py +2 -2
  2. ccxt/abstract/bitstamp.py +6 -0
  3. ccxt/abstract/coinbase.py +1 -0
  4. ccxt/ace.py +1 -1
  5. ccxt/ascendex.py +1 -1
  6. ccxt/async_support/__init__.py +2 -2
  7. ccxt/async_support/ace.py +1 -1
  8. ccxt/async_support/ascendex.py +1 -1
  9. ccxt/async_support/base/exchange.py +1 -1
  10. ccxt/async_support/bigone.py +1 -1
  11. ccxt/async_support/binance.py +3 -3
  12. ccxt/async_support/bingx.py +1 -1
  13. ccxt/async_support/bit2c.py +1 -1
  14. ccxt/async_support/bitbank.py +1 -1
  15. ccxt/async_support/bitfinex.py +1 -1
  16. ccxt/async_support/bitfinex2.py +1 -1
  17. ccxt/async_support/bitget.py +1 -1
  18. ccxt/async_support/bithumb.py +1 -1
  19. ccxt/async_support/bitmart.py +1 -1
  20. ccxt/async_support/bitmex.py +1 -1
  21. ccxt/async_support/bitopro.py +1 -1
  22. ccxt/async_support/bitrue.py +1 -1
  23. ccxt/async_support/bitso.py +1 -1
  24. ccxt/async_support/bitstamp.py +7 -1
  25. ccxt/async_support/bitteam.py +1 -1
  26. ccxt/async_support/bitvavo.py +1 -1
  27. ccxt/async_support/blockchaincom.py +1 -1
  28. ccxt/async_support/blofin.py +1 -1
  29. ccxt/async_support/btcalpha.py +1 -1
  30. ccxt/async_support/btcbox.py +1 -1
  31. ccxt/async_support/bybit.py +2 -2
  32. ccxt/async_support/cex.py +1 -1
  33. ccxt/async_support/coinbase.py +587 -103
  34. ccxt/async_support/coinbaseinternational.py +1 -1
  35. ccxt/async_support/coinbasepro.py +1 -1
  36. ccxt/async_support/coincheck.py +1 -1
  37. ccxt/async_support/coinex.py +62 -56
  38. ccxt/async_support/coinlist.py +1 -1
  39. ccxt/async_support/coinmate.py +1 -1
  40. ccxt/async_support/coinsph.py +1 -1
  41. ccxt/async_support/cryptocom.py +1 -1
  42. ccxt/async_support/currencycom.py +1 -1
  43. ccxt/async_support/delta.py +1 -1
  44. ccxt/async_support/deribit.py +1 -1
  45. ccxt/async_support/digifinex.py +1 -1
  46. ccxt/async_support/exmo.py +1 -1
  47. ccxt/async_support/gate.py +1 -1
  48. ccxt/async_support/gemini.py +27 -11
  49. ccxt/async_support/hitbtc.py +1 -1
  50. ccxt/async_support/hollaex.py +1 -1
  51. ccxt/async_support/htx.py +117 -116
  52. ccxt/async_support/huobijp.py +1 -1
  53. ccxt/async_support/idex.py +1 -1
  54. ccxt/async_support/indodax.py +1 -1
  55. ccxt/async_support/kraken.py +1 -1
  56. ccxt/async_support/krakenfutures.py +2 -2
  57. ccxt/async_support/kucoin.py +1 -1
  58. ccxt/async_support/kucoinfutures.py +1 -1
  59. ccxt/async_support/latoken.py +1 -1
  60. ccxt/async_support/lbank.py +1 -1
  61. ccxt/async_support/mexc.py +1 -1
  62. ccxt/async_support/ndax.py +1 -1
  63. ccxt/async_support/novadax.py +1 -1
  64. ccxt/async_support/oceanex.py +1 -1
  65. ccxt/async_support/okcoin.py +1 -1
  66. ccxt/async_support/okx.py +42 -42
  67. ccxt/async_support/onetrading.py +1 -1
  68. ccxt/async_support/p2b.py +1 -1
  69. ccxt/async_support/phemex.py +1 -1
  70. ccxt/async_support/poloniex.py +1 -1
  71. ccxt/async_support/poloniexfutures.py +1 -1
  72. ccxt/async_support/probit.py +1 -1
  73. ccxt/async_support/timex.py +1 -1
  74. ccxt/async_support/tokocrypto.py +1 -1
  75. ccxt/async_support/tradeogre.py +1 -1
  76. ccxt/async_support/upbit.py +2 -2
  77. ccxt/async_support/wavesexchange.py +1 -1
  78. ccxt/async_support/whitebit.py +1 -1
  79. ccxt/async_support/woo.py +1 -1
  80. ccxt/async_support/yobit.py +1 -1
  81. ccxt/async_support/zonda.py +1 -1
  82. ccxt/base/errors.py +7 -7
  83. ccxt/base/exchange.py +2 -2
  84. ccxt/bigone.py +1 -1
  85. ccxt/binance.py +3 -3
  86. ccxt/bingx.py +1 -1
  87. ccxt/bit2c.py +1 -1
  88. ccxt/bitbank.py +1 -1
  89. ccxt/bitfinex.py +1 -1
  90. ccxt/bitfinex2.py +1 -1
  91. ccxt/bitget.py +1 -1
  92. ccxt/bithumb.py +1 -1
  93. ccxt/bitmart.py +1 -1
  94. ccxt/bitmex.py +1 -1
  95. ccxt/bitopro.py +1 -1
  96. ccxt/bitrue.py +1 -1
  97. ccxt/bitso.py +1 -1
  98. ccxt/bitstamp.py +7 -1
  99. ccxt/bitteam.py +1 -1
  100. ccxt/bitvavo.py +1 -1
  101. ccxt/blockchaincom.py +1 -1
  102. ccxt/blofin.py +1 -1
  103. ccxt/btcalpha.py +1 -1
  104. ccxt/btcbox.py +1 -1
  105. ccxt/bybit.py +2 -2
  106. ccxt/cex.py +1 -1
  107. ccxt/coinbase.py +587 -103
  108. ccxt/coinbaseinternational.py +1 -1
  109. ccxt/coinbasepro.py +1 -1
  110. ccxt/coincheck.py +1 -1
  111. ccxt/coinex.py +62 -56
  112. ccxt/coinlist.py +1 -1
  113. ccxt/coinmate.py +1 -1
  114. ccxt/coinsph.py +1 -1
  115. ccxt/cryptocom.py +1 -1
  116. ccxt/currencycom.py +1 -1
  117. ccxt/delta.py +1 -1
  118. ccxt/deribit.py +1 -1
  119. ccxt/digifinex.py +1 -1
  120. ccxt/exmo.py +1 -1
  121. ccxt/gate.py +1 -1
  122. ccxt/gemini.py +27 -11
  123. ccxt/hitbtc.py +1 -1
  124. ccxt/hollaex.py +1 -1
  125. ccxt/htx.py +117 -116
  126. ccxt/huobijp.py +1 -1
  127. ccxt/idex.py +1 -1
  128. ccxt/indodax.py +1 -1
  129. ccxt/kraken.py +1 -1
  130. ccxt/krakenfutures.py +2 -2
  131. ccxt/kucoin.py +1 -1
  132. ccxt/kucoinfutures.py +1 -1
  133. ccxt/latoken.py +1 -1
  134. ccxt/lbank.py +1 -1
  135. ccxt/mexc.py +1 -1
  136. ccxt/ndax.py +1 -1
  137. ccxt/novadax.py +1 -1
  138. ccxt/oceanex.py +1 -1
  139. ccxt/okcoin.py +1 -1
  140. ccxt/okx.py +42 -42
  141. ccxt/onetrading.py +1 -1
  142. ccxt/p2b.py +1 -1
  143. ccxt/phemex.py +1 -1
  144. ccxt/poloniex.py +1 -1
  145. ccxt/poloniexfutures.py +1 -1
  146. ccxt/pro/__init__.py +1 -1
  147. ccxt/pro/ascendex.py +1 -1
  148. ccxt/pro/bitfinex2.py +1 -1
  149. ccxt/pro/bitget.py +1 -1
  150. ccxt/pro/bitmart.py +1 -1
  151. ccxt/pro/bitmex.py +1 -1
  152. ccxt/pro/bitstamp.py +1 -1
  153. ccxt/pro/bitvavo.py +1 -1
  154. ccxt/pro/blockchaincom.py +1 -1
  155. ccxt/pro/bybit.py +1 -1
  156. ccxt/pro/coinbase.py +31 -4
  157. ccxt/pro/coinbaseinternational.py +1 -1
  158. ccxt/pro/coinbasepro.py +1 -1
  159. ccxt/pro/coinex.py +1 -1
  160. ccxt/pro/cryptocom.py +1 -1
  161. ccxt/pro/gate.py +1 -1
  162. ccxt/pro/hitbtc.py +1 -1
  163. ccxt/pro/hollaex.py +1 -1
  164. ccxt/pro/htx.py +1 -1
  165. ccxt/pro/kraken.py +1 -1
  166. ccxt/pro/krakenfutures.py +1 -1
  167. ccxt/pro/okcoin.py +1 -1
  168. ccxt/pro/okx.py +1 -1
  169. ccxt/pro/poloniex.py +1 -1
  170. ccxt/pro/poloniexfutures.py +1 -1
  171. ccxt/pro/whitebit.py +1 -1
  172. ccxt/probit.py +1 -1
  173. ccxt/timex.py +1 -1
  174. ccxt/tokocrypto.py +1 -1
  175. ccxt/tradeogre.py +1 -1
  176. ccxt/upbit.py +2 -2
  177. ccxt/wavesexchange.py +1 -1
  178. ccxt/whitebit.py +1 -1
  179. ccxt/woo.py +1 -1
  180. ccxt/yobit.py +1 -1
  181. ccxt/zonda.py +1 -1
  182. {ccxt-4.2.94.dist-info → ccxt-4.2.96.dist-info}/METADATA +4 -4
  183. {ccxt-4.2.94.dist-info → ccxt-4.2.96.dist-info}/RECORD +185 -185
  184. {ccxt-4.2.94.dist-info → ccxt-4.2.96.dist-info}/WHEEL +0 -0
  185. {ccxt-4.2.94.dist-info → ccxt-4.2.96.dist-info}/top_level.txt +0 -0
ccxt/async_support/htx.py CHANGED
@@ -10,6 +10,7 @@ import hashlib
10
10
  from ccxt.base.types import Account, Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
+ from ccxt.base.errors import AuthenticationError
13
14
  from ccxt.base.errors import PermissionDenied
14
15
  from ccxt.base.errors import AccountNotEnabled
15
16
  from ccxt.base.errors import ArgumentsRequired
@@ -19,12 +20,11 @@ from ccxt.base.errors import InsufficientFunds
19
20
  from ccxt.base.errors import InvalidOrder
20
21
  from ccxt.base.errors import OrderNotFound
21
22
  from ccxt.base.errors import NotSupported
22
- from ccxt.base.errors import NetworkError
23
+ from ccxt.base.errors import OperationFailed
23
24
  from ccxt.base.errors import RateLimitExceeded
24
25
  from ccxt.base.errors import ExchangeNotAvailable
25
26
  from ccxt.base.errors import OnMaintenance
26
27
  from ccxt.base.errors import RequestTimeout
27
- from ccxt.base.errors import AuthenticationError
28
28
  from ccxt.base.decimal_to_precision import TRUNCATE
29
29
  from ccxt.base.decimal_to_precision import TICK_SIZE
30
30
  from ccxt.base.precise import Precise
@@ -959,14 +959,8 @@ class htx(Exchange, ImplicitAPI):
959
959
  'fetchMarkets': {
960
960
  'types': {
961
961
  'spot': True,
962
- 'future': {
963
- 'linear': True,
964
- 'inverse': True,
965
- },
966
- 'swap': {
967
- 'linear': True,
968
- 'inverse': True,
969
- },
962
+ 'linear': True,
963
+ 'inverse': True,
970
964
  },
971
965
  },
972
966
  'fetchOHLCV': {
@@ -1610,52 +1604,41 @@ class htx(Exchange, ImplicitAPI):
1610
1604
  :param dict [params]: extra parameters specific to the exchange API endpoint
1611
1605
  :returns dict[]: an array of objects representing market data
1612
1606
  """
1613
- options = self.safe_value(self.options, 'fetchMarkets', {})
1614
- types = self.safe_value(options, 'types', {})
1607
+ types = None
1608
+ types, params = self.handle_option_and_params(params, 'fetchMarkets', 'types', {})
1615
1609
  allMarkets = []
1616
1610
  promises = []
1617
1611
  keys = list(types.keys())
1618
1612
  for i in range(0, len(keys)):
1619
- type = keys[i]
1620
- value = self.safe_value(types, type)
1621
- if value is True:
1622
- promises.append(self.fetch_markets_by_type_and_sub_type(type, None, params))
1623
- elif value:
1624
- subKeys = list(value.keys())
1625
- for j in range(0, len(subKeys)):
1626
- subType = subKeys[j]
1627
- subValue = self.safe_value(value, subType)
1628
- if subValue:
1629
- promises.append(self.fetch_markets_by_type_and_sub_type(type, subType, params))
1613
+ key = keys[i]
1614
+ if self.safe_bool(types, key):
1615
+ if key == 'spot':
1616
+ promises.append(self.fetch_markets_by_type_and_sub_type('spot', None, params))
1617
+ elif key == 'linear':
1618
+ promises.append(self.fetch_markets_by_type_and_sub_type(None, 'linear', params))
1619
+ elif key == 'inverse':
1620
+ promises.append(self.fetch_markets_by_type_and_sub_type('swap', 'inverse', params))
1621
+ promises.append(self.fetch_markets_by_type_and_sub_type('future', 'inverse', params))
1630
1622
  promises = await asyncio.gather(*promises)
1631
1623
  for i in range(0, len(promises)):
1632
1624
  allMarkets = self.array_concat(allMarkets, promises[i])
1633
1625
  return allMarkets
1634
1626
 
1635
1627
  async def fetch_markets_by_type_and_sub_type(self, type, subType, params={}):
1636
- query = self.omit(params, ['type', 'subType'])
1637
- spot = (type == 'spot')
1638
- contract = (type != 'spot')
1639
- future = (type == 'future')
1640
- swap = (type == 'swap')
1641
- linear = None
1642
- inverse = None
1628
+ isSpot = (type == 'spot')
1643
1629
  request = {}
1644
1630
  response = None
1645
- if contract:
1646
- linear = (subType == 'linear')
1647
- inverse = (subType == 'inverse')
1648
- if linear:
1649
- if future:
1650
- request['business_type'] = 'futures'
1651
- response = await self.contractPublicGetLinearSwapApiV1SwapContractInfo(self.extend(request, query))
1652
- elif inverse:
1653
- if future:
1654
- response = await self.contractPublicGetApiV1ContractContractInfo(self.extend(request, query))
1655
- elif swap:
1656
- response = await self.contractPublicGetSwapApiV1SwapContractInfo(self.extend(request, query))
1631
+ if not isSpot:
1632
+ if subType == 'linear':
1633
+ request['business_type'] = 'all' # override default to fetch all linear markets
1634
+ response = await self.contractPublicGetLinearSwapApiV1SwapContractInfo(self.extend(request, params))
1635
+ elif subType == 'inverse':
1636
+ if type == 'future':
1637
+ response = await self.contractPublicGetApiV1ContractContractInfo(self.extend(request, params))
1638
+ elif type == 'swap':
1639
+ response = await self.contractPublicGetSwapApiV1SwapContractInfo(self.extend(request, params))
1657
1640
  else:
1658
- response = await self.spotPublicGetV1CommonSymbols(self.extend(request, query))
1641
+ response = await self.spotPublicGetV1CommonSymbols(self.extend(request, params))
1659
1642
  #
1660
1643
  # spot
1661
1644
  #
@@ -1694,75 +1677,58 @@ class htx(Exchange, ImplicitAPI):
1694
1677
  # ]
1695
1678
  # }
1696
1679
  #
1697
- # inverse future
1680
+ # inverse(swap & future)
1698
1681
  #
1699
1682
  # {
1700
1683
  # "status":"ok",
1701
1684
  # "data":[
1702
1685
  # {
1703
1686
  # "symbol":"BTC",
1704
- # "contract_code":"BTC211126",
1705
- # "contract_type":"self_week",
1706
- # "contract_size":100.000000000000000000,
1707
- # "price_tick":0.010000000000000000,
1708
- # "delivery_date":"20211126",
1709
- # "delivery_time":"1637913600000",
1687
+ # "contract_code":"BTC211126", #/ BTC-USD in swap
1688
+ # "contract_type":"self_week", # only in future
1689
+ # "contract_size":100,
1690
+ # "price_tick":0.1,
1691
+ # "delivery_date":"20211126", # only in future
1692
+ # "delivery_time":"1637913600000", # empty in swap
1710
1693
  # "create_date":"20211112",
1711
1694
  # "contract_status":1,
1712
- # "settlement_time":"1637481600000"
1695
+ # "settlement_time":"1637481600000" # only in future
1696
+ # "settlement_date":"16xxxxxxxxxxx" # only in swap
1713
1697
  # },
1698
+ # ...
1714
1699
  # ],
1715
1700
  # "ts":1637474595140
1716
1701
  # }
1717
1702
  #
1718
- # linear futures
1703
+ # linear(swap & future)
1719
1704
  #
1720
1705
  # {
1721
1706
  # "status":"ok",
1722
1707
  # "data":[
1723
1708
  # {
1724
1709
  # "symbol":"BTC",
1725
- # "contract_code":"BTC-USDT-211231",
1726
- # "contract_size":0.001000000000000000,
1727
- # "price_tick":0.100000000000000000,
1728
- # "delivery_date":"20211231",
1729
- # "delivery_time":"1640937600000",
1710
+ # "contract_code":"BTC-USDT-211231", # or "BTC-USDT" in swap
1711
+ # "contract_size":0.001,
1712
+ # "price_tick":0.1,
1713
+ # "delivery_date":"20211231", # empty in swap
1714
+ # "delivery_time":"1640937600000", # empty in swap
1730
1715
  # "create_date":"20211228",
1731
1716
  # "contract_status":1,
1732
1717
  # "settlement_date":"1640764800000",
1733
- # "support_margin_mode":"cross",
1734
- # "business_type":"futures",
1718
+ # "support_margin_mode":"cross", # "all" or "cross"
1719
+ # "business_type":"futures", # "swap" or "futures"
1735
1720
  # "pair":"BTC-USDT",
1736
- # "contract_type":"self_week" # next_week, quarter
1737
- # },
1721
+ # "contract_type":"self_week", # "swap", "self_week", "next_week", "quarter"
1722
+ # "trade_partition":"USDT",
1723
+ # }
1738
1724
  # ],
1739
1725
  # "ts":1640736207263
1740
1726
  # }
1741
1727
  #
1742
- # swaps
1743
- #
1744
- # {
1745
- # "status":"ok",
1746
- # "data":[
1747
- # {
1748
- # "symbol":"BTC",
1749
- # "contract_code":"BTC-USDT",
1750
- # "contract_size":0.001000000000000000,
1751
- # "price_tick":0.100000000000000000,
1752
- # "delivery_time":"",
1753
- # "create_date":"20201021",
1754
- # "contract_status":1,
1755
- # "settlement_date":"1637481600000",
1756
- # "support_margin_mode":"all", # isolated
1757
- # },
1758
- # ],
1759
- # "ts":1637474774467
1760
- # }
1761
- #
1762
- markets = self.safe_value(response, 'data', [])
1728
+ markets = self.safe_list(response, 'data', [])
1763
1729
  numMarkets = len(markets)
1764
1730
  if numMarkets < 1:
1765
- raise NetworkError(self.id + ' fetchMarkets() returned an empty response: ' + self.json(markets))
1731
+ raise OperationFailed(self.id + ' fetchMarkets() returned an empty response: ' + self.json(response))
1766
1732
  result = []
1767
1733
  for i in range(0, len(markets)):
1768
1734
  market = markets[i]
@@ -1771,15 +1737,30 @@ class htx(Exchange, ImplicitAPI):
1771
1737
  settleId = None
1772
1738
  id = None
1773
1739
  lowercaseId = None
1740
+ contract = ('contract_code' in market)
1741
+ spot = not contract
1742
+ swap = False
1743
+ future = False
1744
+ linear = None
1745
+ inverse = None
1746
+ # check if parsed market is contract
1774
1747
  if contract:
1775
1748
  id = self.safe_string(market, 'contract_code')
1776
1749
  lowercaseId = id.lower()
1750
+ delivery_date = self.safe_string(market, 'delivery_date')
1751
+ business_type = self.safe_string(market, 'business_type')
1752
+ future = delivery_date is not None
1753
+ swap = not future
1754
+ linear = business_type is not None
1755
+ inverse = not linear
1777
1756
  if swap:
1757
+ type = 'swap'
1778
1758
  parts = id.split('-')
1779
1759
  baseId = self.safe_string_lower(market, 'symbol')
1780
1760
  quoteId = self.safe_string_lower(parts, 1)
1781
1761
  settleId = baseId if inverse else quoteId
1782
1762
  elif future:
1763
+ type = 'future'
1783
1764
  baseId = self.safe_string_lower(market, 'symbol')
1784
1765
  if inverse:
1785
1766
  quoteId = 'USD'
@@ -1790,6 +1771,7 @@ class htx(Exchange, ImplicitAPI):
1790
1771
  quoteId = self.safe_string_lower(parts, 1)
1791
1772
  settleId = quoteId
1792
1773
  else:
1774
+ type = 'spot'
1793
1775
  baseId = self.safe_string(market, 'base-currency')
1794
1776
  quoteId = self.safe_string(market, 'quote-currency')
1795
1777
  id = baseId + quoteId
@@ -1912,6 +1894,40 @@ class htx(Exchange, ImplicitAPI):
1912
1894
  })
1913
1895
  return result
1914
1896
 
1897
+ def try_get_symbol_from_future_markets(self, symbolOrMarketId: str):
1898
+ if symbolOrMarketId in self.markets:
1899
+ return symbolOrMarketId
1900
+ # only on "future" market type(inverse & linear), market-id differs between "fetchMarkets" and "fetchTicker"
1901
+ # so we have to create a mapping
1902
+ # - market-id from fetchMarkts: `BTC-USDT-240419`(linear future) or `BTC240412`(inverse future)
1903
+ # - market-id from fetchTciker[s]: `BTC-USDT-CW` (linear future) or `BTC_CW` (inverse future)
1904
+ if not ('futureMarketIdsForSymbols' in self.options):
1905
+ self.options['futureMarketIdsForSymbols'] = {}
1906
+ futureMarketIdsForSymbols = self.safe_dict(self.options, 'futureMarketIdsForSymbols', {})
1907
+ if symbolOrMarketId in futureMarketIdsForSymbols:
1908
+ return futureMarketIdsForSymbols[symbolOrMarketId]
1909
+ futureMarkets = self.filter_by(self.markets, 'future', True)
1910
+ futuresCharsMaps = {
1911
+ 'this_week': 'CW',
1912
+ 'next_week': 'NW',
1913
+ 'quarter': 'CQ',
1914
+ 'next_quarter': 'NQ',
1915
+ }
1916
+ for i in range(0, len(futureMarkets)):
1917
+ market = futureMarkets[i]
1918
+ info = self.safe_value(market, 'info', {})
1919
+ contractType = self.safe_string(info, 'contract_type')
1920
+ contractSuffix = futuresCharsMaps[contractType]
1921
+ # see comment on formats a bit above
1922
+ constructedId = market['base'] + '-' + market['quote'] + '-' + contractSuffix if market['linear'] else market['base'] + '_' + contractSuffix
1923
+ if constructedId == symbolOrMarketId:
1924
+ symbol = market['symbol']
1925
+ self.options['futureMarketIdsForSymbols'][symbolOrMarketId] = symbol
1926
+ return symbol
1927
+ # if not found, just save it to avoid unnecessary future iterations
1928
+ self.options['futureMarketIdsForSymbols'][symbolOrMarketId] = symbolOrMarketId
1929
+ return symbolOrMarketId
1930
+
1915
1931
  def parse_ticker(self, ticker, market: Market = None) -> Ticker:
1916
1932
  #
1917
1933
  # fetchTicker
@@ -1960,6 +1976,7 @@ class htx(Exchange, ImplicitAPI):
1960
1976
  #
1961
1977
  marketId = self.safe_string_2(ticker, 'symbol', 'contract_code')
1962
1978
  symbol = self.safe_symbol(marketId, market)
1979
+ symbol = self.try_get_symbol_from_future_markets(symbol)
1963
1980
  timestamp = self.safe_integer_2(ticker, 'ts', 'quoteTime')
1964
1981
  bid = None
1965
1982
  bidVolume = None
@@ -2087,7 +2104,7 @@ class htx(Exchange, ImplicitAPI):
2087
2104
  :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-a-batch-of-market-data-overview
2088
2105
  :see: https://huobiapi.github.io/docs/dm/v1/en/#get-a-batch-of-market-data-overview
2089
2106
  :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-a-batch-of-market-data-overview-v2
2090
- :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
2107
+ :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
2091
2108
  :param dict [params]: extra parameters specific to the exchange API endpoint
2092
2109
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
2093
2110
  """
@@ -2097,27 +2114,37 @@ class htx(Exchange, ImplicitAPI):
2097
2114
  market = None
2098
2115
  if first is not None:
2099
2116
  market = self.market(first)
2117
+ isSubTypeRequested = ('subType' in params) or ('business_type' in params)
2100
2118
  type = None
2101
2119
  subType = None
2102
2120
  type, params = self.handle_market_type_and_params('fetchTickers', market, params)
2103
2121
  subType, params = self.handle_sub_type_and_params('fetchTickers', market, params)
2104
2122
  request = {}
2123
+ isSpot = (type == 'spot')
2105
2124
  future = (type == 'future')
2106
2125
  swap = (type == 'swap')
2107
2126
  linear = (subType == 'linear')
2108
2127
  inverse = (subType == 'inverse')
2109
- params = self.omit(params, ['type', 'subType'])
2110
2128
  response = None
2111
- if future or swap:
2129
+ if not isSpot or isSubTypeRequested:
2112
2130
  if linear:
2131
+ # independently of type, supports calling all linear symbols i.e. fetchTickers(None, {subType:'linear'})
2113
2132
  if future:
2114
2133
  request['business_type'] = 'futures'
2134
+ elif swap:
2135
+ request['business_type'] = 'swap'
2136
+ else:
2137
+ request['business_type'] = 'all'
2115
2138
  response = await self.contractPublicGetLinearSwapExMarketDetailBatchMerged(self.extend(request, params))
2116
2139
  elif inverse:
2117
2140
  if future:
2118
2141
  response = await self.contractPublicGetMarketDetailBatchMerged(self.extend(request, params))
2119
2142
  elif swap:
2120
2143
  response = await self.contractPublicGetSwapExMarketDetailBatchMerged(self.extend(request, params))
2144
+ else:
2145
+ raise NotSupported(self.id + ' fetchTickers() you have to set params["type"] to either "swap" or "future" for inverse contracts')
2146
+ else:
2147
+ raise NotSupported(self.id + ' fetchTickers() you have to set params["subType"] to either "linear" or "inverse" for contracts')
2121
2148
  else:
2122
2149
  response = await self.spotPublicGetMarketTickers(self.extend(request, params))
2123
2150
  #
@@ -2170,35 +2197,9 @@ class htx(Exchange, ImplicitAPI):
2170
2197
  # "ts":1637504679376
2171
2198
  # }
2172
2199
  #
2173
- tickers = self.safe_value_2(response, 'data', 'ticks', [])
2174
- timestamp = self.safe_integer(response, 'ts')
2175
- result = {}
2176
- for i in range(0, len(tickers)):
2177
- ticker = self.parse_ticker(tickers[i])
2178
- # the market ids for linear futures are non-standard and differ from all the other endpoints
2179
- # we are doing a linear-matching here
2180
- if future and linear:
2181
- for j in range(0, len(self.symbols)):
2182
- symbolInner = self.symbols[j]
2183
- marketInner = self.market(symbolInner)
2184
- contractType = self.safe_string(marketInner['info'], 'contract_type')
2185
- if (contractType == 'this_week') and (ticker['symbol'] == (marketInner['baseId'] + '-' + marketInner['quoteId'] + '-CW')):
2186
- ticker['symbol'] = marketInner['symbol']
2187
- break
2188
- elif (contractType == 'next_week') and (ticker['symbol'] == (marketInner['baseId'] + '-' + marketInner['quoteId'] + '-NW')):
2189
- ticker['symbol'] = marketInner['symbol']
2190
- break
2191
- elif (contractType == 'this_quarter') and (ticker['symbol'] == (marketInner['baseId'] + '-' + marketInner['quoteId'] + '-CQ')):
2192
- ticker['symbol'] = marketInner['symbol']
2193
- break
2194
- elif (contractType == 'next_quarter') and (ticker['symbol'] == (marketInner['baseId'] + '-' + marketInner['quoteId'] + '-NQ')):
2195
- ticker['symbol'] = marketInner['symbol']
2196
- break
2197
- symbol = ticker['symbol']
2198
- ticker['timestamp'] = timestamp
2199
- ticker['datetime'] = self.iso8601(timestamp)
2200
- result[symbol] = ticker
2201
- return self.filter_by_array_tickers(result, 'symbol', symbols)
2200
+ rawTickers = self.safe_list_2(response, 'data', 'ticks', [])
2201
+ tickers = self.parse_tickers(rawTickers, symbols, params)
2202
+ return self.filter_by_array_tickers(tickers, 'symbol', symbols)
2202
2203
 
2203
2204
  async def fetch_last_prices(self, symbols: Strings = None, params={}):
2204
2205
  """
@@ -2206,7 +2207,7 @@ class htx(Exchange, ImplicitAPI):
2206
2207
  :see: https://www.htx.com/en-us/opend/newApiPages/?id=8cb81024-77b5-11ed-9966-0242ac110003 linear swap & linear future
2207
2208
  :see: https://www.htx.com/en-us/opend/newApiPages/?id=28c2e8fc-77ae-11ed-9966-0242ac110003 inverse future
2208
2209
  :see: https://www.htx.com/en-us/opend/newApiPages/?id=5d517ef5-77b6-11ed-9966-0242ac110003 inverse swap
2209
- :param str[]|None symbols: unified symbols of the markets to fetch the last prices
2210
+ :param str[] [symbols]: unified symbols of the markets to fetch the last prices
2210
2211
  :param dict [params]: extra parameters specific to the exchange API endpoint
2211
2212
  :returns dict: a dictionary of lastprices structures
2212
2213
  """
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Account, Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import PermissionDenied
13
14
  from ccxt.base.errors import ArgumentsRequired
14
15
  from ccxt.base.errors import BadRequest
@@ -21,7 +22,6 @@ from ccxt.base.errors import NetworkError
21
22
  from ccxt.base.errors import ExchangeNotAvailable
22
23
  from ccxt.base.errors import OnMaintenance
23
24
  from ccxt.base.errors import RequestTimeout
24
- from ccxt.base.errors import AuthenticationError
25
25
  from ccxt.base.decimal_to_precision import TRUNCATE
26
26
  from ccxt.base.decimal_to_precision import TICK_SIZE
27
27
  from ccxt.base.precise import Precise
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import BadRequest
13
14
  from ccxt.base.errors import InsufficientFunds
14
15
  from ccxt.base.errors import InvalidAddress
@@ -16,7 +17,6 @@ from ccxt.base.errors import InvalidOrder
16
17
  from ccxt.base.errors import NotSupported
17
18
  from ccxt.base.errors import DDoSProtection
18
19
  from ccxt.base.errors import ExchangeNotAvailable
19
- from ccxt.base.errors import AuthenticationError
20
20
  from ccxt.base.decimal_to_precision import ROUND
21
21
  from ccxt.base.decimal_to_precision import TRUNCATE
22
22
  from ccxt.base.decimal_to_precision import DECIMAL_PLACES
@@ -10,12 +10,12 @@ import math
10
10
  from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
+ from ccxt.base.errors import AuthenticationError
13
14
  from ccxt.base.errors import ArgumentsRequired
14
15
  from ccxt.base.errors import BadSymbol
15
16
  from ccxt.base.errors import InsufficientFunds
16
17
  from ccxt.base.errors import InvalidOrder
17
18
  from ccxt.base.errors import OrderNotFound
18
- from ccxt.base.errors import AuthenticationError
19
19
  from ccxt.base.decimal_to_precision import TICK_SIZE
20
20
 
21
21
 
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Balances, Currencies, Currency, IndexType, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import PermissionDenied
13
14
  from ccxt.base.errors import AccountSuspended
14
15
  from ccxt.base.errors import ArgumentsRequired
@@ -25,7 +26,6 @@ from ccxt.base.errors import RateLimitExceeded
25
26
  from ccxt.base.errors import ExchangeNotAvailable
26
27
  from ccxt.base.errors import OnMaintenance
27
28
  from ccxt.base.errors import InvalidNonce
28
- from ccxt.base.errors import AuthenticationError
29
29
  from ccxt.base.decimal_to_precision import TRUNCATE
30
30
  from ccxt.base.decimal_to_precision import TICK_SIZE
31
31
  from ccxt.base.precise import Precise
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Balances, Currency, Int, Leverage, Leverages, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import ArgumentsRequired
13
14
  from ccxt.base.errors import BadRequest
14
15
  from ccxt.base.errors import InsufficientFunds
@@ -17,12 +18,11 @@ from ccxt.base.errors import OrderNotFound
17
18
  from ccxt.base.errors import OrderImmediatelyFillable
18
19
  from ccxt.base.errors import OrderNotFillable
19
20
  from ccxt.base.errors import DuplicateOrderId
21
+ from ccxt.base.errors import ContractUnavailable
20
22
  from ccxt.base.errors import DDoSProtection
21
23
  from ccxt.base.errors import RateLimitExceeded
22
24
  from ccxt.base.errors import ExchangeNotAvailable
23
25
  from ccxt.base.errors import InvalidNonce
24
- from ccxt.base.errors import AuthenticationError
25
- from ccxt.base.errors import ContractUnavailable
26
26
  from ccxt.base.decimal_to_precision import TICK_SIZE
27
27
  from ccxt.base.precise import Precise
28
28
 
@@ -12,6 +12,7 @@ import json
12
12
  from ccxt.base.types import Account, Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
13
13
  from typing import List
14
14
  from ccxt.base.errors import ExchangeError
15
+ from ccxt.base.errors import AuthenticationError
15
16
  from ccxt.base.errors import PermissionDenied
16
17
  from ccxt.base.errors import AccountSuspended
17
18
  from ccxt.base.errors import ArgumentsRequired
@@ -25,7 +26,6 @@ from ccxt.base.errors import NotSupported
25
26
  from ccxt.base.errors import RateLimitExceeded
26
27
  from ccxt.base.errors import ExchangeNotAvailable
27
28
  from ccxt.base.errors import InvalidNonce
28
- from ccxt.base.errors import AuthenticationError
29
29
  from ccxt.base.decimal_to_precision import TRUNCATE
30
30
  from ccxt.base.decimal_to_precision import TICK_SIZE
31
31
  from ccxt.base.precise import Precise
@@ -7,6 +7,7 @@ from ccxt.async_support.kucoin import kucoin
7
7
  from ccxt.abstract.kucoinfutures import ImplicitAPI
8
8
  from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
9
  from typing import List
10
+ from ccxt.base.errors import AuthenticationError
10
11
  from ccxt.base.errors import PermissionDenied
11
12
  from ccxt.base.errors import AccountSuspended
12
13
  from ccxt.base.errors import ArgumentsRequired
@@ -18,7 +19,6 @@ from ccxt.base.errors import NotSupported
18
19
  from ccxt.base.errors import RateLimitExceeded
19
20
  from ccxt.base.errors import ExchangeNotAvailable
20
21
  from ccxt.base.errors import InvalidNonce
21
- from ccxt.base.errors import AuthenticationError
22
22
  from ccxt.base.decimal_to_precision import TICK_SIZE
23
23
  from ccxt.base.precise import Precise
24
24
 
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import PermissionDenied
13
14
  from ccxt.base.errors import AccountSuspended
14
15
  from ccxt.base.errors import ArgumentsRequired
@@ -20,7 +21,6 @@ from ccxt.base.errors import NotSupported
20
21
  from ccxt.base.errors import RateLimitExceeded
21
22
  from ccxt.base.errors import ExchangeNotAvailable
22
23
  from ccxt.base.errors import InvalidNonce
23
- from ccxt.base.errors import AuthenticationError
24
24
  from ccxt.base.decimal_to_precision import TICK_SIZE
25
25
 
26
26
 
@@ -10,6 +10,7 @@ import hashlib
10
10
  from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
+ from ccxt.base.errors import AuthenticationError
13
14
  from ccxt.base.errors import PermissionDenied
14
15
  from ccxt.base.errors import ArgumentsRequired
15
16
  from ccxt.base.errors import BadRequest
@@ -21,7 +22,6 @@ from ccxt.base.errors import DuplicateOrderId
21
22
  from ccxt.base.errors import NotSupported
22
23
  from ccxt.base.errors import RateLimitExceeded
23
24
  from ccxt.base.errors import InvalidNonce
24
- from ccxt.base.errors import AuthenticationError
25
25
  from ccxt.base.decimal_to_precision import TICK_SIZE
26
26
  from ccxt.base.precise import Precise
27
27
 
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Account, Balances, Currencies, Currency, IndexType, Int, Leverage, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import PermissionDenied
13
14
  from ccxt.base.errors import AccountSuspended
14
15
  from ccxt.base.errors import ArgumentsRequired
@@ -20,7 +21,6 @@ from ccxt.base.errors import InvalidOrder
20
21
  from ccxt.base.errors import NotSupported
21
22
  from ccxt.base.errors import OnMaintenance
22
23
  from ccxt.base.errors import InvalidNonce
23
- from ccxt.base.errors import AuthenticationError
24
24
  from ccxt.base.decimal_to_precision import TICK_SIZE
25
25
  from ccxt.base.precise import Precise
26
26
 
@@ -10,10 +10,10 @@ import json
10
10
  from ccxt.base.types import Account, Balances, Currencies, Currency, IndexType, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, Transaction
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
+ from ccxt.base.errors import AuthenticationError
13
14
  from ccxt.base.errors import BadSymbol
14
15
  from ccxt.base.errors import InsufficientFunds
15
16
  from ccxt.base.errors import OrderNotFound
16
- from ccxt.base.errors import AuthenticationError
17
17
  from ccxt.base.decimal_to_precision import TICK_SIZE
18
18
  from ccxt.base.precise import Precise
19
19
 
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Account, Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import PermissionDenied
13
14
  from ccxt.base.errors import AccountNotEnabled
14
15
  from ccxt.base.errors import AccountSuspended
@@ -21,7 +22,6 @@ from ccxt.base.errors import OrderNotFound
21
22
  from ccxt.base.errors import CancelPending
22
23
  from ccxt.base.errors import RateLimitExceeded
23
24
  from ccxt.base.errors import OnMaintenance
24
- from ccxt.base.errors import AuthenticationError
25
25
  from ccxt.base.decimal_to_precision import TICK_SIZE
26
26
  from ccxt.base.precise import Precise
27
27
 
@@ -8,13 +8,13 @@ from ccxt.abstract.oceanex import ImplicitAPI
8
8
  from ccxt.base.types import Balances, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
+ from ccxt.base.errors import AuthenticationError
11
12
  from ccxt.base.errors import PermissionDenied
12
13
  from ccxt.base.errors import ArgumentsRequired
13
14
  from ccxt.base.errors import BadRequest
14
15
  from ccxt.base.errors import InsufficientFunds
15
16
  from ccxt.base.errors import InvalidOrder
16
17
  from ccxt.base.errors import OrderNotFound
17
- from ccxt.base.errors import AuthenticationError
18
18
  from ccxt.base.decimal_to_precision import TICK_SIZE
19
19
 
20
20
 
@@ -9,6 +9,7 @@ import hashlib
9
9
  from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
12
13
  from ccxt.base.errors import PermissionDenied
13
14
  from ccxt.base.errors import AccountNotEnabled
14
15
  from ccxt.base.errors import AccountSuspended
@@ -27,7 +28,6 @@ from ccxt.base.errors import ExchangeNotAvailable
27
28
  from ccxt.base.errors import OnMaintenance
28
29
  from ccxt.base.errors import InvalidNonce
29
30
  from ccxt.base.errors import RequestTimeout
30
- from ccxt.base.errors import AuthenticationError
31
31
  from ccxt.base.decimal_to_precision import TICK_SIZE
32
32
  from ccxt.base.precise import Precise
33
33