Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 52 additions & 8 deletions hyperliquid/info.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from hyperliquid.api import API
from hyperliquid.utils.types import Any, Callable, Meta, SpotMeta, Optional, Subscription, cast, Cloid
from hyperliquid.utils.types import Any, Callable, Meta, SpotMeta, SpotMetaAndAssetCtxs, Optional, Subscription, cast, Cloid
from hyperliquid.websocket_manager import WebsocketManager


Expand Down Expand Up @@ -179,24 +179,68 @@ def spot_meta(self) -> SpotMeta:

Returns:
{
tokens: [
universe: [
{
tokens: [int, int],
name: str,
szDecimals: int,
weiDecimals: int
index: int,
isCanonical: bool
},
...
],
universe: [
]
tokens: [
{
name: str,
tokens: [int, int]
szDecimals: int,
weiDecimals: int,
index: int,
tokenId: str,
isCanonical: bool
},
...
]
],
}
"""
return cast(SpotMeta, self.post("/info", {"type": "spotMeta"}))

def spot_meta_and_asset_ctxs(self) -> SpotMetaAndAssetCtxs:
"""Retrieve exchange spot asset contexts

POST /info

Returns:
[
{
universe: [
{
name: str,
tokens: [int, int]
}
...
],
tokens: [
{
name: str,
szDecimals: int,
weiDecimals int
},
...
]
},
[
{
dayNtlVlm: float,
markPx: float,
midPx: float,
prevDayPx: float,
circulatingSupply: float,
coin: str
}
...
]
]
"""
return cast(SpotMetaAndAssetCtxs, self.post("/info", {"type": "spotMetaAndAssetCtxs"}))

def funding_history(self, coin: str, startTime: int, endTime: Optional[int] = None) -> Any:
"""Retrieve funding history for a given coin
Expand Down
3 changes: 3 additions & 0 deletions hyperliquid/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
)
SpotMeta = TypedDict("SpotMeta", {"universe": List[SpotAssetInfo], "tokens": List[SpotTokenInfo]})

SpotAssetCtx = TypedDict("SpotAssetCtx", {"dayNtlVlm": str, "markPx": str, "midPx": Optional[str], "prevDayPx": str, "circulatingSupply": str, "coin": str})
SpotMetaAndAssetCtxs = Tuple[SpotMeta, List[SpotAssetCtx]]

AllMidsSubscription = TypedDict("AllMidsSubscription", {"type": Literal["allMids"]})
L2BookSubscription = TypedDict("L2BookSubscription", {"type": Literal["l2Book"], "coin": str})
TradesSubscription = TypedDict("TradesSubscription", {"type": Literal["trades"], "coin": str})
Expand Down