Skip to content
Open
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
30 changes: 30 additions & 0 deletions hyperliquid/info.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from hyperliquid.api import API
from hyperliquid.utils.types import (
ActiveAssetData,
Any,
Callable,
Cloid,
Expand Down Expand Up @@ -762,6 +763,35 @@ def extra_agents(self, user: str) -> Any:
"""
return self.post("/info", {"type": "extraAgents", "user": user})

def user_active_asset_data(self, user: str, name: str) -> ActiveAssetData:
"""Retrieve a user's leverage and trading limits for a given coin.

POST /info

Args:
user (str): Onchain address in 42-character hexadecimal format;
e.g. 0x0000000000000000000000000000000000000000.
name (str): Coin to retrieve active asset data for.

Returns:
{
user: str,
coin: str,
leverage: {
type: "cross" | "isolated",
value: int,
rawUsd: float string # only if type is "isolated"
},
maxTradeSzs: [float string, float string],
availableToTrade: [float string, float string],
markPx: float string
}
"""
return cast(
ActiveAssetData,
self.post("/info", {"type": "activeAssetData", "user": user, "coin": self.name_to_coin[name]}),
)

def _remap_coin_subscription(self, subscription: Subscription) -> None:
if (
subscription["type"] == "l2Book"
Expand Down
Loading