ccxt 4.1.47__py2.py3-none-any.whl → 4.1.49__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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

Files changed (166) hide show
  1. ccxt/__init__.py +3 -1
  2. ccxt/abstract/binance.py +2 -0
  3. ccxt/abstract/binancecoinm.py +2 -0
  4. ccxt/abstract/binanceus.py +2 -0
  5. ccxt/abstract/binanceusdm.py +2 -0
  6. ccxt/abstract/htx.py +541 -0
  7. ccxt/ace.py +2 -2
  8. ccxt/ascendex.py +2 -2
  9. ccxt/async_support/__init__.py +3 -1
  10. ccxt/async_support/ace.py +2 -2
  11. ccxt/async_support/ascendex.py +2 -2
  12. ccxt/async_support/base/exchange.py +1 -1
  13. ccxt/async_support/bigone.py +2 -2
  14. ccxt/async_support/binance.py +5 -3
  15. ccxt/async_support/bingx.py +3 -3
  16. ccxt/async_support/bitbns.py +2 -2
  17. ccxt/async_support/bitfinex.py +2 -2
  18. ccxt/async_support/bitfinex2.py +2 -2
  19. ccxt/async_support/bitget.py +3 -3
  20. ccxt/async_support/bithumb.py +2 -2
  21. ccxt/async_support/bitmart.py +157 -53
  22. ccxt/async_support/bitmex.py +2 -2
  23. ccxt/async_support/bitopro.py +2 -2
  24. ccxt/async_support/bitpanda.py +2 -2
  25. ccxt/async_support/bitrue.py +2 -2
  26. ccxt/async_support/bitstamp.py +2 -2
  27. ccxt/async_support/bittrex.py +2 -2
  28. ccxt/async_support/bitvavo.py +2 -2
  29. ccxt/async_support/blockchaincom.py +2 -2
  30. ccxt/async_support/btcalpha.py +2 -2
  31. ccxt/async_support/btcturk.py +2 -2
  32. ccxt/async_support/bybit.py +2 -2
  33. ccxt/async_support/cex.py +2 -2
  34. ccxt/async_support/coinbase.py +2 -2
  35. ccxt/async_support/coinbasepro.py +2 -2
  36. ccxt/async_support/coinex.py +63 -20
  37. ccxt/async_support/coinfalcon.py +2 -2
  38. ccxt/async_support/coinlist.py +2 -2
  39. ccxt/async_support/coinone.py +2 -2
  40. ccxt/async_support/coinsph.py +2 -2
  41. ccxt/async_support/coinspot.py +2 -2
  42. ccxt/async_support/cryptocom.py +2 -2
  43. ccxt/async_support/currencycom.py +2 -2
  44. ccxt/async_support/delta.py +2 -2
  45. ccxt/async_support/deribit.py +2 -2
  46. ccxt/async_support/digifinex.py +2 -2
  47. ccxt/async_support/exmo.py +2 -2
  48. ccxt/async_support/gate.py +2 -2
  49. ccxt/async_support/gemini.py +3 -3
  50. ccxt/async_support/hitbtc.py +2 -2
  51. ccxt/async_support/hollaex.py +2 -2
  52. ccxt/async_support/htx.py +7853 -0
  53. ccxt/async_support/huobi.py +3 -7846
  54. ccxt/async_support/huobijp.py +2 -2
  55. ccxt/async_support/idex.py +2 -2
  56. ccxt/async_support/indodax.py +2 -2
  57. ccxt/async_support/kraken.py +2 -6
  58. ccxt/async_support/krakenfutures.py +2 -2
  59. ccxt/async_support/kucoin.py +2 -2
  60. ccxt/async_support/kuna.py +2 -2
  61. ccxt/async_support/latoken.py +2 -2
  62. ccxt/async_support/lbank.py +2 -2
  63. ccxt/async_support/lbank2.py +2 -2
  64. ccxt/async_support/luno.py +2 -2
  65. ccxt/async_support/lykke.py +2 -2
  66. ccxt/async_support/mexc.py +23 -23
  67. ccxt/async_support/novadax.py +2 -2
  68. ccxt/async_support/oceanex.py +2 -2
  69. ccxt/async_support/okcoin.py +3 -3
  70. ccxt/async_support/okx.py +3 -3
  71. ccxt/async_support/phemex.py +2 -2
  72. ccxt/async_support/poloniex.py +2 -2
  73. ccxt/async_support/poloniexfutures.py +2 -2
  74. ccxt/async_support/probit.py +2 -2
  75. ccxt/async_support/tidex.py +2 -2
  76. ccxt/async_support/timex.py +4 -4
  77. ccxt/async_support/tokocrypto.py +2 -2
  78. ccxt/async_support/upbit.py +2 -2
  79. ccxt/async_support/wavesexchange.py +2 -2
  80. ccxt/async_support/wazirx.py +2 -2
  81. ccxt/async_support/whitebit.py +2 -2
  82. ccxt/async_support/yobit.py +2 -2
  83. ccxt/async_support/zonda.py +2 -2
  84. ccxt/base/exchange.py +1 -1
  85. ccxt/base/types.py +43 -4
  86. ccxt/bigone.py +2 -2
  87. ccxt/binance.py +5 -3
  88. ccxt/bingx.py +3 -3
  89. ccxt/bitbns.py +2 -2
  90. ccxt/bitfinex.py +2 -2
  91. ccxt/bitfinex2.py +2 -2
  92. ccxt/bitget.py +3 -3
  93. ccxt/bithumb.py +2 -2
  94. ccxt/bitmart.py +157 -53
  95. ccxt/bitmex.py +2 -2
  96. ccxt/bitopro.py +2 -2
  97. ccxt/bitpanda.py +2 -2
  98. ccxt/bitrue.py +2 -2
  99. ccxt/bitstamp.py +2 -2
  100. ccxt/bittrex.py +2 -2
  101. ccxt/bitvavo.py +2 -2
  102. ccxt/blockchaincom.py +2 -2
  103. ccxt/btcalpha.py +2 -2
  104. ccxt/btcturk.py +2 -2
  105. ccxt/bybit.py +2 -2
  106. ccxt/cex.py +2 -2
  107. ccxt/coinbase.py +2 -2
  108. ccxt/coinbasepro.py +2 -2
  109. ccxt/coinex.py +63 -20
  110. ccxt/coinfalcon.py +2 -2
  111. ccxt/coinlist.py +2 -2
  112. ccxt/coinone.py +2 -2
  113. ccxt/coinsph.py +2 -2
  114. ccxt/coinspot.py +2 -2
  115. ccxt/cryptocom.py +2 -2
  116. ccxt/currencycom.py +2 -2
  117. ccxt/delta.py +2 -2
  118. ccxt/deribit.py +2 -2
  119. ccxt/digifinex.py +2 -2
  120. ccxt/exmo.py +2 -2
  121. ccxt/gate.py +2 -2
  122. ccxt/gemini.py +3 -3
  123. ccxt/hitbtc.py +2 -2
  124. ccxt/hollaex.py +2 -2
  125. ccxt/htx.py +7852 -0
  126. ccxt/huobi.py +3 -7845
  127. ccxt/huobijp.py +2 -2
  128. ccxt/idex.py +2 -2
  129. ccxt/indodax.py +2 -2
  130. ccxt/kraken.py +2 -6
  131. ccxt/krakenfutures.py +2 -2
  132. ccxt/kucoin.py +2 -2
  133. ccxt/kuna.py +2 -2
  134. ccxt/latoken.py +2 -2
  135. ccxt/lbank.py +2 -2
  136. ccxt/lbank2.py +2 -2
  137. ccxt/luno.py +2 -2
  138. ccxt/lykke.py +2 -2
  139. ccxt/mexc.py +23 -23
  140. ccxt/novadax.py +2 -2
  141. ccxt/oceanex.py +2 -2
  142. ccxt/okcoin.py +3 -3
  143. ccxt/okx.py +3 -3
  144. ccxt/phemex.py +2 -2
  145. ccxt/poloniex.py +2 -2
  146. ccxt/poloniexfutures.py +2 -2
  147. ccxt/pro/__init__.py +3 -1
  148. ccxt/pro/htx.py +2177 -0
  149. ccxt/pro/huobi.py +4 -2166
  150. ccxt/probit.py +2 -2
  151. ccxt/test/test_async.py +15 -1
  152. ccxt/test/test_sync.py +15 -1
  153. ccxt/tidex.py +2 -2
  154. ccxt/timex.py +4 -4
  155. ccxt/tokocrypto.py +2 -2
  156. ccxt/upbit.py +2 -2
  157. ccxt/wavesexchange.py +2 -2
  158. ccxt/wazirx.py +2 -2
  159. ccxt/whitebit.py +2 -2
  160. ccxt/yobit.py +2 -2
  161. ccxt/zonda.py +2 -2
  162. ccxt-4.1.49.dist-info/METADATA +624 -0
  163. {ccxt-4.1.47.dist-info → ccxt-4.1.49.dist-info}/RECORD +165 -161
  164. ccxt-4.1.47.dist-info/METADATA +0 -624
  165. {ccxt-4.1.47.dist-info → ccxt-4.1.49.dist-info}/WHEEL +0 -0
  166. {ccxt-4.1.47.dist-info → ccxt-4.1.49.dist-info}/top_level.txt +0 -0
ccxt/ace.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.ace import ImplicitAPI
8
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade
8
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade
9
9
  from typing import Optional
10
10
  from typing import List
11
11
  from ccxt.base.errors import BadRequest
@@ -309,7 +309,7 @@ class ace(Exchange, ImplicitAPI):
309
309
  #
310
310
  return self.parse_ticker(ticker, market)
311
311
 
312
- def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
312
+ def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
313
313
  """
314
314
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
315
315
  :see: https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#oapi-api---trade-data
ccxt/ascendex.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.ascendex import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import OrderRequest, Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
9
+ from ccxt.base.types import OrderRequest, Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
10
10
  from typing import Optional
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
@@ -993,7 +993,7 @@ class ascendex(Exchange, ImplicitAPI):
993
993
  data = self.safe_value(response, 'data', {})
994
994
  return self.parse_ticker(data, market)
995
995
 
996
- def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
996
+ def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
997
997
  """
998
998
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
999
999
  :see: https://ascendex.github.io/ascendex-pro-api/#ticker
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.1.47'
7
+ __version__ = '4.1.49'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -121,6 +121,7 @@ from ccxt.async_support.gemini import gemini
121
121
  from ccxt.async_support.hitbtc import hitbtc # noqa: F401
122
122
  from ccxt.async_support.hitbtc3 import hitbtc3 # noqa: F401
123
123
  from ccxt.async_support.hollaex import hollaex # noqa: F401
124
+ from ccxt.async_support.htx import htx # noqa: F401
124
125
  from ccxt.async_support.huobi import huobi # noqa: F401
125
126
  from ccxt.async_support.huobijp import huobijp # noqa: F401
126
127
  from ccxt.async_support.huobipro import huobipro # noqa: F401
@@ -229,6 +230,7 @@ exchanges = [
229
230
  'hitbtc',
230
231
  'hitbtc3',
231
232
  'hollaex',
233
+ 'htx',
232
234
  'huobi',
233
235
  'huobijp',
234
236
  'huobipro',
ccxt/async_support/ace.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.ace import ImplicitAPI
8
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade
8
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade
9
9
  from typing import Optional
10
10
  from typing import List
11
11
  from ccxt.base.errors import BadRequest
@@ -309,7 +309,7 @@ class ace(Exchange, ImplicitAPI):
309
309
  #
310
310
  return self.parse_ticker(ticker, market)
311
311
 
312
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
312
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
313
313
  """
314
314
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
315
315
  :see: https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#oapi-api---trade-data
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.ascendex import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import OrderRequest, Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
9
+ from ccxt.base.types import OrderRequest, Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
10
10
  from typing import Optional
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
@@ -993,7 +993,7 @@ class ascendex(Exchange, ImplicitAPI):
993
993
  data = self.safe_value(response, 'data', {})
994
994
  return self.parse_ticker(data, market)
995
995
 
996
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
996
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
997
997
  """
998
998
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
999
999
  :see: https://ascendex.github.io/ascendex-pro-api/#ticker
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.1.47'
5
+ __version__ = '4.1.49'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bigone import ImplicitAPI
8
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
8
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
9
9
  from typing import Optional
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
@@ -663,7 +663,7 @@ class bigone(Exchange, ImplicitAPI):
663
663
  ticker = self.safe_value(response, 'data', {})
664
664
  return self.parse_ticker(ticker, market)
665
665
 
666
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
666
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
667
667
  """
668
668
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
669
669
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
@@ -8,7 +8,7 @@ from ccxt.abstract.binance import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import json
11
- from ccxt.base.types import OrderRequest, Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
11
+ from ccxt.base.types import OrderRequest, Balances, Market, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
12
12
  from typing import Optional
13
13
  from typing import List
14
14
  from ccxt.base.errors import ExchangeError
@@ -1008,9 +1008,11 @@ class binance(Exchange, ImplicitAPI):
1008
1008
  'um/order': 1, # 1
1009
1009
  'um/conditional/order': 1,
1010
1010
  'um/allOpenOrders': 1, # 1
1011
+ 'um/conditional/allOpenOrders': 1,
1011
1012
  'cm/order': 1, # 1
1012
1013
  'cm/conditional/order': 1,
1013
1014
  'cm/allOpenOrders': 1, # 1
1015
+ 'cm/conditional/allOpenOrders': 1,
1014
1016
  'margin/order': 1, # Weight(IP): 10 => cost = 0.1 * 10 = 1
1015
1017
  'margin/allOpenOrders': 5, # 5
1016
1018
  'margin/orderList': 2, # 2
@@ -2224,7 +2226,7 @@ class binance(Exchange, ImplicitAPI):
2224
2226
  result.append(self.parse_market(markets[i]))
2225
2227
  return result
2226
2228
 
2227
- def parse_market(self, market):
2229
+ def parse_market(self, market) -> Market:
2228
2230
  swap = False
2229
2231
  future = False
2230
2232
  option = False
@@ -3106,7 +3108,7 @@ class binance(Exchange, ImplicitAPI):
3106
3108
  'info': info,
3107
3109
  }
3108
3110
 
3109
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
3111
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
3110
3112
  """
3111
3113
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
3112
3114
  :see: https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics # spot
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bingx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import OrderRequest, Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
10
+ from ccxt.base.types import OrderRequest, Balances, Market, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
11
11
  from typing import Optional
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
@@ -546,7 +546,7 @@ class bingx(Exchange, ImplicitAPI):
546
546
  result.append(self.parse_market(markets[i]))
547
547
  return result
548
548
 
549
- def parse_market(self, market):
549
+ def parse_market(self, market) -> Market:
550
550
  id = self.safe_string(market, 'symbol')
551
551
  symbolParts = id.split('-')
552
552
  baseId = symbolParts[0]
@@ -1210,7 +1210,7 @@ class bingx(Exchange, ImplicitAPI):
1210
1210
  ticker = self.safe_value(data, 0, data)
1211
1211
  return self.parse_ticker(ticker, market)
1212
1212
 
1213
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
1213
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
1214
1214
  """
1215
1215
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
1216
1216
  :see: https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Ticker
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitbns import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
9
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
10
10
  from typing import Optional
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
@@ -378,7 +378,7 @@ class bitbns(Exchange, ImplicitAPI):
378
378
  'info': ticker,
379
379
  }, market)
380
380
 
381
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
381
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
382
382
  """
383
383
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
384
384
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitfinex import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
9
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
10
10
  from typing import Optional
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
@@ -825,7 +825,7 @@ class bitfinex(Exchange, ImplicitAPI):
825
825
  response = await self.publicGetBookSymbol(self.extend(request, params))
826
826
  return self.parse_order_book(response, market['symbol'], None, 'bids', 'asks', 'price', 'amount')
827
827
 
828
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
828
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
829
829
  """
830
830
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
831
831
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitfinex2 import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
9
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
10
10
  from typing import Optional
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
@@ -1075,7 +1075,7 @@ class bitfinex2(Exchange, ImplicitAPI):
1075
1075
  'info': ticker,
1076
1076
  }, market)
1077
1077
 
1078
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
1078
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
1079
1079
  """
1080
1080
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
1081
1081
  :see: https://docs.bitfinex.com/reference/rest-public-tickers
@@ -8,7 +8,7 @@ from ccxt.abstract.bitget import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
10
  import json
11
- from ccxt.base.types import OrderRequest, Balances, Order, OrderBook, OrderSide, OrderType, FundingHistory, Ticker, Trade, Transaction
11
+ from ccxt.base.types import OrderRequest, Balances, Market, Order, OrderBook, OrderSide, OrderType, FundingHistory, Ticker, Tickers, Trade, Transaction
12
12
  from typing import Optional
13
13
  from typing import List
14
14
  from ccxt.base.errors import ExchangeError
@@ -1147,7 +1147,7 @@ class bitget(Exchange, ImplicitAPI):
1147
1147
  result.append(self.parse_market(markets[i]))
1148
1148
  return result
1149
1149
 
1150
- def parse_market(self, market):
1150
+ def parse_market(self, market) -> Market:
1151
1151
  #
1152
1152
  # spot
1153
1153
  #
@@ -2162,7 +2162,7 @@ class bitget(Exchange, ImplicitAPI):
2162
2162
  data = self.safe_value(response, 'data')
2163
2163
  return self.parse_ticker(data, market)
2164
2164
 
2165
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
2165
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
2166
2166
  """
2167
2167
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
2168
2168
  :see: https://bitgetlimited.github.io/apidoc/en/spot/#get-all-tickers
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bithumb import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
9
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
10
10
  from typing import Optional
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
@@ -388,7 +388,7 @@ class bithumb(Exchange, ImplicitAPI):
388
388
  'info': ticker,
389
389
  }, market)
390
390
 
391
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
391
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
392
392
  """
393
393
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
394
394
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitmart import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
9
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
10
10
  from typing import Optional
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
@@ -593,6 +593,7 @@ class bitmart(Exchange, ImplicitAPI):
593
593
  'swap': 'swap',
594
594
  },
595
595
  'createMarketBuyOrderRequiresPrice': True,
596
+ 'brokerId': 'CCXTxBitmart000',
596
597
  },
597
598
  })
598
599
 
@@ -1184,7 +1185,7 @@ class bitmart(Exchange, ImplicitAPI):
1184
1185
  ticker = self.safe_value(tickersById, market['id'])
1185
1186
  return self.parse_ticker(ticker, market)
1186
1187
 
1187
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
1188
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
1188
1189
  """
1189
1190
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
1190
1191
  :see: https://developer-pro.bitmart.com/en/spot/#get-ticker-of-all-pairs-v2
@@ -1910,6 +1911,12 @@ class bitmart(Exchange, ImplicitAPI):
1910
1911
  # "order_id": 2707217580
1911
1912
  # }
1912
1913
  #
1914
+ # swap
1915
+ # "data": {
1916
+ # "order_id": 231116359426639,
1917
+ # "price": "market price"
1918
+ # },
1919
+ #
1913
1920
  # cancelOrder
1914
1921
  #
1915
1922
  # "2707217580" # order id
@@ -1989,6 +1996,9 @@ class bitmart(Exchange, ImplicitAPI):
1989
1996
  if type == 'ioc':
1990
1997
  type = 'limit'
1991
1998
  timeInForce = 'IOC'
1999
+ priceString = self.safe_string(order, 'price')
2000
+ if priceString == 'market price':
2001
+ priceString = None
1992
2002
  return self.safe_order({
1993
2003
  'id': id,
1994
2004
  'clientOrderId': self.safe_string(order, 'client_order_id'),
@@ -2001,7 +2011,7 @@ class bitmart(Exchange, ImplicitAPI):
2001
2011
  'timeInForce': timeInForce,
2002
2012
  'postOnly': postOnly,
2003
2013
  'side': self.parse_order_side(self.safe_string(order, 'side')),
2004
- 'price': self.omit_zero(self.safe_string(order, 'price')),
2014
+ 'price': self.omit_zero(priceString),
2005
2015
  'stopPrice': None,
2006
2016
  'triggerPrice': None,
2007
2017
  'amount': self.omit_zero(self.safe_string(order, 'size')),
@@ -2053,6 +2063,7 @@ class bitmart(Exchange, ImplicitAPI):
2053
2063
  create a trade order
2054
2064
  :see: https://developer-pro.bitmart.com/en/spot/#place-spot-order
2055
2065
  :see: https://developer-pro.bitmart.com/en/spot/#place-margin-order
2066
+ :see: https://developer-pro.bitmart.com/en/futures/#submit-order-signed
2056
2067
  :param str symbol: unified symbol of the market to create an order in
2057
2068
  :param str type: 'market' or 'limit'
2058
2069
  :param str side: 'buy' or 'sell'
@@ -2060,61 +2071,26 @@ class bitmart(Exchange, ImplicitAPI):
2060
2071
  :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2061
2072
  :param dict [params]: extra parameters specific to the bitmart api endpoint
2062
2073
  :param str [params.marginMode]: 'cross' or 'isolated'
2074
+ :param str [params.leverage]: *swap only* leverage level
2075
+ :param str [params.clientOrderId]: client order id of the order
2076
+ :param boolean [params.reduceOnly]: *swap only* reduce only
2077
+ :param boolean [params.postOnly]: make sure the order is posted to the order book and not matched immediately
2063
2078
  :returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
2064
2079
  """
2065
2080
  await self.load_markets()
2066
2081
  market = self.market(symbol)
2067
- request = {}
2068
- timeInForce = self.safe_string(params, 'timeInForce')
2069
- if timeInForce == 'FOK':
2070
- raise InvalidOrder(self.id + ' createOrder() only accepts timeInForce parameter values of IOC or PO')
2071
- mode = self.safe_integer(params, 'mode') # only for swap
2072
- isMarketOrder = type == 'market'
2073
- postOnly = None
2074
- isExchangeSpecificPo = (type == 'limit_maker') or (mode == 4)
2075
- postOnly, params = self.handle_post_only(isMarketOrder, isExchangeSpecificPo, params)
2076
- params = self.omit(params, ['timeInForce', 'postOnly'])
2077
- ioc = ((timeInForce == 'IOC') or (type == 'ioc'))
2078
- isLimitOrder = (type == 'limit') or postOnly or ioc
2079
- method = None
2082
+ result = self.handle_margin_mode_and_params('createOrder', params)
2083
+ marginMode = self.safe_string(result, 0)
2084
+ response = None
2080
2085
  if market['spot']:
2081
- request['symbol'] = market['id']
2082
- request['side'] = side
2083
- request['type'] = type
2084
- method = 'privatePostSpotV2SubmitOrder'
2085
- if isLimitOrder:
2086
- request['size'] = self.amount_to_precision(symbol, amount)
2087
- request['price'] = self.price_to_precision(symbol, price)
2088
- elif isMarketOrder:
2089
- # for market buy it requires the amount of quote currency to spend
2090
- if side == 'buy':
2091
- notional = self.safe_number(params, 'notional')
2092
- createMarketBuyOrderRequiresPrice = self.safe_value(self.options, 'createMarketBuyOrderRequiresPrice', True)
2093
- if createMarketBuyOrderRequiresPrice:
2094
- if price is not None:
2095
- if notional is None:
2096
- amountString = self.number_to_string(amount)
2097
- priceString = self.number_to_string(price)
2098
- notional = self.parse_number(Precise.string_mul(amountString, priceString))
2099
- elif notional is None:
2100
- raise InvalidOrder(self.id + " createOrder() requires the price argument with market buy orders to calculate total order cost(amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = False and supply the total cost value in the 'amount' argument or in the 'notional' extra parameter(the exchange-specific behaviour)")
2101
- else:
2102
- notional = amount if (notional is None) else notional
2103
- request['notional'] = self.decimal_to_precision(notional, TRUNCATE, market['precision']['price'], self.precisionMode)
2104
- elif side == 'sell':
2105
- request['size'] = self.amount_to_precision(symbol, amount)
2106
- elif market['swap']:
2107
- raise NotSupported(self.id + ' createOrder() does not accept swap orders, only spot orders are allowed')
2108
- if postOnly:
2109
- request['type'] = 'limit_maker'
2110
- if ioc:
2111
- request['type'] = 'ioc'
2112
- marginMode, query = self.handle_margin_mode_and_params('createOrder', params)
2113
- if marginMode is not None:
2114
- if marginMode != 'isolated':
2115
- raise NotSupported(self.id + ' only isolated margin is supported')
2116
- method = 'privatePostSpotV1MarginSubmitOrder'
2117
- response = await getattr(self, method)(self.extend(request, query))
2086
+ spotRequest = self.create_spot_order_request(symbol, type, side, amount, price, params)
2087
+ if marginMode == 'isolated':
2088
+ response = await self.privatePostSpotV1MarginSubmitOrder(spotRequest)
2089
+ else:
2090
+ response = await self.privatePostSpotV2SubmitOrder(spotRequest)
2091
+ else:
2092
+ swapRequest = self.create_swap_order_request(symbol, type, side, amount, price, params)
2093
+ response = await self.privatePostContractPrivateSubmitOrder(swapRequest)
2118
2094
  #
2119
2095
  # spot and margin
2120
2096
  #
@@ -2127,6 +2103,9 @@ class bitmart(Exchange, ImplicitAPI):
2127
2103
  # }
2128
2104
  # }
2129
2105
  #
2106
+ # swap
2107
+ # {"code":1000,"message":"Ok","data":{"order_id":231116359426639,"price":"market price"},"trace":"7f9c94e10f9d4513bc08a7bfc2a5559a.62.16996369620521911"}
2108
+ #
2130
2109
  data = self.safe_value(response, 'data', {})
2131
2110
  order = self.parse_order(data, market)
2132
2111
  order['type'] = type
@@ -2135,6 +2114,129 @@ class bitmart(Exchange, ImplicitAPI):
2135
2114
  order['price'] = price
2136
2115
  return order
2137
2116
 
2117
+ def create_swap_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
2118
+ """
2119
+ create a trade order
2120
+ :see: https://developer-pro.bitmart.com/en/futures/#submit-order-signed
2121
+ :param str symbol: unified symbol of the market to create an order in
2122
+ :param str type: 'market' or 'limit'
2123
+ :param str side: 'buy' or 'sell'
2124
+ :param float amount: how much of currency you want to trade in units of base currency
2125
+ :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2126
+ :param dict [params]: extra parameters specific to the bitmart api endpoint
2127
+ :param int [params.leverage]: leverage level
2128
+ :param boolean [params.reduceOnly]: *swap only* reduce only
2129
+ :param str [params.marginMode]: 'cross' or 'isolated', default is 'cross'
2130
+ * @param {string} [params.clientOrderId] client order id of the order
2131
+ :returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
2132
+ """
2133
+ market = self.market(symbol)
2134
+ request = {
2135
+ 'symbol': market['id'],
2136
+ 'type': type,
2137
+ 'size': int(self.amount_to_precision(symbol, amount)),
2138
+ }
2139
+ timeInForce = self.safe_string(params, 'timeInForce')
2140
+ mode = self.safe_integer(params, 'mode') # only for swap
2141
+ isMarketOrder = type == 'market'
2142
+ postOnly = None
2143
+ reduceOnly = self.safe_value(params, 'reduceOnly')
2144
+ isExchangeSpecificPo = (mode == 4)
2145
+ postOnly, params = self.handle_post_only(isMarketOrder, isExchangeSpecificPo, params)
2146
+ params = self.omit(params, ['timeInForce', 'postOnly', 'reduceOnly'])
2147
+ ioc = ((timeInForce == 'IOC') or (mode == 3))
2148
+ isLimitOrder = (type == 'limit') or postOnly or ioc
2149
+ if timeInForce == 'GTC':
2150
+ request['mode'] = 1
2151
+ elif timeInForce == 'FOK':
2152
+ request['mode'] = 2
2153
+ elif timeInForce == 'IOC':
2154
+ request['mode'] = 3
2155
+ if postOnly:
2156
+ request['mode'] = 4
2157
+ if isLimitOrder:
2158
+ request['price'] = self.price_to_precision(symbol, price)
2159
+ if side == 'buy':
2160
+ if reduceOnly:
2161
+ request['side'] = 2 # sell close long
2162
+ else:
2163
+ request['side'] = 1 # buy open long
2164
+ elif side == 'sell':
2165
+ if reduceOnly:
2166
+ request['side'] = 3 # sell close long
2167
+ else:
2168
+ request['side'] = 4 # sell open short
2169
+ marginMode = None
2170
+ marginMode, params = self.handle_margin_mode_and_params('createOrder', params, 'cross')
2171
+ request['open_type'] = marginMode
2172
+ clientOrderId = self.safe_string(params, 'clientOrderId')
2173
+ if clientOrderId is not None:
2174
+ params = self.omit(params, 'clientOrderId')
2175
+ request['client_order_id'] = clientOrderId
2176
+ leverage = self.safe_integer(params, 'leverage', 1)
2177
+ params = self.omit(params, 'leverage')
2178
+ request['leverage'] = self.number_to_string(leverage)
2179
+ return self.extend(request, params)
2180
+
2181
+ def create_spot_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount, price=None, params={}):
2182
+ """
2183
+ create a spot order request
2184
+ :see: https://developer-pro.bitmart.com/en/spot/#place-spot-order
2185
+ :see: https://developer-pro.bitmart.com/en/spot/#place-margin-order
2186
+ :param str symbol: unified symbol of the market to create an order in
2187
+ :param str type: 'market' or 'limit'
2188
+ :param str side: 'buy' or 'sell'
2189
+ :param float amount: how much of currency you want to trade in units of base currency
2190
+ :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2191
+ :param dict [params]: extra parameters specific to the bitmart api endpoint
2192
+ :param str [params.marginMode]: 'cross' or 'isolated'
2193
+ :returns dict: an `order structure <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
2194
+ """
2195
+ market = self.market(symbol)
2196
+ request = {
2197
+ 'symbol': market['id'],
2198
+ 'side': side,
2199
+ 'type': type,
2200
+ }
2201
+ timeInForce = self.safe_string(params, 'timeInForce')
2202
+ if timeInForce == 'FOK':
2203
+ raise InvalidOrder(self.id + ' createOrder() only accepts timeInForce parameter values of IOC or PO')
2204
+ mode = self.safe_integer(params, 'mode') # only for swap
2205
+ isMarketOrder = type == 'market'
2206
+ postOnly = None
2207
+ isExchangeSpecificPo = (type == 'limit_maker') or (mode == 4)
2208
+ postOnly, params = self.handle_post_only(isMarketOrder, isExchangeSpecificPo, params)
2209
+ params = self.omit(params, ['timeInForce', 'postOnly'])
2210
+ ioc = ((timeInForce == 'IOC') or (type == 'ioc'))
2211
+ isLimitOrder = (type == 'limit') or postOnly or ioc
2212
+ # method = 'privatePostSpotV2SubmitOrder'
2213
+ if isLimitOrder:
2214
+ request['size'] = self.amount_to_precision(symbol, amount)
2215
+ request['price'] = self.price_to_precision(symbol, price)
2216
+ elif isMarketOrder:
2217
+ # for market buy it requires the amount of quote currency to spend
2218
+ if side == 'buy':
2219
+ notional = self.safe_number(params, 'notional')
2220
+ createMarketBuyOrderRequiresPrice = self.safe_value(self.options, 'createMarketBuyOrderRequiresPrice', True)
2221
+ if createMarketBuyOrderRequiresPrice:
2222
+ if price is not None:
2223
+ if notional is None:
2224
+ amountString = self.number_to_string(amount)
2225
+ priceString = self.number_to_string(price)
2226
+ notional = self.parse_number(Precise.string_mul(amountString, priceString))
2227
+ elif notional is None:
2228
+ raise InvalidOrder(self.id + " createOrder() requires the price argument with market buy orders to calculate total order cost(amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options['createMarketBuyOrderRequiresPrice'] = False and supply the total cost value in the 'amount' argument or in the 'notional' extra parameter(the exchange-specific behaviour)")
2229
+ else:
2230
+ notional = amount if (notional is None) else notional
2231
+ request['notional'] = self.decimal_to_precision(notional, TRUNCATE, market['precision']['price'], self.precisionMode)
2232
+ elif side == 'sell':
2233
+ request['size'] = self.amount_to_precision(symbol, amount)
2234
+ if postOnly:
2235
+ request['type'] = 'limit_maker'
2236
+ if ioc:
2237
+ request['type'] = 'ioc'
2238
+ return self.extend(request, params)
2239
+
2138
2240
  async def cancel_order(self, id: str, symbol: Optional[str] = None, params={}):
2139
2241
  """
2140
2242
  :see: https://developer-pro.bitmart.com/en/futures/#cancel-order-signed
@@ -3835,9 +3937,11 @@ class bitmart(Exchange, ImplicitAPI):
3835
3937
  if api == 'private':
3836
3938
  self.check_required_credentials()
3837
3939
  timestamp = str(self.milliseconds())
3940
+ brokerId = self.safe_string(self.options, 'brokerId', 'CCXTxBitmart000')
3838
3941
  headers = {
3839
3942
  'X-BM-KEY': self.apiKey,
3840
3943
  'X-BM-TIMESTAMP': timestamp,
3944
+ 'X-BM-BROKER-ID': brokerId,
3841
3945
  'Content-Type': 'application/json',
3842
3946
  }
3843
3947
  if not getOrDelete:
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitmex import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
9
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
10
10
  from typing import Optional
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
@@ -1276,7 +1276,7 @@ class bitmex(Exchange, ImplicitAPI):
1276
1276
  raise BadSymbol(self.id + ' fetchTicker() symbol ' + symbol + ' not found')
1277
1277
  return self.parse_ticker(ticker, market)
1278
1278
 
1279
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
1279
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
1280
1280
  """
1281
1281
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
1282
1282
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitopro import ImplicitAPI
8
8
  import hashlib
9
9
  import math
10
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
10
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
11
11
  from typing import Optional
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
@@ -439,7 +439,7 @@ class bitopro(Exchange, ImplicitAPI):
439
439
  #
440
440
  return self.parse_ticker(ticker, market)
441
441
 
442
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
442
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
443
443
  """
444
444
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
445
445
  :see: https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ticker_data.md
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitpanda import ImplicitAPI
8
- from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Trade, Transaction
8
+ from ccxt.base.types import Balances, Order, OrderBook, OrderSide, OrderType, Ticker, Tickers, Trade, Transaction
9
9
  from typing import Optional
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
@@ -642,7 +642,7 @@ class bitpanda(Exchange, ImplicitAPI):
642
642
  #
643
643
  return self.parse_ticker(response, market)
644
644
 
645
- async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}):
645
+ async def fetch_tickers(self, symbols: Optional[List[str]] = None, params={}) -> Tickers:
646
646
  """
647
647
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
648
648
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned