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
| Name | Required | Description | Default |
|---|---|---|---|
| orderId | Yes | Super order ID to modify | |
| dhanClientId | Yes | Your Dhan client ID | |
| legName | Yes | Which leg to modify | |
| orderType | Yes | ||
| quantity | No | New quantity | |
| price | No | New price | |
| targetPrice | No | New target price (for entry leg) | |
| stopLossPrice | No | New stop loss price | |
| trailingJump | No | New 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
- src/authentication.ts:537-573 (handler)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}`); } }
- src/index.ts:306-327 (schema)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), }, ], }; }