ccxt 4.4.3__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 (79) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/async_support/__init__.py +1 -1
  3. ccxt/async_support/base/exchange.py +24 -13
  4. ccxt/async_support/base/ws/cache.py +1 -0
  5. ccxt/async_support/binance.py +40 -15
  6. ccxt/async_support/bingx.py +1 -0
  7. ccxt/async_support/bitfinex2.py +10 -9
  8. ccxt/async_support/bitget.py +13 -9
  9. ccxt/async_support/bitmex.py +14 -13
  10. ccxt/async_support/bitso.py +8 -7
  11. ccxt/async_support/bitstamp.py +12 -12
  12. ccxt/async_support/blofin.py +24 -26
  13. ccxt/async_support/bybit.py +24 -23
  14. ccxt/async_support/coinbase.py +31 -10
  15. ccxt/async_support/coinbaseexchange.py +14 -14
  16. ccxt/async_support/coinlist.py +9 -8
  17. ccxt/async_support/coinmetro.py +6 -6
  18. ccxt/async_support/cryptocom.py +10 -8
  19. ccxt/async_support/currencycom.py +9 -9
  20. ccxt/async_support/delta.py +8 -8
  21. ccxt/async_support/digifinex.py +11 -9
  22. ccxt/async_support/gate.py +9 -8
  23. ccxt/async_support/hashkey.py +12 -10
  24. ccxt/async_support/htx.py +16 -19
  25. ccxt/async_support/hyperliquid.py +70 -117
  26. ccxt/async_support/kraken.py +12 -10
  27. ccxt/async_support/kucoin.py +12 -11
  28. ccxt/async_support/luno.py +13 -12
  29. ccxt/async_support/mexc.py +34 -2
  30. ccxt/async_support/ndax.py +9 -8
  31. ccxt/async_support/okcoin.py +21 -30
  32. ccxt/async_support/okx.py +21 -29
  33. ccxt/async_support/woo.py +10 -9
  34. ccxt/async_support/woofipro.py +11 -9
  35. ccxt/async_support/xt.py +7 -6
  36. ccxt/async_support/zonda.py +9 -8
  37. ccxt/base/exchange.py +3 -1
  38. ccxt/binance.py +40 -15
  39. ccxt/bingx.py +1 -0
  40. ccxt/bitfinex2.py +10 -9
  41. ccxt/bitget.py +13 -9
  42. ccxt/bitmex.py +14 -13
  43. ccxt/bitso.py +8 -7
  44. ccxt/bitstamp.py +12 -12
  45. ccxt/blofin.py +24 -26
  46. ccxt/bybit.py +24 -23
  47. ccxt/coinbase.py +31 -10
  48. ccxt/coinbaseexchange.py +14 -14
  49. ccxt/coinlist.py +9 -8
  50. ccxt/coinmetro.py +6 -6
  51. ccxt/cryptocom.py +10 -8
  52. ccxt/currencycom.py +9 -9
  53. ccxt/delta.py +8 -8
  54. ccxt/digifinex.py +11 -9
  55. ccxt/gate.py +9 -8
  56. ccxt/hashkey.py +12 -10
  57. ccxt/htx.py +16 -19
  58. ccxt/hyperliquid.py +70 -117
  59. ccxt/kraken.py +12 -10
  60. ccxt/kucoin.py +12 -11
  61. ccxt/luno.py +13 -12
  62. ccxt/mexc.py +33 -2
  63. ccxt/ndax.py +9 -8
  64. ccxt/okcoin.py +21 -30
  65. ccxt/okx.py +21 -29
  66. ccxt/pro/__init__.py +1 -1
  67. ccxt/pro/bybit.py +51 -0
  68. ccxt/pro/mexc.py +78 -0
  69. ccxt/test/tests_async.py +1 -1
  70. ccxt/test/tests_sync.py +1 -1
  71. ccxt/woo.py +10 -9
  72. ccxt/woofipro.py +11 -9
  73. ccxt/xt.py +7 -6
  74. ccxt/zonda.py +9 -8
  75. {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/METADATA +5 -5
  76. {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/RECORD +79 -79
  77. {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/LICENSE.txt +0 -0
  78. {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/WHEEL +0 -0
  79. {ccxt-4.4.3.dist-info → ccxt-4.4.4.dist-info}/top_level.txt +0 -0
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.gate import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
+ from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, 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
@@ -6139,7 +6139,7 @@ class gate(Exchange, ImplicitAPI):
6139
6139
  result.append(self.parse_settlement(settlements[i], market))
6140
6140
  return result
6141
6141
 
6142
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
6142
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
6143
6143
  """
6144
6144
  fetch the history of changes, actions done by the user or operations that altered the balance of the user
6145
6145
  :see: https://www.gate.io/docs/developers/apiv4/en/#query-account-book
@@ -6147,12 +6147,12 @@ class gate(Exchange, ImplicitAPI):
6147
6147
  :see: https://www.gate.io/docs/developers/apiv4/en/#query-account-book-2
6148
6148
  :see: https://www.gate.io/docs/developers/apiv4/en/#query-account-book-3
6149
6149
  :see: https://www.gate.io/docs/developers/apiv4/en/#list-account-changing-history
6150
- :param str code: unified currency code
6150
+ :param str [code]: unified currency code
6151
6151
  :param int [since]: timestamp in ms of the earliest ledger entry
6152
6152
  :param int [limit]: max number of ledger entries to return
6153
6153
  :param dict [params]: extra parameters specific to the exchange API endpoint
6154
6154
  :param int [params.until]: end time in ms
6155
- :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)
6155
+ :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)
6156
6156
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
6157
6157
  """
6158
6158
  await self.load_markets()
@@ -6243,7 +6243,7 @@ class gate(Exchange, ImplicitAPI):
6243
6243
  #
6244
6244
  return self.parse_ledger(response, currency, since, limit)
6245
6245
 
6246
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
6246
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
6247
6247
  #
6248
6248
  # spot
6249
6249
  #
@@ -6296,6 +6296,7 @@ class gate(Exchange, ImplicitAPI):
6296
6296
  else:
6297
6297
  direction = 'in'
6298
6298
  currencyId = self.safe_string(item, 'currency')
6299
+ currency = self.safe_currency(currencyId, currency)
6299
6300
  type = self.safe_string(item, 'type')
6300
6301
  rawTimestamp = self.safe_string(item, 'time')
6301
6302
  timestamp = None
@@ -6306,7 +6307,8 @@ class gate(Exchange, ImplicitAPI):
6306
6307
  balanceString = self.safe_string(item, 'balance')
6307
6308
  changeString = self.safe_string(item, 'change')
6308
6309
  before = self.parse_number(Precise.string_sub(balanceString, changeString))
6309
- return {
6310
+ return self.safe_ledger_entry({
6311
+ 'info': item,
6310
6312
  'id': self.safe_string(item, 'id'),
6311
6313
  'direction': direction,
6312
6314
  'account': None,
@@ -6321,8 +6323,7 @@ class gate(Exchange, ImplicitAPI):
6321
6323
  'after': self.safe_number(item, 'balance'),
6322
6324
  'status': None,
6323
6325
  'fee': None,
6324
- 'info': item,
6325
- }
6326
+ }, currency)
6326
6327
 
6327
6328
  def parse_ledger_entry_type(self, type):
6328
6329
  ledgerType: dict = {
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.hashkey import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, LastPrice, LastPrices, Leverage, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
9
+ from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, LastPrice, LastPrices, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, 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
@@ -2147,13 +2147,13 @@ class hashkey(Exchange, ImplicitAPI):
2147
2147
  }
2148
2148
  return self.safe_integer(types, type, type)
2149
2149
 
2150
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
2150
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
2151
2151
  """
2152
- fetch the history of changes, actions done by the user or operations that altered balance of the user
2152
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
2153
2153
  :see: https://hashkeyglobal-apidoc.readme.io/reference/get-account-transaction-list
2154
- :param str code: unified currency code, default is None(not used)
2154
+ :param str [code]: unified currency code, default is None(not used)
2155
2155
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
2156
- :param int [limit]: max number of ledger entrys to return, default is None
2156
+ :param int [limit]: max number of ledger entries to return, default is None
2157
2157
  :param dict [params]: extra parameters specific to the exchange API endpoint
2158
2158
  :param int [params.until]: the latest time in ms to fetch entries for
2159
2159
  :param int [params.flowType]: trade, fee, transfer, deposit, withdrawal
@@ -2213,7 +2213,7 @@ class hashkey(Exchange, ImplicitAPI):
2213
2213
  }
2214
2214
  return self.safe_string(types, type, type)
2215
2215
 
2216
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
2216
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
2217
2217
  #
2218
2218
  # {
2219
2219
  # "id": "1740844413612065537",
@@ -2233,7 +2233,9 @@ class hashkey(Exchange, ImplicitAPI):
2233
2233
  account = self.safe_string(item, 'accountId')
2234
2234
  timestamp = self.safe_integer(item, 'created')
2235
2235
  type = self.parse_ledger_entry_type(self.safe_string(item, 'flowTypeValue'))
2236
- code = self.safe_currency_code(self.safe_string(item, 'coin'), currency)
2236
+ currencyId = self.safe_string(item, 'coin')
2237
+ code = self.safe_currency_code(currencyId, currency)
2238
+ currency = self.safe_currency(currencyId, currency)
2237
2239
  amountString = self.safe_string(item, 'change')
2238
2240
  amount = self.parse_number(amountString)
2239
2241
  direction = 'in'
@@ -2242,9 +2244,9 @@ class hashkey(Exchange, ImplicitAPI):
2242
2244
  afterString = self.safe_string(item, 'total')
2243
2245
  after = self.parse_number(afterString)
2244
2246
  status = 'ok'
2245
- return {
2246
- 'id': id,
2247
+ return self.safe_ledger_entry({
2247
2248
  'info': item,
2249
+ 'id': id,
2248
2250
  'timestamp': timestamp,
2249
2251
  'datetime': self.iso8601(timestamp),
2250
2252
  'account': account,
@@ -2259,7 +2261,7 @@ class hashkey(Exchange, ImplicitAPI):
2259
2261
  'after': after,
2260
2262
  'status': status,
2261
2263
  'fee': None,
2262
- }
2264
+ }, currency)
2263
2265
 
2264
2266
  async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> Order:
2265
2267
  """
ccxt/async_support/htx.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.htx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Account, Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -7393,7 +7393,7 @@ class htx(Exchange, ImplicitAPI):
7393
7393
  }
7394
7394
  return self.safe_string(types, type, type)
7395
7395
 
7396
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
7396
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
7397
7397
  #
7398
7398
  # {
7399
7399
  # "accountId": 10000001,
@@ -7407,44 +7407,41 @@ class htx(Exchange, ImplicitAPI):
7407
7407
  # "transferee": 13496526
7408
7408
  # }
7409
7409
  #
7410
- id = self.safe_string(item, 'transactId')
7411
7410
  currencyId = self.safe_string(item, 'currency')
7412
7411
  code = self.safe_currency_code(currencyId, currency)
7413
- amount = self.safe_number(item, 'transactAmt')
7412
+ currency = self.safe_currency(currencyId, currency)
7413
+ id = self.safe_string(item, 'transactId')
7414
7414
  transferType = self.safe_string(item, 'transferType')
7415
- type = self.parse_ledger_entry_type(transferType)
7416
- direction = self.safe_string(item, 'direction')
7417
7415
  timestamp = self.safe_integer(item, 'transactTime')
7418
- datetime = self.iso8601(timestamp)
7419
7416
  account = self.safe_string(item, 'accountId')
7420
- return {
7417
+ return self.safe_ledger_entry({
7418
+ 'info': item,
7421
7419
  'id': id,
7422
- 'direction': direction,
7420
+ 'direction': self.safe_string(item, 'direction'),
7423
7421
  'account': account,
7424
7422
  'referenceId': id,
7425
7423
  'referenceAccount': account,
7426
- 'type': type,
7424
+ 'type': self.parse_ledger_entry_type(transferType),
7427
7425
  'currency': code,
7428
- 'amount': amount,
7426
+ 'amount': self.safe_number(item, 'transactAmt'),
7429
7427
  'timestamp': timestamp,
7430
- 'datetime': datetime,
7428
+ 'datetime': self.iso8601(timestamp),
7431
7429
  'before': None,
7432
7430
  'after': None,
7433
7431
  'status': None,
7434
7432
  'fee': None,
7435
- 'info': item,
7436
- }
7433
+ }, currency)
7437
7434
 
7438
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
7435
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
7439
7436
  """
7437
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
7440
7438
  :see: https://huobiapi.github.io/docs/spot/v1/en/#get-account-history
7441
- fetch the history of changes, actions done by the user or operations that altered balance of the user
7442
- :param str code: unified currency code, default is None
7439
+ :param str [code]: unified currency code, default is None
7443
7440
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
7444
- :param int [limit]: max number of ledger entrys to return, default is None
7441
+ :param int [limit]: max number of ledger entries to return, default is None
7445
7442
  :param dict [params]: extra parameters specific to the exchange API endpoint
7446
7443
  :param int [params.until]: the latest time in ms to fetch entries for
7447
- :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)
7444
+ :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)
7448
7445
  :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
7449
7446
  """
7450
7447
  await self.load_markets()
@@ -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 = {