subscribeToTicker
Subscribe to real-time ticker updates for specific trading pairs on Bitget cryptocurrency exchange. Choose instrument type (SPOT or UMCBL) to monitor market data instantly.
Instructions
Subscribe to real-time ticker updates
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instType | No | Instrument type (default: SPOT) | |
| symbol | Yes | Trading pair symbol |
Input Schema (JSON Schema)
{
"properties": {
"instType": {
"description": "Instrument type (default: SPOT)",
"enum": [
"SPOT",
"UMCBL"
],
"type": "string"
},
"symbol": {
"description": "Trading pair symbol",
"type": "string"
}
},
"required": [
"symbol"
],
"type": "object"
}
Implementation Reference
- src/server.ts:505-516 (handler)MCP tool handler for subscribeToTicker: extracts symbol and instType from arguments, calls the WebSocket client's subscribe method with 'ticker' channel, and returns success message.case 'subscribeToTicker': { const { symbol, instType = 'SPOT' } = args as any; this.wsClient.subscribe('ticker', symbol, instType); return { content: [ { type: 'text', text: `Subscribed to ticker updates for ${symbol} (${instType})`, }, ], } as CallToolResult; }
- src/server.ts:257-268 (registration)Tool registration in the listTools handler, defining the name, description, and input schema for subscribeToTicker.{ name: 'subscribeToTicker', description: 'Subscribe to real-time ticker updates', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Trading pair symbol' }, instType: { type: 'string', enum: ['SPOT', 'UMCBL'], description: 'Instrument type (default: SPOT)' } }, required: ['symbol'] }, },
- src/api/websocket-client.ts:110-129 (helper)Core implementation in BitgetWebSocketClient: constructs the Bitget WS subscription message for the specified channel (e.g., 'ticker'), tracks subscription, sends it if connected or queues for reconnect.subscribe(channel: string, symbol: string, instType: 'SPOT' | 'UMCBL' | 'DMCBL' = 'SPOT'): void { const subscription: WSSubscription = { op: 'subscribe', args: [{ instType, channel, instId: symbol }] }; const subKey = `${instType}:${channel}:${symbol}`; this.subscriptions.add(subKey); if (this.isConnected && this.ws) { logger.debug('Subscribing to channel', { channel, symbol, instType }); this.ws.send(JSON.stringify(subscription)); } else { logger.warn('WebSocket not connected, subscription will be sent on reconnect', { channel, symbol }); } }