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.
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.
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.
Hi @Hardik , first question will this work on options buy as well? If i want to buy a call option at market price and add the stop loss then what should be my parameters, could you share it? I see order type as LIMIT, Market, SL, SLM in API documentation. Should it be SLM or Market or it is LIMIT only? Second question, whether product_type should be ‘INTRA’ in this case or ‘CO’? Could you share the request parameters for call option buy at market price with stop loss.
Need one more clarification, If I want to buy a security(equity) and want to hold as in the case of swing trading, what parameter value do I use for validity and product_type, could you share with me the request structure I need to pass? Also, could you tell me which parameters I do not need to pass since this will be a market order. I want to keep the request structure simple and minimal.
In case of swing trading, you cannot use BO for same, as Bracket Order is valid only for single day.
You can keep the check at your end, using Live Market Feed and place orders whenever price is reached. We do have Forever Order API on our roadmap, till then, you can keep this at your end.
So the parameters I sent you will work right, is that what you mean? Could you please confirm the parameters for validity and product_type I sent you for placing a market order?
Thank you Hardik, I will try to explain better. I do not want to place a BO order, I just want to buy at market price for positional trades, I am not looking to trade intraday. if I want to buy 1 share of TCS at market price and hold, in this case what required parameters should I pass? I got this error today:
Error placing buy order for VEDL: dhanhq.place_order() got an unexpected keyword argument ‘bo_stop_loss_value’
There is no Exit All Position option with Webhooks, as Webhook Orders are for alert based execution from charts. To exit any position, you can simply trigger alert with JSON which has opposite order type of same quantity.
For example, if you have long position, you can configure sell JSON with same quantity to exit the position.
Hi Hardik,
Ive placed a BO order with the below parameters, but the stock was immediately purchased even before it touched the trigger price which was much higher than the current price.
it shoul,d have waited for the price to hit trigger price and buy at the limit price but it didnt but still went ahead and bouhgt it even before the price reached trigger price.
WHat could be the error in the code?