Skip to main content
Glama

modify_super_order

Modify pending or partially traded super orders by updating specific legs like entry, target, or stop loss with new parameters such as price, quantity, or order type.

Instructions

Modifies any leg of a pending or part-traded super order. Requires authentication.

Input Schema

NameRequiredDescriptionDefault
orderIdYesSuper order ID to modify
dhanClientIdYesYour Dhan client ID
legNameYesWhich leg to modify
orderTypeYes
quantityNoNew quantity
priceNoNew price
targetPriceNoNew target price (for entry leg)
stopLossPriceNoNew stop loss price
trailingJumpNoNew trailing jump amount

Input Schema (JSON Schema)

{ "properties": { "dhanClientId": { "description": "Your Dhan client ID", "type": "string" }, "legName": { "description": "Which leg to modify", "enum": [ "ENTRY_LEG", "TARGET_LEG", "STOP_LOSS_LEG" ], "type": "string" }, "orderId": { "description": "Super order ID to modify", "type": "string" }, "orderType": { "enum": [ "MARKET", "LIMIT", "STOP", "STOP_LIMIT" ], "type": "string" }, "price": { "description": "New price", "type": "number" }, "quantity": { "description": "New quantity", "type": "number" }, "stopLossPrice": { "description": "New stop loss price", "type": "number" }, "targetPrice": { "description": "New target price (for entry leg)", "type": "number" }, "trailingJump": { "description": "New trailing jump amount", "type": "number" } }, "required": [ "orderId", "dhanClientId", "legName", "orderType" ], "type": "object" }

Implementation Reference

  • The core handler function implementing the logic to modify a specific leg of a super order by sending a PUT request to the DhanHQ API endpoint.
    export async function modifySuperOrder( orderId: string, legName: string, request: Record<string, unknown> ): Promise<OrderResponse> { try { log(`Modifying super order: ${orderId}, leg: ${legName}`); const payload = { ...request, legName, }; const response = await axios.put<OrderResponse>( `https://api.dhan.co/v2/super/orders/${orderId}`, payload, { headers: getApiHeaders(), } ); log( `✓ Super 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 super order: ${errorMessage}`); throw new Error(`Failed to modify super order: ${errorMessage}`); } }
  • Input schema defining the parameters, types, enums, descriptions, and required fields for the modify_super_order tool.
    inputSchema: { type: 'object' as const, properties: { orderId: { type: 'string', description: 'Super order ID to modify' }, dhanClientId: { type: 'string', description: 'Your Dhan client ID' }, legName: { type: 'string', enum: ['ENTRY_LEG', 'TARGET_LEG', 'STOP_LOSS_LEG'], description: 'Which leg to modify', }, orderType: { type: 'string', enum: ['MARKET', 'LIMIT', 'STOP', 'STOP_LIMIT'], }, quantity: { type: 'number', description: 'New quantity' }, price: { type: 'number', description: 'New price' }, targetPrice: { type: 'number', description: 'New target price (for entry leg)' }, stopLossPrice: { type: 'number', description: 'New stop loss price' }, trailingJump: { type: 'number', description: 'New trailing jump amount' }, }, required: ['orderId', 'dhanClientId', 'legName', 'orderType'], },
  • src/index.ts:302-328 (registration)
    The tool registration object that defines the name, description, and references the input schema; included in the tools list returned by ListTools.
    { name: 'modify_super_order', description: 'Modifies any leg of a pending or part-traded super order. Requires authentication.', inputSchema: { type: 'object' as const, properties: { orderId: { type: 'string', description: 'Super order ID to modify' }, dhanClientId: { type: 'string', description: 'Your Dhan client ID' }, legName: { type: 'string', enum: ['ENTRY_LEG', 'TARGET_LEG', 'STOP_LOSS_LEG'], description: 'Which leg to modify', }, orderType: { type: 'string', enum: ['MARKET', 'LIMIT', 'STOP', 'STOP_LIMIT'], }, quantity: { type: 'number', description: 'New quantity' }, price: { type: 'number', description: 'New price' }, targetPrice: { type: 'number', description: 'New target price (for entry leg)' }, stopLossPrice: { type: 'number', description: 'New stop loss price' }, trailingJump: { type: 'number', description: 'New trailing jump amount' }, }, required: ['orderId', 'dhanClientId', 'legName', 'orderType'], }, },
  • src/index.ts:668-684 (registration)
    Registration of the tool execution handler within the MCP CallTool request switch statement, which parses arguments and invokes the core modifySuperOrder function.
    case 'modify_super_order': { console.error('[Tool] Executing: modify_super_order'); const modSOArgs = args as Record<string, unknown>; const result = await modifySuperOrder( modSOArgs.orderId as string, modSOArgs.legName as string, modSOArgs ); 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