Need Help - Trying to place a Cover Order on dhan using python

Dear Community,

I’m trying to place a Cover order using below method on python, but I’m getting an error. Please provide me some solution so that I can place cover order’s using python.

My code:

print (dhan.place_order(security_id= ‘1333’, exchange_segment= dhan.NSE, transaction_type= dhan.BUY, quantity=1, order_type=dhan.CO, product_type= dhan.INTRA, price=1626, trigger_price=1624.00 ))

Error :
{‘status’: ‘failure’, ‘remarks’: {‘error_code’: ‘RS-9005’, ‘message’: ‘JSON parse error: Cannot deserialize value of type co.dhan.api.model.enums.OrderType from String “CO”: not one of the values accepted for Enum class: [STOP_LOSS, STOP_LOSS_MARKET, MARKET, LIMIT]; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type co.dhan.api.model.enums.OrderType from String “CO”: not one of the values accepted for Enum class: [STOP_LOSS, STOP_LOSS_MARKET, MARKET, LIMIT]\n at [Source: (PushbackInputStream); line: 1, column: 127] (through reference chain: co.dhan.api.model.OrderRequest[“orderType”])’}, ‘data’: ‘’}

It work’s fine with Limit order and market order’s.

Hey @anksliv

First of all, welcome to Dhan Community!
Over here, as I can see, you have added CO as order_type where in fact Cover Order is a product type.

You can add order_type=dhan.LIMIT and product_type=dhan.CO and cover order should be placed. You can always refer to Dhan HQ API Documentation for reference.

Hope this helps!

2 Likes

Thanks @Hardik , It was helpful

1 Like