ccxt 4.4.2__py2.py3-none-any.whl → 4.4.4__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 (87) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bitmart.py +1 -0
  3. ccxt/async_support/__init__.py +1 -1
  4. ccxt/async_support/base/exchange.py +24 -13
  5. ccxt/async_support/base/ws/cache.py +1 -0
  6. ccxt/async_support/binance.py +50 -25
  7. ccxt/async_support/bingx.py +1 -0
  8. ccxt/async_support/bitfinex2.py +10 -9
  9. ccxt/async_support/bitget.py +13 -9
  10. ccxt/async_support/bitmart.py +3 -1
  11. ccxt/async_support/bitmex.py +14 -13
  12. ccxt/async_support/bitso.py +8 -7
  13. ccxt/async_support/bitstamp.py +36 -48
  14. ccxt/async_support/blofin.py +24 -26
  15. ccxt/async_support/bybit.py +26 -23
  16. ccxt/async_support/coinbase.py +31 -10
  17. ccxt/async_support/coinbaseexchange.py +14 -14
  18. ccxt/async_support/coinlist.py +9 -8
  19. ccxt/async_support/coinmetro.py +6 -6
  20. ccxt/async_support/cryptocom.py +12 -9
  21. ccxt/async_support/currencycom.py +9 -9
  22. ccxt/async_support/delta.py +8 -8
  23. ccxt/async_support/digifinex.py +11 -9
  24. ccxt/async_support/gate.py +9 -8
  25. ccxt/async_support/hashkey.py +12 -10
  26. ccxt/async_support/htx.py +16 -19
  27. ccxt/async_support/hyperliquid.py +70 -117
  28. ccxt/async_support/kraken.py +12 -10
  29. ccxt/async_support/kucoin.py +12 -11
  30. ccxt/async_support/luno.py +13 -12
  31. ccxt/async_support/mexc.py +49 -2
  32. ccxt/async_support/ndax.py +9 -8
  33. ccxt/async_support/okcoin.py +21 -30
  34. ccxt/async_support/okx.py +21 -29
  35. ccxt/async_support/woo.py +10 -9
  36. ccxt/async_support/woofipro.py +11 -9
  37. ccxt/async_support/xt.py +12 -7
  38. ccxt/async_support/zonda.py +9 -8
  39. ccxt/base/exchange.py +3 -1
  40. ccxt/binance.py +50 -25
  41. ccxt/bingx.py +1 -0
  42. ccxt/bitfinex2.py +10 -9
  43. ccxt/bitget.py +13 -9
  44. ccxt/bitmart.py +3 -1
  45. ccxt/bitmex.py +14 -13
  46. ccxt/bitso.py +8 -7
  47. ccxt/bitstamp.py +36 -48
  48. ccxt/blofin.py +24 -26
  49. ccxt/bybit.py +26 -23
  50. ccxt/coinbase.py +31 -10
  51. ccxt/coinbaseexchange.py +14 -14
  52. ccxt/coinlist.py +9 -8
  53. ccxt/coinmetro.py +6 -6
  54. ccxt/cryptocom.py +12 -9
  55. ccxt/currencycom.py +9 -9
  56. ccxt/delta.py +8 -8
  57. ccxt/digifinex.py +11 -9
  58. ccxt/gate.py +9 -8
  59. ccxt/hashkey.py +12 -10
  60. ccxt/htx.py +16 -19
  61. ccxt/hyperliquid.py +70 -117
  62. ccxt/kraken.py +12 -10
  63. ccxt/kucoin.py +12 -11
  64. ccxt/luno.py +13 -12
  65. ccxt/mexc.py +48 -2
  66. ccxt/ndax.py +9 -8
  67. ccxt/okcoin.py +21 -30
  68. ccxt/okx.py +21 -29
  69. ccxt/pro/__init__.py +1 -1
  70. ccxt/pro/bybit.py +51 -0
  71. ccxt/pro/cryptocom.py +181 -22
  72. ccxt/pro/mexc.py +154 -4
  73. ccxt/pro/okx.py +5 -3
  74. ccxt/pro/oxfun.py +70 -0
  75. ccxt/pro/phemex.py +41 -2
  76. ccxt/pro/woofipro.py +64 -0
  77. ccxt/test/tests_async.py +1 -1
  78. ccxt/test/tests_sync.py +1 -1
  79. ccxt/woo.py +10 -9
  80. ccxt/woofipro.py +11 -9
  81. ccxt/xt.py +12 -7
  82. ccxt/zonda.py +9 -8
  83. {ccxt-4.4.2.dist-info → ccxt-4.4.4.dist-info}/METADATA +5 -5
  84. {ccxt-4.4.2.dist-info → ccxt-4.4.4.dist-info}/RECORD +87 -87
  85. {ccxt-4.4.2.dist-info → ccxt-4.4.4.dist-info}/LICENSE.txt +0 -0
  86. {ccxt-4.4.2.dist-info → ccxt-4.4.4.dist-info}/WHEEL +0 -0
  87. {ccxt-4.4.2.dist-info → ccxt-4.4.4.dist-info}/top_level.txt +0 -0
ccxt/__init__.py CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.4.2'
25
+ __version__ = '4.4.4'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
ccxt/abstract/bitmart.py CHANGED
@@ -84,6 +84,7 @@ class ImplicitAPI:
84
84
  private_post_spot_v4_query_trades = privatePostSpotV4QueryTrades = Entry('spot/v4/query/trades', 'private', 'POST', {'cost': 5})
85
85
  private_post_spot_v4_query_order_trades = privatePostSpotV4QueryOrderTrades = Entry('spot/v4/query/order-trades', 'private', 'POST', {'cost': 5})
86
86
  private_post_spot_v4_cancel_orders = privatePostSpotV4CancelOrders = Entry('spot/v4/cancel_orders', 'private', 'POST', {'cost': 3})
87
+ private_post_spot_v4_cancel_all = privatePostSpotV4CancelAll = Entry('spot/v4/cancel_all', 'private', 'POST', {'cost': 90})
87
88
  private_post_spot_v4_batch_orders = privatePostSpotV4BatchOrders = Entry('spot/v4/batch_orders', 'private', 'POST', {'cost': 3})
88
89
  private_post_spot_v3_cancel_order = privatePostSpotV3CancelOrder = Entry('spot/v3/cancel_order', 'private', 'POST', {'cost': 1})
89
90
  private_post_spot_v2_batch_orders = privatePostSpotV2BatchOrders = Entry('spot/v2/batch_orders', 'private', 'POST', {'cost': 1})
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.2'
7
+ __version__ = '4.4.4'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.4.2'
5
+ __version__ = '4.4.4'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -65,6 +65,7 @@ class Exchange(BaseExchange):
65
65
  ping = None
66
66
  newUpdates = True
67
67
  clients = {}
68
+ timeout_on_exit = 250 # needed for: https://github.com/ccxt/ccxt/pull/23470
68
69
 
69
70
  def __init__(self, config={}):
70
71
  if 'asyncio_loop' in config:
@@ -114,8 +115,8 @@ class Exchange(BaseExchange):
114
115
 
115
116
  if self.own_session and self.session is None:
116
117
  # Pass this SSL context to aiohttp and create a TCPConnector
117
- connector = aiohttp.TCPConnector(ssl=self.ssl_context, loop=self.asyncio_loop, enable_cleanup_closed=True)
118
- self.session = aiohttp.ClientSession(loop=self.asyncio_loop, connector=connector, trust_env=self.aiohttp_trust_env)
118
+ self.tcp_connector = aiohttp.TCPConnector(ssl=self.ssl_context, loop=self.asyncio_loop, enable_cleanup_closed=True)
119
+ self.session = aiohttp.ClientSession(loop=self.asyncio_loop, connector=self.tcp_connector, trust_env=self.aiohttp_trust_env)
119
120
 
120
121
  async def close(self):
121
122
  await self.ws_close()
@@ -123,7 +124,17 @@ class Exchange(BaseExchange):
123
124
  if self.own_session:
124
125
  await self.session.close()
125
126
  self.session = None
127
+ await self.close_connector()
126
128
  await self.close_proxy_sessions()
129
+ await self.sleep(self.timeout_on_exit)
130
+
131
+ async def close_connector(self):
132
+ if self.tcp_connector is not None:
133
+ await self.tcp_connector.close()
134
+ self.tcp_connector = None
135
+ if self.aiohttp_socks_connector is not None:
136
+ await self.aiohttp_socks_connector.close()
137
+ self.aiohttp_socks_connector = None
127
138
 
128
139
  async def close_proxy_sessions(self):
129
140
  if self.socks_proxy_sessions is not None:
@@ -153,20 +164,20 @@ class Exchange(BaseExchange):
153
164
  elif socksProxy:
154
165
  if ProxyConnector is None:
155
166
  raise NotSupported(self.id + ' - to use SOCKS proxy with ccxt, you need "aiohttp_socks" module that can be installed by "pip install aiohttp_socks"')
156
- # Create our SSL context object with our CA cert file
157
- self.open() # ensure `asyncio_loop` is set
158
- connector = ProxyConnector.from_url(
159
- socksProxy,
160
- # extra args copied from self.open()
161
- ssl=self.ssl_context,
162
- loop=self.asyncio_loop,
163
- enable_cleanup_closed=True
164
- )
165
167
  # override session
166
168
  if (self.socks_proxy_sessions is None):
167
169
  self.socks_proxy_sessions = {}
168
170
  if (socksProxy not in self.socks_proxy_sessions):
169
- self.socks_proxy_sessions[socksProxy] = aiohttp.ClientSession(loop=self.asyncio_loop, connector=connector, trust_env=self.aiohttp_trust_env)
171
+ # Create our SSL context object with our CA cert file
172
+ self.open() # ensure `asyncio_loop` is set
173
+ self.aiohttp_socks_connector = ProxyConnector.from_url(
174
+ socksProxy,
175
+ # extra args copied from self.open()
176
+ ssl=self.ssl_context,
177
+ loop=self.asyncio_loop,
178
+ enable_cleanup_closed=True
179
+ )
180
+ self.socks_proxy_sessions[socksProxy] = aiohttp.ClientSession(loop=self.asyncio_loop, connector=self.aiohttp_socks_connector, trust_env=self.aiohttp_trust_env)
170
181
  proxy_session = self.socks_proxy_sessions[socksProxy]
171
182
  # add aiohttp_proxy for python as exclusion
172
183
  elif self.aiohttp_proxy:
@@ -23,6 +23,7 @@ class BaseCache(list):
23
23
  __contains__ = Delegate('__contains__', '_deque')
24
24
  __reversed__ = Delegate('__reversed__', '_deque')
25
25
  clear = Delegate('clear', '_deque')
26
+ pop = Delegate('pop', '_deque')
26
27
 
27
28
  def __init__(self, max_size=None):
28
29
  super(BaseCache, self).__init__()
@@ -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 Balances, Conversion, CrossBorrowRate, Currencies, Currency, Greeks, Int, IsolatedBorrowRate, IsolatedBorrowRates, Leverage, Leverages, LeverageTier, LeverageTiers, MarginMode, MarginModes, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
11
+ from ccxt.base.types import Balances, Conversion, CrossBorrowRate, Currencies, Currency, Greeks, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, MarginMode, MarginModes, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import AuthenticationError
@@ -6033,8 +6033,8 @@ class binance(Exchange, ImplicitAPI):
6033
6033
  marginMode, params = self.handle_margin_mode_and_params('fetchOrders', params)
6034
6034
  isPortfolioMargin = None
6035
6035
  isPortfolioMargin, params = self.handle_option_and_params_2(params, 'fetchOrders', 'papi', 'portfolioMargin', False)
6036
- isConditional = self.safe_bool_2(params, 'stop', 'conditional')
6037
- params = self.omit(params, ['stop', 'conditional', 'type'])
6036
+ isConditional = self.safe_bool_n(params, ['stop', 'trigger', 'conditional'])
6037
+ params = self.omit(params, ['stop', 'trigger', 'conditional', 'type'])
6038
6038
  request: dict = {
6039
6039
  'symbol': market['id'],
6040
6040
  }
@@ -6283,7 +6283,7 @@ class binance(Exchange, ImplicitAPI):
6283
6283
  marginMode, params = self.handle_margin_mode_and_params('fetchOpenOrders', params)
6284
6284
  isPortfolioMargin = None
6285
6285
  isPortfolioMargin, params = self.handle_option_and_params_2(params, 'fetchOpenOrders', 'papi', 'portfolioMargin', False)
6286
- isConditional = self.safe_bool_n(params, ['stop', 'conditional', 'trigger'])
6286
+ isConditional = self.safe_bool_n(params, ['stop', 'trigger', 'conditional'])
6287
6287
  if symbol is not None:
6288
6288
  market = self.market(symbol)
6289
6289
  request['symbol'] = market['id']
@@ -6297,7 +6297,7 @@ class binance(Exchange, ImplicitAPI):
6297
6297
  type = self.safe_string(params, 'type', defaultType)
6298
6298
  subType = None
6299
6299
  subType, params = self.handle_sub_type_and_params('fetchOpenOrders', market, params)
6300
- params = self.omit(params, ['type', 'stop', 'conditional', 'trigger'])
6300
+ params = self.omit(params, ['type', 'stop', 'trigger', 'conditional'])
6301
6301
  response = None
6302
6302
  if type == 'option':
6303
6303
  if since is not None:
@@ -6358,8 +6358,8 @@ class binance(Exchange, ImplicitAPI):
6358
6358
  }
6359
6359
  isPortfolioMargin = None
6360
6360
  isPortfolioMargin, params = self.handle_option_and_params_2(params, 'fetchOpenOrder', 'papi', 'portfolioMargin', False)
6361
- isConditional = self.safe_bool_n(params, ['stop', 'conditional', 'trigger'])
6362
- params = self.omit(params, ['stop', 'conditional', 'trigger'])
6361
+ isConditional = self.safe_bool_n(params, ['stop', 'trigger', 'conditional'])
6362
+ params = self.omit(params, ['stop', 'trigger', 'conditional'])
6363
6363
  isPortfolioMarginConditional = (isPortfolioMargin and isConditional)
6364
6364
  orderIdRequest = 'strategyId' if isPortfolioMarginConditional else 'orderId'
6365
6365
  request[orderIdRequest] = id
@@ -6649,7 +6649,7 @@ class binance(Exchange, ImplicitAPI):
6649
6649
  marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
6650
6650
  isPortfolioMargin = None
6651
6651
  isPortfolioMargin, params = self.handle_option_and_params_2(params, 'cancelOrder', 'papi', 'portfolioMargin', False)
6652
- isConditional = self.safe_bool_2(params, 'stop', 'conditional')
6652
+ isConditional = self.safe_bool_n(params, ['stop', 'trigger', 'conditional'])
6653
6653
  request: dict = {
6654
6654
  'symbol': market['id'],
6655
6655
  }
@@ -6667,7 +6667,7 @@ class binance(Exchange, ImplicitAPI):
6667
6667
  request['strategyId'] = id
6668
6668
  else:
6669
6669
  request['orderId'] = id
6670
- params = self.omit(params, ['type', 'origClientOrderId', 'clientOrderId', 'newClientStrategyId', 'stop', 'conditional'])
6670
+ params = self.omit(params, ['type', 'origClientOrderId', 'clientOrderId', 'newClientStrategyId', 'stop', 'trigger', 'conditional'])
6671
6671
  response = None
6672
6672
  if market['option']:
6673
6673
  response = await self.eapiPrivateDeleteOrder(self.extend(request, params))
@@ -6726,9 +6726,9 @@ class binance(Exchange, ImplicitAPI):
6726
6726
  }
6727
6727
  isPortfolioMargin = None
6728
6728
  isPortfolioMargin, params = self.handle_option_and_params_2(params, 'cancelAllOrders', 'papi', 'portfolioMargin', False)
6729
- isConditional = self.safe_bool_2(params, 'stop', 'conditional')
6729
+ isConditional = self.safe_bool_n(params, ['stop', 'trigger', 'conditional'])
6730
6730
  type = self.safe_string(params, 'type', market['type'])
6731
- params = self.omit(params, ['type', 'stop', 'conditional'])
6731
+ params = self.omit(params, ['type', 'stop', 'trigger', 'conditional'])
6732
6732
  marginMode = None
6733
6733
  marginMode, params = self.handle_margin_mode_and_params('cancelAllOrders', params)
6734
6734
  response = None
@@ -10362,19 +10362,42 @@ class binance(Exchange, ImplicitAPI):
10362
10362
  result.append(self.parse_settlement(settlements[i], market))
10363
10363
  return result
10364
10364
 
10365
- async def fetch_ledger_entry(self, id: str, code: Str = None, params={}):
10365
+ async def fetch_ledger_entry(self, id: str, code: Str = None, params={}) -> LedgerEntry:
10366
+ """
10367
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
10368
+ :see: https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
10369
+ :param str id: the identification number of the ledger entry
10370
+ :param str code: unified currency code
10371
+ :param dict [params]: extra parameters specific to the exchange API endpoint
10372
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
10373
+ """
10366
10374
  await self.load_markets()
10367
10375
  type = None
10368
10376
  type, params = self.handle_market_type_and_params('fetchLedgerEntry', None, params)
10369
- query: dict = {
10370
- 'recordId': id,
10371
- 'type': type,
10372
- }
10373
10377
  if type != 'option':
10374
10378
  raise BadRequest(self.id + ' fetchLedgerEntry() can only be used for type option')
10375
- return await self.fetch_ledger(code, None, None, self.extend(query, params))
10379
+ self.check_required_argument('fetchLedgerEntry', code, 'code')
10380
+ currency = self.currency(code)
10381
+ request: dict = {
10382
+ 'recordId': id,
10383
+ 'currency': currency['id'],
10384
+ }
10385
+ response = await self.eapiPrivateGetBill(self.extend(request, params))
10386
+ #
10387
+ # [
10388
+ # {
10389
+ # "id": "1125899906845701870",
10390
+ # "asset": "USDT",
10391
+ # "amount": "-0.16518203",
10392
+ # "type": "FEE",
10393
+ # "createDate": 1676621042489
10394
+ # }
10395
+ # ]
10396
+ #
10397
+ first = self.safe_dict(response, 0, response)
10398
+ return self.parse_ledger_entry(first, currency)
10376
10399
 
10377
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
10400
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
10378
10401
  """
10379
10402
  fetch the history of changes, actions done by the user or operations that altered the balance of the user
10380
10403
  :see: https://developers.binance.com/docs/derivatives/option/account/Account-Funding-Flow
@@ -10382,9 +10405,9 @@ class binance(Exchange, ImplicitAPI):
10382
10405
  :see: https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Get-Income-History
10383
10406
  :see: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Income-History
10384
10407
  :see: https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Income-History
10385
- :param str code: unified currency code
10408
+ :param str [code]: unified currency code
10386
10409
  :param int [since]: timestamp in ms of the earliest ledger entry
10387
- :param int [limit]: max number of ledger entrys to return
10410
+ :param int [limit]: max number of ledger entries to return
10388
10411
  :param dict [params]: extra parameters specific to the exchange API endpoint
10389
10412
  :param int [params.until]: timestamp in ms of the latest ledger entry
10390
10413
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
@@ -10462,7 +10485,7 @@ class binance(Exchange, ImplicitAPI):
10462
10485
  #
10463
10486
  return self.parse_ledger(response, currency, since, limit)
10464
10487
 
10465
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
10488
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
10466
10489
  #
10467
10490
  # options(eapi)
10468
10491
  #
@@ -10495,16 +10518,19 @@ class binance(Exchange, ImplicitAPI):
10495
10518
  else:
10496
10519
  direction = 'in'
10497
10520
  currencyId = self.safe_string(item, 'asset')
10521
+ code = self.safe_currency_code(currencyId, currency)
10522
+ currency = self.safe_currency(currencyId, currency)
10498
10523
  timestamp = self.safe_integer_2(item, 'createDate', 'time')
10499
10524
  type = self.safe_string_2(item, 'type', 'incomeType')
10500
- return {
10525
+ return self.safe_ledger_entry({
10526
+ 'info': item,
10501
10527
  'id': self.safe_string_2(item, 'id', 'tranId'),
10502
10528
  'direction': direction,
10503
10529
  'account': None,
10504
10530
  'referenceAccount': None,
10505
10531
  'referenceId': self.safe_string(item, 'tradeId'),
10506
10532
  'type': self.parse_ledger_entry_type(type),
10507
- 'currency': self.safe_currency_code(currencyId, currency),
10533
+ 'currency': code,
10508
10534
  'amount': self.parse_number(amount),
10509
10535
  'timestamp': timestamp,
10510
10536
  'datetime': self.iso8601(timestamp),
@@ -10512,8 +10538,7 @@ class binance(Exchange, ImplicitAPI):
10512
10538
  'after': None,
10513
10539
  'status': None,
10514
10540
  'fee': None,
10515
- 'info': item,
10516
- }
10541
+ }, currency)
10517
10542
 
10518
10543
  def parse_ledger_entry_type(self, type):
10519
10544
  ledgerType: dict = {
@@ -481,6 +481,7 @@ class bingx(Exchange, ImplicitAPI):
481
481
  'commonCurrencies': {
482
482
  'SNOW': 'Snowman', # Snowman vs SnowSwap conflict
483
483
  'OMNI': 'OmniCat',
484
+ 'NAP': '$NAP', # NAP on SOL = SNAP
484
485
  },
485
486
  'options': {
486
487
  'defaultType': 'spot',
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitfinex2 import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Balances, Currencies, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -2730,7 +2730,7 @@ class bitfinex2(Exchange, ImplicitAPI):
2730
2730
  else:
2731
2731
  return type
2732
2732
 
2733
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
2733
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
2734
2734
  #
2735
2735
  # [
2736
2736
  # [
@@ -2751,6 +2751,7 @@ class bitfinex2(Exchange, ImplicitAPI):
2751
2751
  id = self.safe_string(itemList, 0)
2752
2752
  currencyId = self.safe_string(itemList, 1)
2753
2753
  code = self.safe_currency_code(currencyId, currency)
2754
+ currency = self.safe_currency(currencyId, currency)
2754
2755
  timestamp = self.safe_integer(itemList, 3)
2755
2756
  amount = self.safe_number(itemList, 5)
2756
2757
  after = self.safe_number(itemList, 6)
@@ -2759,7 +2760,8 @@ class bitfinex2(Exchange, ImplicitAPI):
2759
2760
  parts = description.split(' @ ')
2760
2761
  first = self.safe_string_lower(parts, 0)
2761
2762
  type = self.parse_ledger_entry_type(first)
2762
- return {
2763
+ return self.safe_ledger_entry({
2764
+ 'info': item,
2763
2765
  'id': id,
2764
2766
  'direction': None,
2765
2767
  'account': None,
@@ -2774,16 +2776,15 @@ class bitfinex2(Exchange, ImplicitAPI):
2774
2776
  'after': after,
2775
2777
  'status': None,
2776
2778
  'fee': None,
2777
- 'info': item,
2778
- }
2779
+ }, currency)
2779
2780
 
2780
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
2781
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2781
2782
  """
2782
- fetch the history of changes, actions done by the user or operations that altered balance of the user
2783
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
2783
2784
  :see: https://docs.bitfinex.com/reference/rest-auth-ledgers
2784
- :param str code: unified currency code, default is None
2785
+ :param str [code]: unified currency code, default is None
2785
2786
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2786
- :param int [limit]: max number of ledger entrys to return, default is None max is 2500
2787
+ :param int [limit]: max number of ledger entries to return, default is None, max is 2500
2787
2788
  :param dict [params]: extra parameters specific to the exchange API endpoint
2788
2789
  :param int [params.until]: timestamp in ms of the latest ledger entry
2789
2790
  :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
@@ -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 Balances, Conversion, CrossBorrowRate, Currencies, Currency, FundingHistory, Int, IsolatedBorrowRate, Leverage, LeverageTier, Liquidation, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
11
+ from ccxt.base.types import Balances, Conversion, CrossBorrowRate, Currencies, Currency, FundingHistory, Int, IsolatedBorrowRate, LedgerEntry, Leverage, LeverageTier, Liquidation, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
12
12
  from typing import List
13
13
  from ccxt.base.errors import ExchangeError
14
14
  from ccxt.base.errors import AuthenticationError
@@ -5493,14 +5493,14 @@ class bitget(Exchange, ImplicitAPI):
5493
5493
  orders = self.safe_list(response, 'data', [])
5494
5494
  return self.parse_orders(orders, market, since, limit)
5495
5495
 
5496
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
5496
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
5497
5497
  """
5498
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
5498
5499
  :see: https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
5499
5500
  :see: https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
5500
- fetch the history of changes, actions done by the user or operations that altered balance of the user
5501
- :param str code: unified currency code, default is None
5501
+ :param str [code]: unified currency code, default is None
5502
5502
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
5503
- :param int [limit]: max number of ledger entrys to return, default is None
5503
+ :param int [limit]: max number of ledger entries to return, default is None
5504
5504
  :param dict [params]: extra parameters specific to the exchange API endpoint
5505
5505
  :param int [params.until]: end time in ms
5506
5506
  :param str [params.symbol]: *contract only* unified market symbol
@@ -5598,7 +5598,7 @@ class bitget(Exchange, ImplicitAPI):
5598
5598
  return self.parse_ledger(bills, currency, since, limit)
5599
5599
  return self.parse_ledger(data, currency, since, limit)
5600
5600
 
5601
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
5601
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
5602
5602
  #
5603
5603
  # spot
5604
5604
  #
@@ -5628,6 +5628,7 @@ class bitget(Exchange, ImplicitAPI):
5628
5628
  #
5629
5629
  currencyId = self.safe_string(item, 'coin')
5630
5630
  code = self.safe_currency_code(currencyId, currency)
5631
+ currency = self.safe_currency(currencyId, currency)
5631
5632
  timestamp = self.safe_integer(item, 'cTime')
5632
5633
  after = self.safe_number(item, 'balance')
5633
5634
  fee = self.safe_number_2(item, 'fees', 'fee')
@@ -5636,7 +5637,7 @@ class bitget(Exchange, ImplicitAPI):
5636
5637
  direction = 'in'
5637
5638
  if amountRaw.find('-') >= 0:
5638
5639
  direction = 'out'
5639
- return {
5640
+ return self.safe_ledger_entry({
5640
5641
  'info': item,
5641
5642
  'id': self.safe_string(item, 'billId'),
5642
5643
  'timestamp': timestamp,
@@ -5651,8 +5652,11 @@ class bitget(Exchange, ImplicitAPI):
5651
5652
  'before': None,
5652
5653
  'after': after,
5653
5654
  'status': None,
5654
- 'fee': fee,
5655
- }
5655
+ 'fee': {
5656
+ 'currency': code,
5657
+ 'cost': fee,
5658
+ },
5659
+ }, currency)
5656
5660
 
5657
5661
  def parse_ledger_type(self, type):
5658
5662
  types: dict = {
@@ -248,6 +248,7 @@ class bitmart(Exchange, ImplicitAPI):
248
248
  'spot/v4/query/trades': 5, # 12 times/2 sec = 6/s => 30/6 = 5
249
249
  'spot/v4/query/order-trades': 5, # 12 times/2 sec = 6/s => 30/6 = 5
250
250
  'spot/v4/cancel_orders': 3,
251
+ 'spot/v4/cancel_all': 90,
251
252
  'spot/v4/batch_orders': 3,
252
253
  # newer endpoint
253
254
  'spot/v3/cancel_order': 1,
@@ -2789,6 +2790,7 @@ class bitmart(Exchange, ImplicitAPI):
2789
2790
  """
2790
2791
  cancel all open orders in a market
2791
2792
  :see: https://developer-pro.bitmart.com/en/spot/#cancel-all-orders
2793
+ :see: https://developer-pro.bitmart.com/en/spot/#new-batch-order-v4-signed
2792
2794
  :see: https://developer-pro.bitmart.com/en/futures/#cancel-all-orders-signed
2793
2795
  :see: https://developer-pro.bitmart.com/en/futuresv2/#cancel-all-orders-signed
2794
2796
  :param str symbol: unified market symbol of the market to cancel orders in
@@ -2806,7 +2808,7 @@ class bitmart(Exchange, ImplicitAPI):
2806
2808
  type = None
2807
2809
  type, params = self.handle_market_type_and_params('cancelAllOrders', market, params)
2808
2810
  if type == 'spot':
2809
- response = await self.privatePostSpotV1CancelOrders(self.extend(request, params))
2811
+ response = await self.privatePostSpotV4CancelAll(self.extend(request, params))
2810
2812
  elif type == 'swap':
2811
2813
  if symbol is None:
2812
2814
  raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
@@ -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, Currencies, Currency, Int, Leverage, Leverages, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Leverages, Market, MarketType, 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
12
  from ccxt.base.errors import AuthenticationError
@@ -1050,7 +1050,7 @@ class bitmex(Exchange, ImplicitAPI):
1050
1050
  }
1051
1051
  return self.safe_string(types, type, type)
1052
1052
 
1053
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
1053
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
1054
1054
  #
1055
1055
  # {
1056
1056
  # "transactID": "69573da3-7744-5467-3207-89fd6efe7a47",
@@ -1099,6 +1099,7 @@ class bitmex(Exchange, ImplicitAPI):
1099
1099
  type = self.parse_ledger_entry_type(self.safe_string(item, 'transactType'))
1100
1100
  currencyId = self.safe_string(item, 'currency')
1101
1101
  code = self.safe_currency_code(currencyId, currency)
1102
+ currency = self.safe_currency(currencyId, currency)
1102
1103
  amountString = self.safe_string(item, 'amount')
1103
1104
  amount = self.convert_to_real_amount(code, amountString)
1104
1105
  timestamp = self.parse8601(self.safe_string(item, 'transactTime'))
@@ -1111,13 +1112,13 @@ class bitmex(Exchange, ImplicitAPI):
1111
1112
  if feeCost is not None:
1112
1113
  feeCost = self.convert_to_real_amount(code, feeCost)
1113
1114
  fee = {
1114
- 'cost': self.parse_number(feeCost),
1115
+ 'cost': self.parse_to_numeric(feeCost),
1115
1116
  'currency': code,
1116
1117
  }
1117
1118
  after = self.safe_string(item, 'walletBalance')
1118
1119
  if after is not None:
1119
1120
  after = self.convert_to_real_amount(code, after)
1120
- before = self.parse_number(Precise.string_sub(self.number_to_string(after), self.number_to_string(amount)))
1121
+ before = self.parse_to_numeric(Precise.string_sub(self.number_to_string(after), self.number_to_string(amount)))
1121
1122
  direction = None
1122
1123
  if Precise.string_lt(amountString, '0'):
1123
1124
  direction = 'out'
@@ -1125,9 +1126,9 @@ class bitmex(Exchange, ImplicitAPI):
1125
1126
  else:
1126
1127
  direction = 'in'
1127
1128
  status = self.parse_transaction_status(self.safe_string(item, 'transactStatus'))
1128
- return {
1129
- 'id': id,
1129
+ return self.safe_ledger_entry({
1130
1130
  'info': item,
1131
+ 'id': id,
1131
1132
  'timestamp': timestamp,
1132
1133
  'datetime': self.iso8601(timestamp),
1133
1134
  'direction': direction,
@@ -1136,20 +1137,20 @@ class bitmex(Exchange, ImplicitAPI):
1136
1137
  'referenceAccount': referenceAccount,
1137
1138
  'type': type,
1138
1139
  'currency': code,
1139
- 'amount': amount,
1140
+ 'amount': self.parse_to_numeric(amount),
1140
1141
  'before': before,
1141
- 'after': self.parse_number(after),
1142
+ 'after': self.parse_to_numeric(after),
1142
1143
  'status': status,
1143
1144
  'fee': fee,
1144
- }
1145
+ }, currency)
1145
1146
 
1146
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1147
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
1147
1148
  """
1148
- fetch the history of changes, actions done by the user or operations that altered balance of the user
1149
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
1149
1150
  :see: https://www.bitmex.com/api/explorer/#not /User/User_getWalletHistory
1150
- :param str code: unified currency code, default is None
1151
+ :param str [code]: unified currency code, default is None
1151
1152
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1152
- :param int [limit]: max number of ledger entrys to return, default is None
1153
+ :param int [limit]: max number of ledger entries to return, default is None
1153
1154
  :param dict [params]: extra parameters specific to the exchange API endpoint
1154
1155
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
1155
1156
  """
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitso import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Trade, TradingFees, Transaction
9
+ from ccxt.base.types import Balances, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Trade, TradingFees, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -195,12 +195,12 @@ class bitso(Exchange, ImplicitAPI):
195
195
  },
196
196
  })
197
197
 
198
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
198
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
199
199
  """
200
- fetch the history of changes, actions done by the user or operations that altered balance of the user
201
- :param str code: unified currency code, default is None
200
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
201
+ :param str [code]: unified currency code, default is None
202
202
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
203
- :param int [limit]: max number of ledger entrys to return, default is None
203
+ :param int [limit]: max number of ledger entries to return, default is None
204
204
  :param dict [params]: extra parameters specific to the exchange API endpoint
205
205
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
206
206
  """
@@ -244,7 +244,7 @@ class bitso(Exchange, ImplicitAPI):
244
244
  }
245
245
  return self.safe_string(types, type, type)
246
246
 
247
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
247
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
248
248
  #
249
249
  # {
250
250
  # "eid": "2510b3e2bc1c87f584500a18084f35ed",
@@ -308,6 +308,7 @@ class bitso(Exchange, ImplicitAPI):
308
308
  amount = self.safe_string(firstBalance, 'amount')
309
309
  currencyId = self.safe_string(firstBalance, 'currency')
310
310
  code = self.safe_currency_code(currencyId, currency)
311
+ currency = self.safe_currency(currencyId, currency)
311
312
  details = self.safe_value(item, 'details', {})
312
313
  referenceId = self.safe_string_2(details, 'fid', 'wid')
313
314
  if referenceId is None:
@@ -327,6 +328,7 @@ class bitso(Exchange, ImplicitAPI):
327
328
  }
328
329
  timestamp = self.parse8601(self.safe_string(item, 'created_at'))
329
330
  return self.safe_ledger_entry({
331
+ 'info': item,
330
332
  'id': self.safe_string(item, 'eid'),
331
333
  'direction': direction,
332
334
  'account': None,
@@ -341,7 +343,6 @@ class bitso(Exchange, ImplicitAPI):
341
343
  'after': None,
342
344
  'status': 'ok',
343
345
  'fee': fee,
344
- 'info': item,
345
346
  }, currency)
346
347
 
347
348
  async def fetch_markets(self, params={}) -> List[Market]: