Not able to place forever order using api or python library - DH 906

I am not able to place forever order using API or Python Library, here is my code snippet. Please suggest what is wrong

    url = "https://api.dhan.co/v2/forever/orders"
    headers = {"access-token": <ACCESS_TOKEN>, "Content-Type": "application/json", "Accept": "application/json"}

    payload = {"dhanClientId": "1111967573",

        "orderFlag": "SINGLE",

        "transactionType": "SELL",

        "exchangeSegment": "NSE_EQ",

        "productType": "CNC",

        "orderType": "LIMIT",

        "validity": "DAY",

        "securityId": "3499",

        "quantity": 1,

        "disclosedQuantity": 1,

        "price": 189.55,

        "triggerPrice": 190.5}
    
    res = requests.post(url, headers=headers, json=payload)

I tried to place the same order using python library but it is not going through, able to put the same using dhan app though

Hi @uppert
can you also share the error you are getting
Also are you sending the order from the same server, which is registered in
Dhan api page > static ip panel

Hi @Tradehull_Imran

Here is the error message

b’{“errorType”:“Order_Error”,“errorCode”:“DH-906”,“errorMessage”:“Incorrect request for order and cannot be processed”}’

I am running this on Dhan cloud, the normal order I am able to put through API on this, getting error only for this. Doesn’t seem like an ip issue

Hi @uppert
yes this is not a IP issue,

try use below code , it worked fine on my end


{
    "dhanClientId": "2601292566",
    "orderFlag": "SINGLE",
    "transactionType": "BUY",
    "exchangeSegment": "NSE_EQ",
    "productType": "CNC",
    "orderType": "LIMIT",
    "validity": "DAY",
    "securityId": "3499",
    "quantity": 5,
    "price": 189.55,
    "triggerPrice": 190.5
}

Thanks @Tradehull_Imran

Its working for ‘BUY’, but not for ‘SELL’, any potential reason for that?

I think this may be a DDPI activation issue

sir why cannot u bring algo on dhan platform as i am confident that we retailer do trust on you heavily on your knowledge. their is no system where we can deploy one lot or two lot for retailer its high demand write now on dhan platform minimum amt to deploy is 1 lac 2lac which is not available with retailer

Hi @kanhaji ,

Sure, we will look into this.

@Tradehull_Imran Thanks, after activating DDPI, it started working

1 Like

i am also in favour of this why donot u bring your algo people have so much faith on you regarding algo trading.

1 Like