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