Overview
The PortfolioFetcher retrieves your profile, open positions, and trading history from the Limitless Exchange API. It requires an authenticated HttpClient.
Setup
PortfolioFetcher requires an authenticated client. Use WithHMACCredentials with a scoped API token (recommended). The legacy LIMITLESS_API_KEY / WithAPIKey still works but is not recommended for new integrations.
Current Profile
Use GetCurrentProfile() to fetch the authenticated caller’s private profile via GET /profiles/me. This is the preferred helper when the client is already authenticated and you do not want to pass a wallet address.
Fetching a Profile by Address
Use GetProfile() to retrieve a user profile by wallet address:
UserProfile Fields
Fetching All Positions
Use GetPositions() to retrieve all your open positions:
The response is a PortfolioPositionsResponse with the following fields:
CLOB Positions
Use GetCLOBPositions() for CLOB-only positions, or iterate over positions.CLOB:
CLOBPosition Fields
AMM Positions
Use GetAMMPositions() for AMM-only positions:
AMMPosition Fields
Trading History
Use GetUserHistory() to retrieve cursor-paginated trading history. The signature is GetUserHistory(ctx, cursor string, limit int) — pass an empty cursor for the first page, then *history.NextCursor for subsequent pages:
Complete Example