Monitor real-time underlying asset price updates for trading pairs.
| Parameter | Required | Description |
|---|
pair | Yes | Trading pair (e.g., "BTC_USDC", "ETH_USDC", "ARB_USDC") |
{
"type": "subscribe",
"subscriptions": [
{
"channel": "index_price",
"query": {
"pair": "BTC_USDC"
}
}
]
}
{
"kind": "event",
"type": "index_price",
"timestamp_ms": 1677721600000,
"data": {
"value": 45000.5,
"timestamp": 1677721600000
},
"subscription": {
"channel": "index_price",
"query": {
"pair": "BTC_USDC"
}
}
}
| Field | Type | Description |
|---|
data.value | number | Current index price |
data.timestamp | number | Price timestamp in milliseconds |
import WebSocket from 'ws';
const ws = new WebSocket('wss://staging.kyan.sh/ws');
const API_KEY = 'your-api-key-here';
ws.onopen = () => {
ws.send(JSON.stringify({ type: 'auth', api_key: API_KEY }));
};
ws.onmessage = (event) => {
const message = JSON.parse(event.data.toString());
if (message.type === 'auth' && message.success) {
ws.send(JSON.stringify({
type: 'subscribe',
subscriptions: [
{ channel: 'index_price', query: { pair: 'BTC_USDC' } }
]
}));
ws.onmessage = handleMessages;
}
};
function handleMessages(event: WebSocket.MessageEvent) {
const message = JSON.parse(event.data.toString());
if (message.event === 'index_price') {
console.log('New index price:', message.data.value);
}
}
| Channel | Why |
|---|
| Funding | Funding rate is driven by the basis (perp price - index). Index price is one side of that equation. |
| Position | Perps position mark_price is derived from index. Index changes shift unrealised PnL. |
| Account State | equity and unrealised_pnl move with index price. |
| Orderbook Perps | Order prices relative to index give you the basis at each level. |