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