Position PnL Chart
Get historical Profit and Loss (PnL) time-series data for a specific position, identified by account, term, and curve.
Query Structureβ
query GetPositionPnlChart($input: GetPositionPnlChartInput!) {
getPositionPnlChart(input: $input) {
account_id
term_id
curve_id
count
data
interval
}
}
Variablesβ
The query takes a single input object:
| Field | Type | Required | Description |
|---|---|---|---|
account_id | String | Yes | Account address owning the position |
term_id | String | Yes | Term ID identifying the position's atom or triple |
curve_id | String | Yes | Curve ID identifying the bonding curve |
interval | String | Yes | Time interval for data points (e.g. "1h", "1d", "1w", "1M") |
start_time | String | Yes | Start of the time range (ISO 8601 timestamp) |
end_time | String | Yes | End of the time range (ISO 8601 timestamp) |
{
"input": {
"account_id": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"term_id": "0x57d94c116a33bb460428eced262b7ae2ec6f865e7aceef6357cec3d034e8ea21",
"curve_id": "1",
"interval": "1d",
"start_time": "2024-01-01T00:00:00Z",
"end_time": "2024-01-31T23:59:59Z"
}
}
Response Fieldsβ
| Field | Type | Description |
|---|---|---|
account_id | String | The queried account address |
term_id | String | The term ID for this position |
curve_id | String | The curve ID for this position |
count | Int | Number of data points returned |
data | JSON | Array of PnL data points for the time range |
interval | String | The interval used for aggregation |
Expected Responseβ
{
"data": {
"getPositionPnlChart": {
"account_id": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"term_id": "0x57d94c116a33bb460428eced262b7ae2ec6f865e7aceef6357cec3d034e8ea21",
"curve_id": "1",
"count": 31,
"data": [
{
"timestamp": "2024-01-01T00:00:00Z",
"equity_value": "1.000000000000000000",
"net_invested": "1.000000000000000000",
"total_pnl": "0.000000000000000000",
"pnl_pct": 0.0
},
{
"timestamp": "2024-01-02T00:00:00Z",
"equity_value": "1.200000000000000000",
"net_invested": "1.000000000000000000",
"total_pnl": "0.200000000000000000",
"pnl_pct": 20.0
}
],
"interval": "1d"
}
}
}
Interactive Exampleβ
Query
query GetPositionPnlChart($input: GetPositionPnlChartInput!) {
getPositionPnlChart(input: $input) {
account_id
term_id
curve_id
count
data
interval
}
}Variables
Click "Run Query" to execute the GraphQL query and see results
Use Casesβ
Position Detail Pageβ
Show detailed performance for a single position:
import { GraphQLClient } from 'graphql-request'
import { API_URL_PROD } from '@0xintuition/graphql'
const client = new GraphQLClient(API_URL_PROD)
async function getPositionPerformance(
accountId: string,
termId: string,
curveId: string,
days: number = 30
) {
const endTime = new Date()
const startTime = new Date()
startTime.setDate(startTime.getDate() - days)
const query = `
query GetPositionPnlChart($input: GetPositionPnlChartInput!) {
getPositionPnlChart(input: $input) {
account_id
term_id
curve_id
count
data
interval
}
}
`
const data = await client.request(query, {
input: {
account_id: accountId,
term_id: termId,
curve_id: curveId,
interval: '1d',
start_time: startTime.toISOString(),
end_time: endTime.toISOString()
}
})
return data.getPositionPnlChart
}
Best Practicesβ
- Include
curve_id- This is a required field that identifies which bonding curve the position belongs to - Match intervals to timeframe - Use
"1h"for recent data,"1d"for longer periods - Combine with account PnL - Use alongside
getAccountPnlChartfor portfolio-level context
Relatedβ
- Account PnL Chart - Portfolio-level PnL charts
- Account PnL Realized - Realized PnL data
- Vault Details - Vault information for the position