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
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.hyperliquid import ImplicitAPI
8
8
  import asyncio
9
- from ccxt.base.types import Balances, Currencies, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import ArgumentsRequired
@@ -17,7 +17,6 @@ from ccxt.base.errors import NotSupported
17
17
  from ccxt.base.decimal_to_precision import ROUND
18
18
  from ccxt.base.decimal_to_precision import DECIMAL_PLACES
19
19
  from ccxt.base.decimal_to_precision import SIGNIFICANT_DIGITS
20
- from ccxt.base.decimal_to_precision import TICK_SIZE
21
20
  from ccxt.base.precise import Precise
22
21
 
23
22
 
@@ -197,9 +196,11 @@ class hyperliquid(Exchange, ImplicitAPI):
197
196
  'No liquidity available for market order.': InvalidOrder,
198
197
  'Order was never placed, already canceled, or filled.': OrderNotFound,
199
198
  'User or API Wallet ': InvalidOrder,
199
+ 'Order has invalid size': InvalidOrder,
200
+ 'Order price cannot be more than 80% away from the reference price': InvalidOrder,
200
201
  },
201
202
  },
202
- 'precisionMode': TICK_SIZE,
203
+ 'precisionMode': DECIMAL_PLACES,
203
204
  'commonCurrencies': {
204
205
  },
205
206
  'options': {
@@ -217,7 +218,7 @@ class hyperliquid(Exchange, ImplicitAPI):
217
218
  async def fetch_currencies(self, params={}) -> Currencies:
218
219
  """
219
220
  fetches all available currencies on an exchange
220
- :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-exchange-metadata
221
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-metadata
221
222
  :param dict [params]: extra parameters specific to the exchange API endpoint
222
223
  :returns dict: an associative dictionary of currencies
223
224
  """
@@ -273,7 +274,8 @@ class hyperliquid(Exchange, ImplicitAPI):
273
274
  async def fetch_markets(self, params={}) -> List[Market]:
274
275
  """
275
276
  retrieves data on all markets for hyperliquid
276
- :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
277
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
278
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
277
279
  :param dict [params]: extra parameters specific to the exchange API endpoint
278
280
  :returns dict[]: an array of objects representing market data
279
281
  """
@@ -289,7 +291,7 @@ class hyperliquid(Exchange, ImplicitAPI):
289
291
  async def fetch_swap_markets(self, params={}) -> List[Market]:
290
292
  """
291
293
  retrieves data on all swap markets for hyperliquid
292
- :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
294
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
293
295
  :param dict [params]: extra parameters specific to the exchange API endpoint
294
296
  :returns dict[]: an array of objects representing market data
295
297
  """
@@ -344,7 +346,7 @@ class hyperliquid(Exchange, ImplicitAPI):
344
346
  async def fetch_spot_markets(self, params={}) -> List[Market]:
345
347
  """
346
348
  retrieves data on all spot markets for hyperliquid
347
- :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-asset-contexts-includes-mark-price-current-funding-open-interest-etc
349
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
348
350
  :param dict [params]: extra parameters specific to the exchange API endpoint
349
351
  :returns dict[]: an array of objects representing market data
350
352
  """
@@ -355,102 +357,51 @@ class hyperliquid(Exchange, ImplicitAPI):
355
357
  #
356
358
  # [
357
359
  # {
358
- # 'tokens': [
360
+ # "tokens": [
359
361
  # {
360
- # 'name': 'USDC',
361
- # 'szDecimals': '8',
362
- # 'weiDecimals': '8',
362
+ # "name": "USDC",
363
+ # "szDecimals": 8,
364
+ # "weiDecimals" 8,
365
+ # "index": 0,
366
+ # "tokenId": "0x6d1e7cde53ba9467b783cb7c530ce054",
367
+ # "isCanonical": True,
368
+ # "evmContract":null,
369
+ # "fullName":null
363
370
  # },
364
371
  # {
365
- # 'name': 'PURR',
366
- # 'szDecimals': '0',
367
- # 'weiDecimals': '5',
368
- # },
372
+ # "name": "PURR",
373
+ # "szDecimals": 0,
374
+ # "weiDecimals": 5,
375
+ # "index": 1,
376
+ # "tokenId": "0xc1fb593aeffbeb02f85e0308e9956a90",
377
+ # "isCanonical": True,
378
+ # "evmContract":null,
379
+ # "fullName":null
380
+ # }
369
381
  # ],
370
- # 'universe': [
382
+ # "universe": [
371
383
  # {
372
- # 'name': 'PURR/USDC',
373
- # 'tokens': [
374
- # 1,
375
- # 0,
376
- # ],
377
- # },
378
- # ],
384
+ # "name": "PURR/USDC",
385
+ # "tokens": [1, 0],
386
+ # "index": 0,
387
+ # "isCanonical": True
388
+ # }
389
+ # ]
379
390
  # },
380
391
  # [
381
392
  # {
382
- # 'dayNtlVlm': '264250385.14640012',
383
- # 'markPx': '0.018314',
384
- # 'midPx': '0.0182235',
385
- # 'prevDayPx': '0.017427',
386
- # },
387
- # ],
388
- # ]
389
- # mainnet
390
- # [
391
- # {
392
- # "canonical_tokens2":[
393
- # 0,
394
- # 1
395
- # ],
396
- # "spot_infos":[
397
- # {
398
- # "name":"PURR/USDC",
399
- # "tokens":[
400
- # 1,
401
- # 0
402
- # ]
403
- # }
404
- # ],
405
- # "token_id_to_token":[
406
- # [
407
- # "0x6d1e7cde53ba9467b783cb7c530ce054",
408
- # 0
409
- # ],
410
- # [
411
- # "0xc1fb593aeffbeb02f85e0308e9956a90",
412
- # 1
413
- # ]
414
- # ],
415
- # "token_infos":[
416
- # {
417
- # "deployer":null,
418
- # "spec":{
419
- # "name":"USDC",
420
- # "szDecimals":"8",
421
- # "weiDecimals":"8"
422
- # },
423
- # "spots":[
424
- # ]
425
- # },
426
- # {
427
- # "deployer":null,
428
- # "spec":{
429
- # "name":"PURR",
430
- # "szDecimals":"0",
431
- # "weiDecimals":"5"
432
- # },
433
- # "spots":[
434
- # 0
435
- # ]
436
- # }
437
- # ]
438
- # },
439
- # [
440
- # {
441
- # "dayNtlVlm":"35001170.16631",
442
- # "markPx":"0.15743",
443
- # "midPx":"0.157555",
444
- # "prevDayPx":"0.158"
445
- # }
393
+ # "dayNtlVlm":"8906.0",
394
+ # "markPx":"0.14",
395
+ # "midPx":"0.209265",
396
+ # "prevDayPx":"0.20432"
397
+ # }
446
398
  # ]
447
399
  # ]
448
400
  #
449
- # response differs depending on the environment(mainnet vs sandbox)
450
401
  first = self.safe_dict(response, 0, {})
451
402
  second = self.safe_list(response, 1, [])
452
- meta = self.safe_list_2(first, 'universe', 'spot_infos', [])
453
- tokens = self.safe_list_2(first, 'tokens', 'token_infos', [])
403
+ meta = self.safe_list(first, 'universe', [])
404
+ tokens = self.safe_list(first, 'tokens', [])
454
405
  markets = []
455
406
  for i in range(0, len(meta)):
456
407
  market = self.safe_dict(meta, i, {})
@@ -478,7 +429,7 @@ class hyperliquid(Exchange, ImplicitAPI):
478
429
  symbol = base + '/' + quote
479
430
  innerBaseTokenInfo = self.safe_dict(baseTokenInfo, 'spec', baseTokenInfo)
480
431
  # innerQuoteTokenInfo = self.safe_dict(quoteTokenInfo, 'spec', quoteTokenInfo)
481
- amountPrecision = self.parse_number(self.parse_precision(self.safe_string(innerBaseTokenInfo, 'szDecimals')))
432
+ amountPrecision = self.safe_integer(innerBaseTokenInfo, 'szDecimals')
482
433
  # quotePrecision = self.parse_number(self.parse_precision(self.safe_string(innerQuoteTokenInfo, 'szDecimals')))
483
434
  baseId = self.number_to_string(i + 10000)
484
435
  markets.append(self.safe_market_structure({
@@ -510,7 +461,7 @@ class hyperliquid(Exchange, ImplicitAPI):
510
461
  'optionType': None,
511
462
  'precision': {
512
463
  'amount': amountPrecision, # decimal places
513
- 'price': 5, # significant digits
464
+ 'price': 8 - amountPrecision, # MAX_DECIMALS is 8
514
465
  },
515
466
  'limits': {
516
467
  'leverage': {
@@ -526,7 +477,7 @@ class hyperliquid(Exchange, ImplicitAPI):
526
477
  'max': None,
527
478
  },
528
479
  'cost': {
529
- 'min': None,
480
+ 'min': self.parse_number('10'),
530
481
  'max': None,
531
482
  },
532
483
  },
@@ -571,7 +522,8 @@ class hyperliquid(Exchange, ImplicitAPI):
571
522
  fees = self.safe_dict(self.fees, 'swap', {})
572
523
  taker = self.safe_number(fees, 'taker')
573
524
  maker = self.safe_number(fees, 'maker')
574
- return {
525
+ amountPrecision = self.safe_integer(market, 'szDecimals')
526
+ return self.safe_market_structure({
575
527
  'id': baseId,
576
528
  'symbol': symbol,
577
529
  'base': base,
@@ -598,8 +550,8 @@ class hyperliquid(Exchange, ImplicitAPI):
598
550
  'strike': None,
599
551
  'optionType': None,
600
552
  'precision': {
601
- 'amount': self.parse_number(self.parse_precision(self.safe_string(market, 'szDecimals'))), # decimal places
602
- 'price': 5, # significant digits
553
+ 'amount': amountPrecision, # decimal places
554
+ 'price': 6 - amountPrecision, # MAX_DECIMALS is 6
603
555
  },
604
556
  'limits': {
605
557
  'leverage': {
@@ -615,18 +567,19 @@ class hyperliquid(Exchange, ImplicitAPI):
615
567
  'max': None,
616
568
  },
617
569
  'cost': {
618
- 'min': None,
570
+ 'min': self.parse_number('10'),
619
571
  'max': None,
620
572
  },
621
573
  },
622
574
  'created': None,
623
575
  'info': market,
624
- }
576
+ })
625
577
 
626
578
  async def fetch_balance(self, params={}) -> Balances:
627
579
  """
628
580
  query for balance and get the amount of funds available for trading or funds locked in orders
629
- :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-state
581
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-a-users-token-balances
582
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary
630
583
  :param dict [params]: extra parameters specific to the exchange API endpoint
631
584
  :param str [params.user]: user address, will default to self.walletAddress if not provided
632
585
  :param str [params.type]: wallet type, ['spot', 'swap'], defaults to swap
@@ -707,7 +660,7 @@ class hyperliquid(Exchange, ImplicitAPI):
707
660
  async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
708
661
  """
709
662
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
710
- :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#info
663
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#l2-book-snapshot
711
664
  :param str symbol: unified symbol of the market to fetch the order book for
712
665
  :param int [limit]: the maximum amount of order book entries to return
713
666
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -753,7 +706,8 @@ class hyperliquid(Exchange, ImplicitAPI):
753
706
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
754
707
  """
755
708
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
756
- :see: https://www.bitmex.com/api/explorer/#not /Instrument/Instrument_getActiveAndIndices
709
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-perpetuals-asset-contexts-includes-mark-price-current-funding-open-interest-etc
710
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/spot#retrieve-spot-asset-contexts
757
711
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
758
712
  :param dict [params]: extra parameters specific to the exchange API endpoint
759
713
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -804,7 +758,7 @@ class hyperliquid(Exchange, ImplicitAPI):
804
758
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
805
759
  """
806
760
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
807
- :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#info-1
761
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#candle-snapshot
808
762
  :param str symbol: unified symbol of the market to fetch OHLCV data for
809
763
  :param str timeframe: the length of time each candle represents, support '1m', '15m', '1h', '1d'
810
764
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -927,14 +881,13 @@ class hyperliquid(Exchange, ImplicitAPI):
927
881
 
928
882
  def amount_to_precision(self, symbol, amount):
929
883
  market = self.market(symbol)
930
- if market['spot']:
931
- return super(hyperliquid, self).amount_to_precision(symbol, amount)
932
- return self.decimal_to_precision(amount, ROUND, self.markets[symbol]['precision']['amount'], self.precisionMode)
884
+ return self.decimal_to_precision(amount, ROUND, market['precision']['amount'], self.precisionMode, self.paddingMode)
933
885
 
934
886
  def price_to_precision(self, symbol: str, price) -> str:
935
887
  market = self.market(symbol)
936
- result = self.decimal_to_precision(price, ROUND, market['precision']['price'], SIGNIFICANT_DIGITS, self.paddingMode)
937
- decimalParsedResult = self.decimal_to_precision(result, ROUND, 6, DECIMAL_PLACES, self.paddingMode)
888
+ # https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/tick-and-lot-size
889
+ result = self.decimal_to_precision(price, ROUND, 5, SIGNIFICANT_DIGITS, self.paddingMode)
890
+ decimalParsedResult = self.decimal_to_precision(result, ROUND, market['precision']['price'], self.precisionMode, self.paddingMode)
938
891
  return decimalParsedResult
939
892
 
940
893
  def hash_message(self, message):
@@ -1564,7 +1517,7 @@ class hyperliquid(Exchange, ImplicitAPI):
1564
1517
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1565
1518
  """
1566
1519
  fetches historical funding rate prices
1567
- :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-historical-funding-rates
1520
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-historical-funding-rates
1568
1521
  :param str symbol: unified symbol of the market to fetch the funding rate history for
1569
1522
  :param int [since]: timestamp in ms of the earliest funding rate to fetch
1570
1523
  :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
@@ -2038,7 +1991,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2038
1991
  async def fetch_position(self, symbol: str, params={}):
2039
1992
  """
2040
1993
  fetch data on an open position
2041
- :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-state
1994
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary
2042
1995
  :param str symbol: unified market symbol of the market the position is held in
2043
1996
  :param dict [params]: extra parameters specific to the exchange API endpoint
2044
1997
  :param str [params.user]: user address, will default to self.walletAddress if not provided
@@ -2050,7 +2003,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2050
2003
  async def fetch_positions(self, symbols: Strings = None, params={}):
2051
2004
  """
2052
2005
  fetch all open positions
2053
- :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-a-users-state
2006
+ :see: https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint/perpetuals#retrieve-users-perpetuals-account-summary
2054
2007
  :param str[] [symbols]: list of unified market symbols
2055
2008
  :param dict [params]: extra parameters specific to the exchange API endpoint
2056
2009
  :param str [params.user]: user address, will default to self.walletAddress if not provided
@@ -2640,12 +2593,12 @@ class hyperliquid(Exchange, ImplicitAPI):
2640
2593
  'tierBased': None,
2641
2594
  }
2642
2595
 
2643
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
2596
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2644
2597
  """
2645
2598
  fetch the history of changes, actions done by the user or operations that altered the balance of the user
2646
- :param str code: unified currency code
2599
+ :param str [code]: unified currency code
2647
2600
  :param int [since]: timestamp in ms of the earliest ledger entry
2648
- :param int [limit]: max number of ledger entrys to return
2601
+ :param int [limit]: max number of ledger entries to return
2649
2602
  :param dict [params]: extra parameters specific to the exchange API endpoint
2650
2603
  :param int [params.until]: timestamp in ms of the latest ledger entry
2651
2604
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
@@ -2679,7 +2632,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2679
2632
  #
2680
2633
  return self.parse_ledger(response, None, since, limit)
2681
2634
 
2682
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
2635
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
2683
2636
  #
2684
2637
  # {
2685
2638
  # "time":1724762307531,
@@ -2702,7 +2655,8 @@ class hyperliquid(Exchange, ImplicitAPI):
2702
2655
  }
2703
2656
  type = self.safe_string(delta, 'type')
2704
2657
  amount = self.safe_string(delta, 'usdc')
2705
- return {
2658
+ return self.safe_ledger_entry({
2659
+ 'info': item,
2706
2660
  'id': self.safe_string(item, 'hash'),
2707
2661
  'direction': None,
2708
2662
  'account': None,
@@ -2717,8 +2671,7 @@ class hyperliquid(Exchange, ImplicitAPI):
2717
2671
  'after': None,
2718
2672
  'status': None,
2719
2673
  'fee': fee,
2720
- 'info': item,
2721
- }
2674
+ }, currency)
2722
2675
 
2723
2676
  def parse_ledger_entry_type(self, type):
2724
2677
  ledgerType: dict = {
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.kraken import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Currencies, Currency, IndexType, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
9
+ from ccxt.base.types import Balances, Currencies, Currency, IndexType, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -1026,7 +1026,7 @@ class kraken(Exchange, ImplicitAPI):
1026
1026
  }
1027
1027
  return self.safe_string(types, type, type)
1028
1028
 
1029
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
1029
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
1030
1030
  #
1031
1031
  # {
1032
1032
  # 'LTFK7F-N2CUX-PNY4SX': {
@@ -1048,7 +1048,9 @@ class kraken(Exchange, ImplicitAPI):
1048
1048
  referenceId = self.safe_string(item, 'refid')
1049
1049
  referenceAccount = None
1050
1050
  type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
1051
- code = self.safe_currency_code(self.safe_string(item, 'asset'), currency)
1051
+ currencyId = self.safe_string(item, 'asset')
1052
+ code = self.safe_currency_code(currencyId, currency)
1053
+ currency = self.safe_currency(currencyId, currency)
1052
1054
  amount = self.safe_string(item, 'amount')
1053
1055
  if Precise.string_lt(amount, '0'):
1054
1056
  direction = 'out'
@@ -1056,7 +1058,7 @@ class kraken(Exchange, ImplicitAPI):
1056
1058
  else:
1057
1059
  direction = 'in'
1058
1060
  timestamp = self.safe_integer_product(item, 'time', 1000)
1059
- return {
1061
+ return self.safe_ledger_entry({
1060
1062
  'info': item,
1061
1063
  'id': id,
1062
1064
  'direction': direction,
@@ -1075,15 +1077,15 @@ class kraken(Exchange, ImplicitAPI):
1075
1077
  'cost': self.safe_number(item, 'fee'),
1076
1078
  'currency': code,
1077
1079
  },
1078
- }
1080
+ }, currency)
1079
1081
 
1080
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1082
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
1081
1083
  """
1082
- fetch the history of changes, actions done by the user or operations that altered balance of the user
1084
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
1083
1085
  :see: https://docs.kraken.com/rest/#tag/Account-Data/operation/getLedgers
1084
- :param str code: unified currency code, default is None
1086
+ :param str [code]: unified currency code, default is None
1085
1087
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1086
- :param int [limit]: max number of ledger entrys to return, default is None
1088
+ :param int [limit]: max number of ledger entries to return, default is None
1087
1089
  :param dict [params]: extra parameters specific to the exchange API endpoint
1088
1090
  :param int [params.until]: timestamp in ms of the latest ledger entry
1089
1091
  :param int [params.end]: timestamp in seconds of the latest ledger entry
@@ -1151,7 +1153,7 @@ class kraken(Exchange, ImplicitAPI):
1151
1153
  items.append(value)
1152
1154
  return self.parse_ledger(items)
1153
1155
 
1154
- async def fetch_ledger_entry(self, id: str, code: Str = None, params={}):
1156
+ async def fetch_ledger_entry(self, id: str, code: Str = None, params={}) -> LedgerEntry:
1155
1157
  items = await self.fetch_ledger_entries_by_ids([id], code, params)
1156
1158
  return items[0]
1157
1159
 
@@ -9,7 +9,7 @@ import asyncio
9
9
  import hashlib
10
10
  import math
11
11
  import json
12
- from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
12
+ from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
13
13
  from typing import List
14
14
  from ccxt.base.errors import ExchangeError
15
15
  from ccxt.base.errors import AuthenticationError
@@ -3932,7 +3932,7 @@ class kucoin(Exchange, ImplicitAPI):
3932
3932
  }
3933
3933
  return self.safe_string(types, type, type)
3934
3934
 
3935
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
3935
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
3936
3936
  #
3937
3937
  # {
3938
3938
  # "id": "611a1e7c6a053300067a88d9", #unique key for each ledger entry
@@ -3950,6 +3950,7 @@ class kucoin(Exchange, ImplicitAPI):
3950
3950
  id = self.safe_string(item, 'id')
3951
3951
  currencyId = self.safe_string(item, 'currency')
3952
3952
  code = self.safe_currency_code(currencyId, currency)
3953
+ currency = self.safe_currency(currencyId, currency)
3953
3954
  amount = self.safe_number(item, 'amount')
3954
3955
  balanceAfter = None
3955
3956
  # balanceAfter = self.safe_number(item, 'balance'); only returns zero string
@@ -3992,7 +3993,8 @@ class kucoin(Exchange, ImplicitAPI):
3992
3993
  if feeCost != '0':
3993
3994
  feeCurrency = code
3994
3995
  fee = {'cost': self.parse_number(feeCost), 'currency': feeCurrency}
3995
- return {
3996
+ return self.safe_ledger_entry({
3997
+ 'info': item,
3996
3998
  'id': id,
3997
3999
  'direction': direction,
3998
4000
  'account': account,
@@ -4007,22 +4009,21 @@ class kucoin(Exchange, ImplicitAPI):
4007
4009
  'after': balanceAfter, # None
4008
4010
  'status': None,
4009
4011
  'fee': fee,
4010
- 'info': item,
4011
- }
4012
+ }, currency)
4012
4013
 
4013
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
4014
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
4014
4015
  """
4016
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
4015
4017
  :see: https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-spot-margin
4016
4018
  :see: https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-trade_hf
4017
4019
  :see: https://www.kucoin.com/docs/rest/account/basic-info/get-account-ledgers-margin_hf
4018
- fetch the history of changes, actions done by the user or operations that altered balance of the user
4019
- :param str code: unified currency code, default is None
4020
+ :param str [code]: unified currency code, default is None
4020
4021
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
4021
- :param int [limit]: max number of ledger entrys to return, default is None
4022
+ :param int [limit]: max number of ledger entries to return, default is None
4022
4023
  :param dict [params]: extra parameters specific to the exchange API endpoint
4023
4024
  :param boolean [params.hf]: default False, when True will fetch ledger entries for the high frequency trading account
4024
4025
  :param int [params.until]: the latest time in ms to fetch entries for
4025
- :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)
4026
+ :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)
4026
4027
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
4027
4028
  """
4028
4029
  await self.load_markets()
@@ -4743,7 +4744,7 @@ class kucoin(Exchange, ImplicitAPI):
4743
4744
  #
4744
4745
  errorCode = self.safe_string(response, 'code')
4745
4746
  message = self.safe_string_2(response, 'msg', 'data', '')
4746
- feedback = self.id + ' ' + message
4747
+ feedback = self.id + ' ' + body
4747
4748
  self.throw_exactly_matched_exception(self.exceptions['exact'], message, feedback)
4748
4749
  self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
4749
4750
  self.throw_broadly_matched_exception(self.exceptions['broad'], body, feedback)
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.luno import ImplicitAPI
8
- from ccxt.base.types import Account, Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface
8
+ from ccxt.base.types import Account, Balances, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import ArgumentsRequired
@@ -920,13 +920,13 @@ class luno(Exchange, ImplicitAPI):
920
920
  }
921
921
  return await self.fetch_ledger(code, since, limit, self.extend(request, params))
922
922
 
923
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
923
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
924
924
  """
925
- fetch the history of changes, actions done by the user or operations that altered balance of the user
925
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
926
926
  :see: https://www.luno.com/en/developers/api#tag/Accounts/operation/ListTransactions
927
- :param str code: unified currency code, default is None
927
+ :param str [code]: unified currency code, default is None
928
928
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
929
- :param int [limit]: max number of ledger entrys to return, default is None
929
+ :param int [limit]: max number of ledger entries to return, default is None
930
930
  :param dict [params]: extra parameters specific to the exchange API endpoint
931
931
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
932
932
  """
@@ -995,13 +995,14 @@ class luno(Exchange, ImplicitAPI):
995
995
  'referenceId': referenceId,
996
996
  }
997
997
 
998
- def parse_ledger_entry(self, entry, currency: Currency = None):
998
+ def parse_ledger_entry(self, entry, currency: Currency = None) -> LedgerEntry:
999
999
  # details = self.safe_value(entry, 'details', {})
1000
1000
  id = self.safe_string(entry, 'row_index')
1001
1001
  account_id = self.safe_string(entry, 'account_id')
1002
1002
  timestamp = self.safe_integer(entry, 'timestamp')
1003
1003
  currencyId = self.safe_string(entry, 'currency')
1004
1004
  code = self.safe_currency_code(currencyId, currency)
1005
+ currency = self.safe_currency(currencyId, currency)
1005
1006
  available_delta = self.safe_string(entry, 'available_delta')
1006
1007
  balance_delta = self.safe_string(entry, 'balance_delta')
1007
1008
  after = self.safe_string(entry, 'balance')
@@ -1027,7 +1028,8 @@ class luno(Exchange, ImplicitAPI):
1027
1028
  direction = 'in'
1028
1029
  elif Precise.string_lt(balance_delta, '0') or Precise.string_lt(available_delta, '0'):
1029
1030
  direction = 'out'
1030
- return {
1031
+ return self.safe_ledger_entry({
1032
+ 'info': entry,
1031
1033
  'id': id,
1032
1034
  'direction': direction,
1033
1035
  'account': account_id,
@@ -1035,15 +1037,14 @@ class luno(Exchange, ImplicitAPI):
1035
1037
  'referenceAccount': None,
1036
1038
  'type': type,
1037
1039
  'currency': code,
1038
- 'amount': self.parse_number(amount),
1040
+ 'amount': self.parse_to_numeric(amount),
1039
1041
  'timestamp': timestamp,
1040
1042
  'datetime': self.iso8601(timestamp),
1041
- 'before': self.parse_number(before),
1042
- 'after': self.parse_number(after),
1043
+ 'before': self.parse_to_numeric(before),
1044
+ 'after': self.parse_to_numeric(after),
1043
1045
  'status': status,
1044
1046
  'fee': None,
1045
- 'info': entry,
1046
- }
1047
+ }, currency)
1047
1048
 
1048
1049
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
1049
1050
  url = self.urls['api'][api] + '/' + self.version + '/' + self.implode_params(path, params)