ccxt 4.4.3__py2.py3-none-any.whl → 4.4.5__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 (90) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/binanceus.py +36 -36
  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 +43 -18
  7. ccxt/async_support/binanceus.py +1 -0
  8. ccxt/async_support/bingx.py +1 -0
  9. ccxt/async_support/bitfinex2.py +10 -9
  10. ccxt/async_support/bitget.py +55 -99
  11. ccxt/async_support/bitmex.py +14 -13
  12. ccxt/async_support/bitso.py +8 -7
  13. ccxt/async_support/bitstamp.py +12 -12
  14. ccxt/async_support/blofin.py +24 -26
  15. ccxt/async_support/bybit.py +101 -29
  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 +10 -8
  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/lykke.py +2 -2
  32. ccxt/async_support/mexc.py +41 -3
  33. ccxt/async_support/ndax.py +9 -8
  34. ccxt/async_support/okcoin.py +21 -30
  35. ccxt/async_support/okx.py +21 -29
  36. ccxt/async_support/paradex.py +1 -1
  37. ccxt/async_support/woo.py +10 -9
  38. ccxt/async_support/woofipro.py +11 -9
  39. ccxt/async_support/xt.py +7 -6
  40. ccxt/async_support/zonda.py +9 -8
  41. ccxt/base/exchange.py +3 -1
  42. ccxt/binance.py +43 -18
  43. ccxt/binanceus.py +1 -0
  44. ccxt/bingx.py +1 -0
  45. ccxt/bitfinex2.py +10 -9
  46. ccxt/bitget.py +55 -99
  47. ccxt/bitmex.py +14 -13
  48. ccxt/bitso.py +8 -7
  49. ccxt/bitstamp.py +12 -12
  50. ccxt/blofin.py +24 -26
  51. ccxt/bybit.py +101 -29
  52. ccxt/coinbase.py +31 -10
  53. ccxt/coinbaseexchange.py +14 -14
  54. ccxt/coinlist.py +9 -8
  55. ccxt/coinmetro.py +6 -6
  56. ccxt/cryptocom.py +10 -8
  57. ccxt/currencycom.py +9 -9
  58. ccxt/delta.py +8 -8
  59. ccxt/digifinex.py +11 -9
  60. ccxt/gate.py +9 -8
  61. ccxt/hashkey.py +12 -10
  62. ccxt/htx.py +16 -19
  63. ccxt/hyperliquid.py +70 -117
  64. ccxt/kraken.py +12 -10
  65. ccxt/kucoin.py +12 -11
  66. ccxt/luno.py +13 -12
  67. ccxt/lykke.py +2 -2
  68. ccxt/mexc.py +40 -3
  69. ccxt/ndax.py +9 -8
  70. ccxt/okcoin.py +21 -30
  71. ccxt/okx.py +21 -29
  72. ccxt/paradex.py +1 -1
  73. ccxt/pro/__init__.py +1 -1
  74. ccxt/pro/binance.py +6 -2
  75. ccxt/pro/binanceus.py +2 -1
  76. ccxt/pro/bybit.py +51 -0
  77. ccxt/pro/hyperliquid.py +14 -1
  78. ccxt/pro/mexc.py +78 -0
  79. ccxt/pro/paradex.py +1 -0
  80. ccxt/test/tests_async.py +1 -1
  81. ccxt/test/tests_sync.py +1 -1
  82. ccxt/woo.py +10 -9
  83. ccxt/woofipro.py +11 -9
  84. ccxt/xt.py +7 -6
  85. ccxt/zonda.py +9 -8
  86. {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/METADATA +5 -5
  87. {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/RECORD +90 -90
  88. {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/LICENSE.txt +0 -0
  89. {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/WHEEL +0 -0
  90. {ccxt-4.4.3.dist-info → ccxt-4.4.5.dist-info}/top_level.txt +0 -0
ccxt/bitso.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.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
- def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
198
+ 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
  def fetch_markets(self, params={}) -> List[Market]:
ccxt/bitstamp.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bitstamp import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, 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
12
  from ccxt.base.errors import AuthenticationError
@@ -1831,7 +1831,7 @@ class bitstamp(Exchange, ImplicitAPI):
1831
1831
  }
1832
1832
  return self.safe_string(types, type, type)
1833
1833
 
1834
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
1834
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
1835
1835
  #
1836
1836
  # [
1837
1837
  # {
@@ -1872,9 +1872,9 @@ class bitstamp(Exchange, ImplicitAPI):
1872
1872
  if market is None:
1873
1873
  market = self.get_market_from_trade(item)
1874
1874
  direction = 'in' if (parsedTrade['side'] == 'buy') else 'out'
1875
- return {
1876
- 'id': parsedTrade['id'],
1875
+ return self.safe_ledger_entry({
1877
1876
  'info': item,
1877
+ 'id': parsedTrade['id'],
1878
1878
  'timestamp': parsedTrade['timestamp'],
1879
1879
  'datetime': parsedTrade['datetime'],
1880
1880
  'direction': direction,
@@ -1888,7 +1888,7 @@ class bitstamp(Exchange, ImplicitAPI):
1888
1888
  'after': None,
1889
1889
  'status': 'ok',
1890
1890
  'fee': parsedTrade['fee'],
1891
- }
1891
+ }, currency)
1892
1892
  else:
1893
1893
  parsedTransaction = self.parse_transaction(item, currency)
1894
1894
  direction = None
@@ -1900,9 +1900,9 @@ class bitstamp(Exchange, ImplicitAPI):
1900
1900
  currency = self.currency(currencyCode)
1901
1901
  amount = self.safe_string(item, currency['id'])
1902
1902
  direction = 'in' if Precise.string_gt(amount, '0') else 'out'
1903
- return {
1904
- 'id': parsedTransaction['id'],
1903
+ return self.safe_ledger_entry({
1905
1904
  'info': item,
1905
+ 'id': parsedTransaction['id'],
1906
1906
  'timestamp': parsedTransaction['timestamp'],
1907
1907
  'datetime': parsedTransaction['datetime'],
1908
1908
  'direction': direction,
@@ -1916,15 +1916,15 @@ class bitstamp(Exchange, ImplicitAPI):
1916
1916
  'after': None,
1917
1917
  'status': parsedTransaction['status'],
1918
1918
  'fee': parsedTransaction['fee'],
1919
- }
1919
+ }, currency)
1920
1920
 
1921
- def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1921
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
1922
1922
  """
1923
- fetch the history of changes, actions done by the user or operations that altered balance of the user
1923
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
1924
1924
  :see: https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactions
1925
- :param str code: unified currency code, default is None
1925
+ :param str [code]: unified currency code, default is None
1926
1926
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1927
- :param int [limit]: max number of ledger entrys to return, default is None
1927
+ :param int [limit]: max number of ledger entries to return, default is None
1928
1928
  :param dict [params]: extra parameters specific to the exchange API endpoint
1929
1929
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
1930
1930
  """
ccxt/blofin.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.blofin import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currency, Int, Leverage, Leverages, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currency, Int, LedgerEntry, Leverage, Leverages, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -1413,17 +1413,17 @@ class blofin(Exchange, ImplicitAPI):
1413
1413
  data = self.safe_list(response, 'data', [])
1414
1414
  return self.parse_transactions(data, currency, since, limit, params)
1415
1415
 
1416
- def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1416
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
1417
1417
  """
1418
- fetch the history of changes, actions done by the user or operations that altered balance of the user
1418
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
1419
1419
  :see: https://blofin.com/docs#get-funds-transfer-history
1420
- :param str code: unified currency code, default is None
1420
+ :param str [code]: unified currency code, default is None
1421
1421
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1422
- :param int [limit]: max number of ledger entrys to return, default is None
1422
+ :param int [limit]: max number of ledger entries to return, default is None
1423
1423
  :param dict [params]: extra parameters specific to the exchange API endpoint
1424
1424
  :param str [params.marginMode]: 'cross' or 'isolated'
1425
1425
  :param int [params.until]: the latest time in ms to fetch entries for
1426
- :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1426
+ :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)
1427
1427
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
1428
1428
  """
1429
1429
  self.load_markets()
@@ -1554,30 +1554,28 @@ class blofin(Exchange, ImplicitAPI):
1554
1554
  }
1555
1555
  return self.safe_string(types, type, type)
1556
1556
 
1557
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
1558
- id = self.safe_string(item, 'transferId')
1559
- referenceId = self.safe_string(item, 'clientId')
1560
- fromAccount = self.safe_string(item, 'fromAccount')
1561
- toAccount = self.safe_string(item, 'toAccount')
1562
- type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
1563
- code = self.safe_currency_code(self.safe_string(item, 'currency'), currency)
1564
- amountString = self.safe_string(item, 'amount')
1565
- amount = self.parse_number(amountString)
1557
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
1558
+ currencyId = self.safe_string(item, 'currency')
1559
+ code = self.safe_currency_code(currencyId, currency)
1560
+ currency = self.safe_currency(currencyId, currency)
1566
1561
  timestamp = self.safe_integer(item, 'ts')
1567
- status = 'ok'
1568
- return {
1569
- 'id': id,
1562
+ return self.safe_ledger_entry({
1570
1563
  'info': item,
1564
+ 'id': self.safe_string(item, 'transferId'),
1565
+ 'direction': None,
1566
+ 'account': None,
1567
+ 'referenceId': self.safe_string(item, 'clientId'),
1568
+ 'referenceAccount': None,
1569
+ 'type': self.parse_ledger_entry_type(self.safe_string(item, 'type')),
1570
+ 'currency': code,
1571
+ 'amount': self.safe_number(item, 'amount'),
1571
1572
  'timestamp': timestamp,
1572
1573
  'datetime': self.iso8601(timestamp),
1573
- 'fromAccount': fromAccount,
1574
- 'toAccount': toAccount,
1575
- 'type': type,
1576
- 'currency': code,
1577
- 'amount': amount,
1578
- 'clientId': referenceId, # balance before
1579
- 'status': status,
1580
- }
1574
+ 'before': None,
1575
+ 'after': None,
1576
+ 'status': 'ok',
1577
+ 'fee': None,
1578
+ }, currency)
1581
1579
 
1582
1580
  def parse_ids(self, ids):
1583
1581
  """
ccxt/bybit.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.bybit import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, CrossBorrowRate, Currencies, Currency, Greeks, Int, Leverage, LeverageTier, LeverageTiers, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, CrossBorrowRate, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -114,7 +114,7 @@ class bybit(Exchange, ImplicitAPI):
114
114
  'fetchOpenOrders': True,
115
115
  'fetchOption': True,
116
116
  'fetchOptionChain': True,
117
- 'fetchOrder': False,
117
+ 'fetchOrder': True,
118
118
  'fetchOrderBook': True,
119
119
  'fetchOrders': False,
120
120
  'fetchOrderTrades': True,
@@ -4526,13 +4526,84 @@ class bybit(Exchange, ImplicitAPI):
4526
4526
  :param str id: the order id
4527
4527
  :param str symbol: unified symbol of the market the order was made in
4528
4528
  :param dict [params]: extra parameters specific to the exchange API endpoint
4529
+ :param dict [params.acknowledged]: to suppress the warning, set to True
4529
4530
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4530
4531
  """
4531
- res = self.is_unified_enabled()
4532
- enableUnifiedAccount = self.safe_bool(res, 1)
4533
- if enableUnifiedAccount:
4534
- raise NotSupported(self.id + ' fetchOrder() is not supported after the 5/02 update for UTA accounts, please use fetchOpenOrder or fetchClosedOrder')
4535
- return self.fetch_order_classic(id, symbol, params)
4532
+ self.load_markets()
4533
+ enableUnifiedMargin, enableUnifiedAccount = self.is_unified_enabled()
4534
+ isUnifiedAccount = (enableUnifiedMargin or enableUnifiedAccount)
4535
+ if not isUnifiedAccount:
4536
+ return self.fetch_order_classic(id, symbol, params)
4537
+ acknowledge = False
4538
+ acknowledge, params = self.handle_option_and_params(params, 'fetchOrder', 'acknowledged')
4539
+ if not acknowledge:
4540
+ raise ArgumentsRequired(self.id + ' fetchOrder() can only access an order if it is in last 500 orders(of any status) for your account. Set params["acknowledged"] = True to hide self warning. Alternatively, we suggest to use fetchOpenOrder or fetchClosedOrder')
4541
+ market = self.market(symbol)
4542
+ marketType = None
4543
+ marketType, params = self.get_bybit_type('fetchOrder', market, params)
4544
+ request: dict = {
4545
+ 'symbol': market['id'],
4546
+ 'orderId': id,
4547
+ 'category': marketType,
4548
+ }
4549
+ isTrigger = None
4550
+ isTrigger, params = self.handle_param_bool_2(params, 'trigger', 'stop', False)
4551
+ if isTrigger:
4552
+ request['orderFilter'] = 'StopOrder'
4553
+ response = self.privateGetV5OrderRealtime(self.extend(request, params))
4554
+ #
4555
+ # {
4556
+ # "retCode": 0,
4557
+ # "retMsg": "OK",
4558
+ # "result": {
4559
+ # "nextPageCursor": "1321052653536515584%3A1672217748287%2C1321052653536515584%3A1672217748287",
4560
+ # "category": "spot",
4561
+ # "list": [
4562
+ # {
4563
+ # "symbol": "ETHUSDT",
4564
+ # "orderType": "Limit",
4565
+ # "orderLinkId": "1672217748277652",
4566
+ # "orderId": "1321052653536515584",
4567
+ # "cancelType": "UNKNOWN",
4568
+ # "avgPrice": "",
4569
+ # "stopOrderType": "tpslOrder",
4570
+ # "lastPriceOnCreated": "",
4571
+ # "orderStatus": "Cancelled",
4572
+ # "takeProfit": "",
4573
+ # "cumExecValue": "0",
4574
+ # "triggerDirection": 0,
4575
+ # "isLeverage": "0",
4576
+ # "rejectReason": "",
4577
+ # "price": "1000",
4578
+ # "orderIv": "",
4579
+ # "createdTime": "1672217748287",
4580
+ # "tpTriggerBy": "",
4581
+ # "positionIdx": 0,
4582
+ # "timeInForce": "GTC",
4583
+ # "leavesValue": "500",
4584
+ # "updatedTime": "1672217748287",
4585
+ # "side": "Buy",
4586
+ # "triggerPrice": "1500",
4587
+ # "cumExecFee": "0",
4588
+ # "leavesQty": "0",
4589
+ # "slTriggerBy": "",
4590
+ # "closeOnTrigger": False,
4591
+ # "cumExecQty": "0",
4592
+ # "reduceOnly": False,
4593
+ # "qty": "0.5",
4594
+ # "stopLoss": "",
4595
+ # "triggerBy": "1192.5"
4596
+ # }
4597
+ # ]
4598
+ # },
4599
+ # "retExtInfo": {},
4600
+ # "time": 1672219526294
4601
+ # }
4602
+ #
4603
+ result = self.safe_dict(response, 'result', {})
4604
+ innerList = self.safe_list(result, 'list', [])
4605
+ order = self.safe_dict(innerList, 0, {})
4606
+ return self.parse_order(order, market)
4536
4607
 
4537
4608
  def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
4538
4609
  res = self.is_unified_enabled()
@@ -5496,15 +5567,15 @@ class bybit(Exchange, ImplicitAPI):
5496
5567
  'comment': None,
5497
5568
  }
5498
5569
 
5499
- def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
5570
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
5500
5571
  """
5501
- fetch the history of changes, actions done by the user or operations that altered balance of the user
5572
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
5502
5573
  :see: https://bybit-exchange.github.io/docs/v5/account/transaction-log
5503
5574
  :see: https://bybit-exchange.github.io/docs/v5/account/contract-transaction-log
5504
- :param str code: unified currency code, default is None
5575
+ :param str [code]: unified currency code, default is None
5505
5576
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
5506
- :param int [limit]: max number of ledger entrys to return, default is None
5507
- :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
5577
+ :param int [limit]: max number of ledger entries to return, default is None
5578
+ :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)
5508
5579
  :param str [params.subType]: if inverse will use v5/account/contract-transaction-log
5509
5580
  :param dict [params]: extra parameters specific to the exchange API endpoint
5510
5581
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
@@ -5664,7 +5735,7 @@ class bybit(Exchange, ImplicitAPI):
5664
5735
  data = self.add_pagination_cursor_to_result(response)
5665
5736
  return self.parse_ledger(data, currency, since, limit)
5666
5737
 
5667
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
5738
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
5668
5739
  #
5669
5740
  # {
5670
5741
  # "id": 234467,
@@ -5703,6 +5774,7 @@ class bybit(Exchange, ImplicitAPI):
5703
5774
  #
5704
5775
  currencyId = self.safe_string_2(item, 'coin', 'currency')
5705
5776
  code = self.safe_currency_code(currencyId, currency)
5777
+ currency = self.safe_currency(currencyId, currency)
5706
5778
  amount = self.safe_string_2(item, 'amount', 'change')
5707
5779
  after = self.safe_string_2(item, 'wallet_balance', 'cashBalance')
5708
5780
  direction = 'out' if Precise.string_lt(amount, '0') else 'in'
@@ -5713,26 +5785,26 @@ class bybit(Exchange, ImplicitAPI):
5713
5785
  timestamp = self.parse8601(self.safe_string(item, 'exec_time'))
5714
5786
  if timestamp is None:
5715
5787
  timestamp = self.safe_integer(item, 'transactionTime')
5716
- type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
5717
- id = self.safe_string(item, 'id')
5718
- referenceId = self.safe_string(item, 'tx_id')
5719
- return {
5720
- 'id': id,
5721
- 'currency': code,
5788
+ return self.safe_ledger_entry({
5789
+ 'info': item,
5790
+ 'id': self.safe_string(item, 'id'),
5791
+ 'direction': direction,
5722
5792
  'account': self.safe_string(item, 'wallet_id'),
5793
+ 'referenceId': self.safe_string(item, 'tx_id'),
5723
5794
  'referenceAccount': None,
5724
- 'referenceId': referenceId,
5725
- 'status': None,
5726
- 'amount': self.parse_number(Precise.string_abs(amount)),
5727
- 'before': self.parse_number(before),
5728
- 'after': self.parse_number(after),
5729
- 'fee': self.parse_number(self.safe_string(item, 'fee')),
5730
- 'direction': direction,
5795
+ 'type': self.parse_ledger_entry_type(self.safe_string(item, 'type')),
5796
+ 'currency': code,
5797
+ 'amount': self.parse_to_numeric(Precise.string_abs(amount)),
5731
5798
  'timestamp': timestamp,
5732
5799
  'datetime': self.iso8601(timestamp),
5733
- 'type': type,
5734
- 'info': item,
5735
- }
5800
+ 'before': self.parse_to_numeric(before),
5801
+ 'after': self.parse_to_numeric(after),
5802
+ 'status': 'ok',
5803
+ 'fee': {
5804
+ 'currency': code,
5805
+ 'cost': self.parse_to_numeric(self.safe_string(item, 'fee')),
5806
+ },
5807
+ }, currency)
5736
5808
 
5737
5809
  def parse_ledger_entry_type(self, type):
5738
5810
  types: dict = {
ccxt/coinbase.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinbase import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Conversion, Currencies, Currency, Int, Market, MarketInterface, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction
9
+ from ccxt.base.types import Account, Balances, Conversion, Currencies, Currency, Int, LedgerEntry, Market, MarketInterface, 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
12
  from ccxt.base.errors import AuthenticationError
@@ -2170,15 +2170,15 @@ class coinbase(Exchange, ImplicitAPI):
2170
2170
  params['type'] = marketType
2171
2171
  return self.parse_custom_balance(response, params)
2172
2172
 
2173
- def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
2173
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2174
2174
  """
2175
- fetch the history of changes, actions done by the user or operations that altered balance of the user
2175
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
2176
2176
  :see: https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-transactions#list-transactions
2177
- :param str code: unified currency code, default is None
2177
+ :param str [code]: unified currency code, default is None
2178
2178
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2179
- :param int [limit]: max number of ledger entrys to return, default is None
2179
+ :param int [limit]: max number of ledger entries to return, default is None
2180
2180
  :param dict [params]: extra parameters specific to the exchange API endpoint
2181
- :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2181
+ :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)
2182
2182
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
2183
2183
  """
2184
2184
  self.load_markets()
@@ -2204,8 +2204,28 @@ class coinbase(Exchange, ImplicitAPI):
2204
2204
  pagination = self.safe_dict(response, 'pagination', {})
2205
2205
  cursor = self.safe_string(pagination, 'next_starting_after')
2206
2206
  if (cursor is not None) and (cursor != ''):
2207
+ lastFee = self.safe_dict(last, 'fee')
2207
2208
  last['next_starting_after'] = cursor
2208
- ledger[lastIndex] = last
2209
+ ledger[lastIndex] = {
2210
+ 'info': self.safe_dict(last, 'info'),
2211
+ 'id': self.safe_string(last, 'id'),
2212
+ 'timestamp': self.safe_integer(last, 'timestamp'),
2213
+ 'datetime': self.safe_string(last, 'datetime'),
2214
+ 'direction': self.safe_string(last, 'direction'),
2215
+ 'account': self.safe_string(last, 'account'),
2216
+ 'referenceId': None,
2217
+ 'referenceAccount': None,
2218
+ 'type': self.safe_string(last, 'type'),
2219
+ 'currency': self.safe_string(last, 'currency'),
2220
+ 'amount': self.safe_number(last, 'amount'),
2221
+ 'before': None,
2222
+ 'after': None,
2223
+ 'status': self.safe_string(last, 'status'),
2224
+ 'fee': {
2225
+ 'cost': self.safe_number(lastFee, 'cost'),
2226
+ 'currency': self.safe_string(lastFee, 'currency'),
2227
+ },
2228
+ }
2209
2229
  return ledger
2210
2230
 
2211
2231
  def parse_ledger_entry_status(self, status):
@@ -2228,7 +2248,7 @@ class coinbase(Exchange, ImplicitAPI):
2228
2248
  }
2229
2249
  return self.safe_string(types, type, type)
2230
2250
 
2231
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
2251
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
2232
2252
  #
2233
2253
  # crypto deposit transaction
2234
2254
  #
@@ -2482,6 +2502,7 @@ class coinbase(Exchange, ImplicitAPI):
2482
2502
  direction = 'in'
2483
2503
  currencyId = self.safe_string(amountInfo, 'currency')
2484
2504
  code = self.safe_currency_code(currencyId, currency)
2505
+ currency = self.safe_currency(currencyId, currency)
2485
2506
  #
2486
2507
  # the address and txid do not belong to the unified ledger structure
2487
2508
  #
@@ -2514,7 +2535,7 @@ class coinbase(Exchange, ImplicitAPI):
2514
2535
  numParts = len(parts)
2515
2536
  if numParts > 3:
2516
2537
  accountId = parts[3]
2517
- return {
2538
+ return self.safe_ledger_entry({
2518
2539
  'info': item,
2519
2540
  'id': id,
2520
2541
  'timestamp': timestamp,
@@ -2530,7 +2551,7 @@ class coinbase(Exchange, ImplicitAPI):
2530
2551
  'after': None,
2531
2552
  'status': status,
2532
2553
  'fee': fee,
2533
- }
2554
+ }, currency)
2534
2555
 
2535
2556
  def find_account_id(self, code, params={}):
2536
2557
  self.load_markets()
ccxt/coinbaseexchange.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinbaseexchange import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction
9
+ from ccxt.base.types import Account, Balances, Currencies, Currency, Int, LedgerEntry, 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
12
  from ccxt.base.errors import AuthenticationError
@@ -1326,7 +1326,7 @@ class coinbaseexchange(Exchange, ImplicitAPI):
1326
1326
  }
1327
1327
  return self.safe_string(types, type, type)
1328
1328
 
1329
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
1329
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
1330
1330
  # {
1331
1331
  # "id": "12087495079",
1332
1332
  # "amount": "-0.0100000000000000",
@@ -1378,31 +1378,31 @@ class coinbaseexchange(Exchange, ImplicitAPI):
1378
1378
  else:
1379
1379
  referenceId = self.safe_string(details, 'order_id')
1380
1380
  status = 'ok'
1381
- return {
1381
+ return self.safe_ledger_entry({
1382
+ 'info': item,
1382
1383
  'id': id,
1383
- 'currency': code,
1384
+ 'timestamp': timestamp,
1385
+ 'datetime': self.iso8601(timestamp),
1386
+ 'direction': direction,
1384
1387
  'account': account,
1385
1388
  'referenceAccount': referenceAccount,
1386
1389
  'referenceId': referenceId,
1387
- 'status': status,
1390
+ 'type': type,
1391
+ 'currency': code,
1388
1392
  'amount': amount,
1389
1393
  'before': before,
1390
1394
  'after': after,
1395
+ 'status': status,
1391
1396
  'fee': None,
1392
- 'direction': direction,
1393
- 'timestamp': timestamp,
1394
- 'datetime': self.iso8601(timestamp),
1395
- 'type': type,
1396
- 'info': item,
1397
- }
1397
+ }, currency)
1398
1398
 
1399
- def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1399
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
1400
1400
  """
1401
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
1401
1402
  :see: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccountledger
1402
- fetch the history of changes, actions done by the user or operations that altered balance of the user
1403
1403
  :param str code: unified currency code, default is None
1404
1404
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1405
- :param int [limit]: max number of ledger entrys to return, default is None
1405
+ :param int [limit]: max number of ledger entries to return, default is None
1406
1406
  :param dict [params]: extra parameters specific to the exchange API endpoint
1407
1407
  :param int [params.until]: the latest time in ms to fetch trades for
1408
1408
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
ccxt/coinlist.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinlist import ImplicitAPI
8
8
  import hashlib
9
9
  import math
10
- from ccxt.base.types import Account, Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Balances, Currencies, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, 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
@@ -1980,13 +1980,13 @@ class coinlist(Exchange, ImplicitAPI):
1980
1980
  }
1981
1981
  return self.safe_string(types, type, type)
1982
1982
 
1983
- def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1983
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
1984
1984
  """
1985
- fetch the history of changes, actions done by the user or operations that altered balance of the user
1985
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
1986
1986
  :see: https://trade-docs.coinlist.co/?javascript--nodejs#get-account-history
1987
- :param str code: unified currency code, default is None
1987
+ :param str [code]: unified currency code, default is None
1988
1988
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1989
- :param int [limit]: max number of ledger entrys to return(default 200, max 500)
1989
+ :param int [limit]: max number of ledger entries to return(default 200, max 500)
1990
1990
  :param dict [params]: extra parameters specific to the exchange API endpoint
1991
1991
  :param int [params.until]: the latest time in ms to fetch entries for
1992
1992
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
@@ -2079,7 +2079,7 @@ class coinlist(Exchange, ImplicitAPI):
2079
2079
  ledger = self.safe_value(response, 'transactions', [])
2080
2080
  return self.parse_ledger(ledger, currency, since, limit)
2081
2081
 
2082
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
2082
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
2083
2083
  #
2084
2084
  # deposit transaction from wallet(funding) to pro(trading)
2085
2085
  # {
@@ -2163,8 +2163,9 @@ class coinlist(Exchange, ImplicitAPI):
2163
2163
  direction = 'in'
2164
2164
  currencyId = self.safe_string(item, 'asset')
2165
2165
  code = self.safe_currency_code(currencyId, currency)
2166
+ currency = self.safe_currency(currencyId, currency)
2166
2167
  type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
2167
- return {
2168
+ return self.safe_ledger_entry({
2168
2169
  'info': item,
2169
2170
  'id': id,
2170
2171
  'timestamp': timestamp,
@@ -2180,7 +2181,7 @@ class coinlist(Exchange, ImplicitAPI):
2180
2181
  'after': None,
2181
2182
  'status': 'ok',
2182
2183
  'fee': None,
2183
- }
2184
+ }, currency)
2184
2185
 
2185
2186
  def parse_ledger_entry_type(self, type):
2186
2187
  types: dict = {