Skip to main content
Glama

modify_order

Update pending trading orders by changing price, quantity, order type, or other parameters through the DhanHQ trading platform.

Instructions

Modifies a pending order. Can change price, quantity, order type, and other parameters. Requires authentication.

Input Schema

NameRequiredDescriptionDefault
orderIdYesOrder ID to modify
dhanClientIdYesYour Dhan client ID
orderTypeYes
quantityNoNew quantity
priceNoNew price (for LIMIT/STOP_LOSS)
triggerPriceNoNew trigger price (for STOP_LOSS/STOP_LOSS_MARKET)
disclosedQuantityNoNew disclosed quantity

Input Schema (JSON Schema)

{ "properties": { "dhanClientId": { "description": "Your Dhan client ID", "type": "string" }, "disclosedQuantity": { "description": "New disclosed quantity", "type": "number" }, "orderId": { "description": "Order ID to modify", "type": "string" }, "orderType": { "enum": [ "MARKET", "LIMIT", "STOP_LOSS", "STOP_LOSS_MARKET" ], "type": "string" }, "price": { "description": "New price (for LIMIT/STOP_LOSS)", "type": "number" }, "quantity": { "description": "New quantity", "type": "number" }, "triggerPrice": { "description": "New trigger price (for STOP_LOSS/STOP_LOSS_MARKET)", "type": "number" } }, "required": [ "orderId", "dhanClientId", "orderType" ], "type": "object" }

Implementation Reference

  • Core handler function that executes the HTTP PUT request to the Dhan API to modify a pending order.
    export async function modifyOrder( orderId: string, request: ModifyOrderRequest ): Promise<OrderResponse> { try { log(`Modifying order: ${orderId}`); const response = await axios.put<OrderResponse>( `https://api.dhan.co/v2/orders/${orderId}`, request, { headers: getApiHeaders(), } ); log(`✓ Order modified successfully. Order ID: ${response.data.orderId}`); 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 modify order: ${errorMessage}`); throw new Error(`Failed to modify order: ${errorMessage}`); } }
  • src/index.ts:167-187 (registration)
    MCP tool registration defining the 'modify_order' tool name, description, and input schema.
    { name: 'modify_order', description: 'Modifies a pending order. Can change price, quantity, order type, and other parameters. Requires authentication.', inputSchema: { type: 'object' as const, properties: { orderId: { type: 'string', description: 'Order ID to modify' }, dhanClientId: { type: 'string', description: 'Your Dhan client ID' }, orderType: { type: 'string', enum: ['MARKET', 'LIMIT', 'STOP_LOSS', 'STOP_LOSS_MARKET'], }, quantity: { type: 'number', description: 'New quantity' }, price: { type: 'number', description: 'New price (for LIMIT/STOP_LOSS)' }, triggerPrice: { type: 'number', description: 'New trigger price (for STOP_LOSS/STOP_LOSS_MARKET)' }, disclosedQuantity: { type: 'number', description: 'New disclosed quantity' }, }, required: ['orderId', 'dhanClientId', 'orderType'], }, },
  • TypeScript interface defining the structure of the ModifyOrderRequest used by the handler.
    export interface ModifyOrderRequest { dhanClientId: string; orderId: string; orderType: 'LIMIT' | 'MARKET' | 'STOP_LOSS' | 'STOP_LOSS_MARKET'; quantity?: number; price?: number; triggerPrice?: number; disclosedQuantity?: number; }
  • MCP server request handler that processes 'modify_order' tool calls and delegates to the core modifyOrder function.
    case 'modify_order': { console.error('[Tool] Executing: modify_order'); const modifyArgs = args as Record<string, unknown>; const result = await modifyOrder(modifyArgs.orderId as string, { dhanClientId: modifyArgs.dhanClientId as string, orderId: modifyArgs.orderId as string, orderType: modifyArgs.orderType as 'LIMIT' | 'MARKET' | 'STOP_LOSS' | 'STOP_LOSS_MARKET', quantity: modifyArgs.quantity as number | undefined, price: modifyArgs.price as number | undefined, triggerPrice: modifyArgs.triggerPrice as number | undefined, disclosedQuantity: modifyArgs.disclosedQuantity as number | undefined, }); return { content: [ { type: 'text' as const, text: JSON.stringify(result, 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