Historical Holdings
It provides comprehensive realtime and historical coverage of USD holdings for a given wallet. These endpoints are based on balance history and price data aggregated over set granularities. Prices are derived from Allium’s real-time DEX trade feeds. Holdings are aggregated at 15s, 5m, 1h, and 1d level granularities with corresponding retentions. Key Features:- Real-Time & Historical Data: Latest balances & prices update in real time, while historical holdings data is available for tracking portfolios over time.
- Aggregated Coverage: USD Holdings for each wallet is aggregated over all tokens that a user holds and returned at set time granularities.
- Single Call Multi-chain Support: Request aggregated holdings across several chains in a single API call.
- PnL Calculation: Calculate the PnL of a portfolio over a given time period.
- Currently, the Holdings API only supports Bitcoin and Solana.
- Support for additional chains and liquidity pool-based pricing is in development.
PnL
PnL calculation requires knowing the average cost of a wallet’s tokens. Average Cost is based on the average cost basis method calculated by taking a weighted average of all token purchases and reweighting the average cost during sale events.Methodology
- PnL calculation is based on token balances
- Realized PnL is calculated by multiplying the number of tokens sold with the difference between sold price and average price
- Unrealized PnL is calculated by multiplying the number of tokens held with the difference between current price and average price
Latest PnL
How is Latest PnL calculated? PnL is calculated using the following formula:Latest PnL = Current Balance(Token) x (Current USD Price(Token) - Average Cost(Token))
- Current Balance(Token) = Latest balance of the token for the given address
- Current USD Price(Token) = Latest price of the token in USD
- Average Cost(Token) = Average cost of the token for the given address
- Invalid data (such as unsupported chains or invalid address/token address) returns status code 400.
Buy/Sell | Token | Amt | Balance | Price | Avg Cost Calculation | PnL |
---|---|---|---|---|---|---|
Buy | SOL | 50 | 50 | $210 | (50 * $210) / (50) | 0 |
Buy | SOL | 10 | 60 | $200 | (50 * 200) / (50 + 10) | -$500 |
Sell | SOL | 10 | 50 | $220 | 50 * avg cost / 50 = 50 * ((50 * 200) / (50 + 10)) / 50 | $583.50 |
Sell | SOL | 2 | 48 | $220 | 48 * avg cost / 48 = 48 * ((50 * 200) / (50 + 10)) / 48 | $560.16 |
User checking app | 48 | $230 | 48 * $208.33 / 48 | $1040.16 | ||
Buy | SOL | 7 | 55 | $180 | 48 * $208.33 + 7 * 180 / 48 + 7 | -$1359.84 |
User checking app | 55 | $185 | 48 * $208.33 + 7 * 180 / 48 + 7 = 204.72 | -$1084.6 |
Historical PnL
How is Historical PnL calculated? PnL is calculated using the following formula:Historical PnL between time X and time Y = Realized PnL from sales between X and Y + (Total unrealized PnL at time Y calculated from genesis - Total unrealized PnL at time X calculated from genesis)
- Invalid data (such as unsupported chains or invalid address/token address) returns status code 400.
- If
end_timestamp
is earlier thanstart_timestamp
, an error will be returned - If
end_timestamp
is in the future, it will be adjusted to the current time - If a wallet has no holdings or does not exist, the endpoint will interpolate the aggregated pnl to be 0