Unable to modify Stop_loss_leg of Super Orders in NSE via API

Is there a way to modify super order stop loss and target legs in NSE.

The same works in MCX but not in NSE…

Kindly clarify or suggest a work around…

please treat this urgent and do not take EONS to respond or ignore…

Hey @Jose_Kiran ,

We request you to please share the request structure for the modification of the stop-loss leg with us over email at help@dhan.co.

Mail Sent to you.
Copying below for ease of reference, and to be of help for others with similar probs.

Hi,

Please find attached the request structure below.

The background is as below. I will enter in NSE_FNO using super order with a wide SL and Target. Whenever my exit conditions are met, I will modify the SL Leg and exit… But When I try modifying the SL leg it is showing an error. However, the code worked smoothly in MCX.

the error message is as below

Error modifying stop-loss leg: {“errorType”:“Order_Error”,“errorCode”:“DH-906”,“errorMessage”:“Incorrect request for order and cannot be processed”} PS D:\Markets\Algo\RJStrategy - SMA based Entry - Exit on Reversal>

#==================================#

1.0 Imports for the Project

#==================================#

import pandas as pd

from dhanhq import dhanhq

from dhanhq.marketfeed import DhanFeed

from datetime import date, datetime, timedelta

import requests

import json

client_id = “11823113”

api_token = “eyJjhbajsdj…”

dhan = dhanhq(client_id, api_token)

version = “v2”

Constants

order_id = “3432510245069471”

new_stop_loss_price = 120.00

quantity = 75

API endpoint and headers

url = f"https://api.dhan.co/v2/super/orders/{order_id}"

headers = {

“Content-Type”: “application/json”,

“access-token”: api_token

}

Define the request payload

payload = {

“dhanClientId”: client_id,

“orderId”: order_id,

“orderType”: “LIMIT”,

“legName”: “STOP_LOSS_LEG”,

“stopLossPrice”: new_stop_loss_price

}

try:

response = requests.put(url, headers=headers, data=json.dumps(payload))

if response.status_code == 200:

print(“Stop-loss leg modified successfully”)

else:

print(“Error modifying stop-loss leg:”, response.text)

except Exception as e:

print(“Error modifying stop-loss leg:”, str(e))

Best regards,

Thank for the timely update over Email… :pray:

It is working now.

Many thanks.

JK

1 Like