Skip to content

Feature: Add function to retrieve user leverage for a specific coin #274

@xdmaury

Description

@xdmaury

I was looking for a way to retrieve the current leverage configured for a specific coin using the Hyperliquid SDK, but I couldn't find a method that exposes this information.

It might already exist and I missed it, but after checking the SDK I couldn't find a direct function for this.

Why this would be useful

For trading bots and automated systems, it's often necessary to know the current leverage configured for a specific asset before placing or managing orders.

Having this directly available in the SDK would avoid the need to manually query the API.

Current workaround

The alternative I found was to manually call the /info endpoint with the activeAssetData request type.

Example (Python):

def _make_api_request(self, endpoint: str, method: str = "GET", **kwargs):
    url = self.base_url + endpoint
    response = requests.post(url, timeout=10, **kwargs)
    response.raise_for_status()
    return response.json()

def _get_user_active_assets(self, user_address: str, coin: str):
    payload = {
        "type": "activeAssetData",
        "user": user_address,
        "coin": coin
    }
    return self._make_api_request("/info", method="POST", json=payload)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions