Skip to content

feat: add user_active_asset_data to Info - #329

Open
manantlerio wants to merge 1 commit into
hyperliquid-dex:masterfrom
manantlerio:feat/active-asset-data
Open

manantlerio wants to merge 1 commit into
hyperliquid-dex:masterfrom
manantlerio:feat/active-asset-data

Conversation

@manantlerio

Copy link
Copy Markdown

Closes #274

Adds Info.user_active_asset_data(user, name), which posts {"type": "activeAssetData", "user": ..., "coin": ...} to /info. It returns the user's current leverage for that coin ({"type": "cross" | "isolated", "value": int}, plus rawUsd when isolated), along with maxTradeSzs, availableToTrade and markPx.

It follows the existing Info methods: name is resolved through name_to_coin like l2_snapshot and funding_history, and the return value is typed with the existing ActiveAssetData TypedDict that the activeAssetData websocket subscription already uses.

Tests: added test_user_active_asset_data with a recorded VCR cassette, matching the other info tests. pytest passes (37 passed), and pre-commit passes (black, isort, flake8, pylint, bandit, mypy).

AI assistance was used in preparing this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant