Calculate unrealized G/L with auto-fetched prices
const url = 'https://api.qeychain.xyz/api/calculate/unrealized-gl/example';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://api.qeychain.xyz/api/calculate/unrealized-gl/exampleCalculates unrealized gain/loss for all open lots with AUTOMATIC price fetching.
This endpoint:
1. Fetches all transactions from Zerion
2. Enriches historical prices from CoinGecko (for missing Zerion prices)
3. Fetches current prices from CoinGecko
4. Calculates unrealized G/L for all open positions
No need to manually provide current_prices - they are fetched automatically.
Note: This endpoint may be slower due to CoinGecko rate limits. For high-frequency
use, consider caching the prices or using the POST /unrealized-gl endpoint
with pre-fetched prices.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Query Parameters
Section titled “Query Parameters”All wallet addresses owned by the user (for internal transfer detection)
Responses
Section titled “Responses”Successful Response
Portfolio-level unrealized gain/loss response.
object
Unrealized G/L by asset (keyed by token_key)
object
Unrealized G/L aggregated by asset.
object
Token symbol
Blockchain network
Total quantity held
Current market price
Total cost basis
Current market value
Unrealized gain/loss
Unrealized G/L as percentage
Per-lot breakdown
Unrealized G/L for a single lot.
object
Lot identifier
Remaining quantity in lot
Cost basis per unit
Current market price
Total cost basis (remaining)
Current market value
Unrealized gain/loss
Whether lot has unknown cost basis
Total unrealized G/L across all assets
Sum of positive unrealized G/L
Sum of negative unrealized G/L (as positive number)
Total cost basis of open positions
Total current market value of open positions
Portfolio unrealized G/L as percentage of cost basis
Example
{ "by_asset": { "additionalProperty": { "lots": [ { "is_untracked": false } ] } }}Bad Request
Not Found
Validation Error
object
object
Examplegenerated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example" } ]}Internal Server Error
