Skip to main content
Glama

get_trade_book

Retrieve all trades executed during the day to track fills and execution prices. Requires authentication with DhanHQ trading APIs.

Instructions

Retrieves all trades executed during the day. Useful for tracking fills and execution prices. Requires authentication.

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "required": [], "type": "object" }

Implementation Reference

  • Core handler function that executes the tool logic by fetching the day's trade book from the Dhan API endpoint 'https://api.dhan.co/v2/trades' using the authenticated access token.
    export async function getTradeBook(): Promise<TradeBook[]> { try { log('Fetching trade book...'); const response = await axios.get<TradeBook[]>( 'https://api.dhan.co/v2/trades', { headers: getApiHeaders(), } ); log(`✓ Trade book retrieved. Total trades: ${response.data.length}`); return response.data; } catch (error) { const errorMessage = error instanceof axios.AxiosError ? `API Error: ${error.response?.status} - ${JSON.stringify(error.response?.data)}` : error instanceof Error ? error.message : 'Unknown error'; log(`✗ Failed to get trade book: ${errorMessage}`); throw new Error(`Failed to get trade book: ${errorMessage}`); } }
  • Tool schema definition including name, description, and empty input schema (no parameters required). Output is implicitly TradeBook[].
    { name: 'get_trade_book', description: 'Retrieves all trades executed during the day. Useful for tracking fills and execution prices. Requires authentication.', inputSchema: { type: 'object' as const, properties: {}, required: [], }, },
  • src/index.ts:613-624 (registration)
    MCP callTool request handler (switch case) that registers and dispatches the 'get_trade_book' tool call to the getTradeBook function and formats the response.
    case 'get_trade_book': { console.error('[Tool] Executing: get_trade_book'); const trades = await getTradeBook(); return { content: [ { type: 'text' as const, text: JSON.stringify(trades, null, 2), }, ], }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/harshitdynamite/DhanMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server