fetch_portfolio
Documentation for eth_defi.hyperliquid.api.fetch_portfolio function.
- fetch_portfolio(session, address, timeout=15.0)
Fetch all-time PnL and volume for any Hyperliquid address.
Calls the
portfolioinfo endpoint which returns account value history, PnL history, and volume across multiple time windows (day, week, month, allTime).Unlike the leaderboard, this works for any address — including those that have not opted in to the public leaderboard.
Example:
from eth_defi.hyperliquid.api import fetch_portfolio from eth_defi.hyperliquid.session import create_hyperliquid_session session = create_hyperliquid_session() portfolio = fetch_portfolio(session, "0x1234...") if portfolio is not None: print(f"All-time PnL: {portfolio.all_time_pnl}") print(f"All-time volume: {portfolio.all_time_volume}") # Example output: # All-time PnL: -58459.412942 # All-time volume: 1893425014.9738The raw API response is an array of
[period, data]pairs:[["day", {"accountValueHistory": [...], "pnlHistory": [...], "vlm": "..."}], ["allTime", {"accountValueHistory": [...], "pnlHistory": [[ts, pnl], ...], "vlm": "1893425014.9738"}]]- Parameters
session (eth_defi.hyperliquid.session.HyperliquidSession) – Session from
create_hyperliquid_session().address (Union[eth_typing.evm.HexAddress, str]) – Hyperliquid user address.
timeout (float) – HTTP request timeout in seconds.
- Returns
All-time PnL, volume, and first activity timestamp, or
Noneon network/API error.- Return type