get_order_history
Retrieve past order details and status from your Groww account, with optional filtering by date range to track transaction history.
Instructions
Past orders with status, optionally filter by date range
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | No | Start date (YYYY-MM-DD) | |
| end_date | No | End date (YYYY-MM-DD) |
Implementation Reference
- src/tools/portfolio.ts:98-130 (handler)Tool registration and handler implementation for get_order_history.
server.tool( "get_order_history", "Past orders with status, optionally filter by date range", { start_date: z.string().optional().describe("Start date (YYYY-MM-DD)"), end_date: z.string().optional().describe("End date (YYYY-MM-DD)"), }, async ({ start_date, end_date }) => { try { const orders = await growwClient.getOrderHistory(start_date, end_date); if (orders.length === 0) return mcpText("📭 No orders found for the given period."); const statusEmoji: Record<string, string> = { EXECUTED: "✅", PENDING: "⏳", CANCELLED: "❌", REJECTED: "🚫", PARTIAL: "🔶", }; const lines = orders.map((o) => { const emoji = statusEmoji[o.status] || "❓"; return [ `${emoji} ${o.orderId} — ${o.orderType} ${o.symbol}.${o.exchange}`, ` ${o.priceType} / ${o.productType} | Qty: ${o.quantity} | Price: ${o.price > 0 ? formatCurrencyExact(o.price) : "MARKET"}`, ` Status: ${o.status}${o.filledQuantity > 0 ? ` (filled ${o.filledQuantity} @ ${formatCurrencyExact(o.avgFilledPrice)})` : ""}`, ` ${new Date(o.timestamp).toLocaleString("en-IN", { timeZone: "Asia/Kolkata" })}${o.remarks ? ` — ${o.remarks}` : ""}`, ].join("\n"); }); const header = `📋 ORDER HISTORY (${orders.length} orders)\n${"─".repeat(50)}`; return mcpText([header, ...lines].join("\n\n")); } catch (err) { return mcpError(normalizeError(err)); } } );