Order placement - Error

hi @t7support

This isn’t a bug, we have mentioned it here - it’s alert when you are trying to exit a position on which you have a hedge benefit.

More on these alerts here: Update for Option Traders: Introducing Alerts on Breaking Hedge while Trading on Options on Dhan

Earlier when traders broke this hedge, there was a penalty that was being passed on to clients. Exchanges / Regulators have now prohibited brokers to pass on the penalty to clients - so if you exit, the penalty will still be there and Dhan will have to pay it. Hence to avoid such situations, we have introduced this alerts.

@PravinJ This is a bug !!!

Last week I had sold 18900 call and bought 18300 call. Today from the basket order I first bought back 18900 call. Then tried to sell 18300 call. There is no hedge break scenario here.

Please fix this error.


It seems Dhan backend is not recognising the non existence of the short leg with in the milli second delay the next exit order of the long leg is placed when fired via the basket order.


This bug essentially means we cannot exit hedged positions via basket orders directly or via TV webhooks. Please disable this new feature until the bug is fixed or fix it ASAP.

1 Like

@PravinJ @Dhan_Help @Naman @Hardik

The error happened again today.

How are the orders sent out when a basket is executed via tv webhook ? Is it in sequential top down order as set in basket ? Is it that all orders in basket are sent to exchanges in one go and so there is a likelihood of the order queue changing (different from the set basket)


Dear Dhan, I have already pointed this in a different context at the thread
“Yes Pj and Naman… Please give the user a way such that if the 1st leg is successful then execute the second leg so on as so forth . In this way we can avoid margin issue. Also, if you can allow drag and drop strike prices as per user preference is his order of preference that would be great”

At least implement this for market order. though limit orders in basket order may be an an bit complex in implementation

The full thread is given below

Hi @t7support

We have gone through your order logs and found out few things. This is a rare phenomenon and can happen with anyone. There is little control of broker in this. Here is the explanation:

Let us first understand the execution of Basket Order. The basket order is placed in the same sequence as arranged in the basket. You will get the hedge benefit upfront (or the overall margin will be same as shown in basket) only when the sequence of execution of orders is followed. There may be a case when your first order (say Buy market order for options) is placed first but didn’t execute or executed lately for some reason. And then second order ( say Sell market order for options) is placed. Since the Buy order is not executed, so your Sell order may reject if there is insufficient funds. The reason for non-execution or delayed execution of Buy market order can be anything : Low liquidity or MPP on options so market order is converted to limit order or delayed response from exchange etc…

Next let us understand the concept of “Hedge Break Alert”. In the above case, if all orders are successfully executed, you will get upfront hedge benefit, hence lower margin requirement to execute option strategy. Point to note, the Sell leg (short position) is hedged by the Buy leg (long position). The standalone short position has higher margin requirement than with a hedge. So if you try to exit long position first, then you must maintain sufficient margin to sustain standalone short position or exit the short position first. If this is not followed, our system will alert you about the Hedge Break and will not let you exit the strategy to avoid any margin shortfall.

Now in your case, you are doing it correct with basket order. Exiting the short open position first (with Buy order of 18050 PE) and then long open position (with Sell order of 18600 PE). But for some reason (it may be any as mentioned above but non exhaustive) your Buy order of 18050 PE is not executed before the Sell order of 18600 PE is placed, hence you got a hedge break alert message. All this happened in fraction of second. Though after few millisecond the Buy order of 18050PE is successfully executed as it was placed earlier. Later when you manually exited 18600 PE it went successfully.

Trust me, all this happened in fraction of seconds.

This is very rare, and cant be controlled. The only suggestion from my side will be to avoid trading in illiquid contracts or try placing order manually. Even if you are automating your system, make a rule to place next order only when you have a confirmation of successful execution of first.

Hope this helps!

1 Like

yes this happened sometimes. but experience is fantastic with @Dhan

Not at all rare. All my and fellow trader orders triggered since Dhan brought in hedge break alerts have failed.

As far as I know exchanges process the orders on a FIFO basis. The first order has to be executed before the next order in queue is executed. All of these are market orders and hence should have gone through at the best price available as I set the basket order correctly.

I trade on liquid options. All the sell and buy legs have sufficient liquidity. If hedge break system at your end is waiting for the first sell leg exit confirmation and it is delayed for whatever reason and it causes an order failure at customer end its not a good system to have as is. May be Dhan can wait for few seconds. If the user doesn’t have sufficient margin still you can raise alert or auto square off the position. Either of these is better than an order failure.

I understand. Execution happens at nano second intervals these days. But order confirmation processing at your end this fast and before the next order is fired ? Please don’t penalize the customer via order failures because of the new system you guys brought in.

Can be controlled. Please go through my above suggestions.

I switched to Dhan to autotrade via tradingview webhooks.

Dhan can do the same with detected hedged orders too and it would be universal to all clients rather than cancelling the orders. Currently Dhan doesn’t allow option trading via TV webhooks nor have released basket order APIs limiting my ability to so.


We will check this if required, but here is stating how things are
a. We cannot (as broker) decided which leg / order of the trade to send to exchange first and next. Brokers do not have right to do order matching or prioritising this, it has to happen on exchange.
b. Total alerts generated for hedge break happened with <0.3% users y’day, and these are all alerts for hedge breaking, everything put together, including the one we refer to.
c. We have observed platforms add a validation layer before orders sent to exchanges in their own middleware (for whatever reason they had) - we can’t do that. Only checks are in order and risk management systems (oms & rms), where only criteria set there for order execution and risk management has to be checked.
d. platforms like ours are pure execution platform. anything if we change here, makes it an algo and it requires certifications.
e. with respect to the new alerting system, the background is brokers were forced to bring the new system as result of regulations. Many brokers made representations for same to reconsider. we ended up refunding penalties (in lacs) for no reason - but just to comply with regulations.
f. we are actually raising alert as suggested by you - we can’t auto square off as well unless it meets the merits as per the risk management policy. again, broker cannot make a trade on behalf of user.

I will still have our teams to check if there can be any solutions for this. I completely get this from your perspective - and I really hoped regulations also considered these scenarios.

Please don’t auto cancel also then for no fault of the customer.


Exactly. Looking for seamless execution like before the entry of hedge break system by Dhan.

@Dhan_Help @PravinJ @Naman

Again happened today. Order placement issues are deal breakers at our end. Please do something about this ASAP.

@Dhan_Help @PravinJ @Naman

Not sure whether you guys changed something at your end. But last 4 times basket orders with hedged positions went through without any glitch. Thanks :pray:.

It’s bit tricky, as we have said earlier. For now let me just say - things are under observation.

:sweat_smile: ok noted. Am hoping it goes through butter smooth in future.

@PravinJ still going super smooth. No issues.


Hi @PravinJ @Dhan_Help

After some time the error happened again today.

Hi @t7support

As explained earlier, the basket is executed in the sequence you have arranged. There may be the case the first order is not executed or executed lately, so automatically the second order will be rejected for insufficient balance or hedge break.

This is a rare thing, but be assure we will figure out something to solve for this.

As explained earlier my basket order legs are arranged correctly and all are market orders on highly liquid NIFTY options. Order not getting executed therefore is not the problem.

I think the problem / delay is likely at the end where you are checking whether the order got executed and raising the alert. This issue is catching us off guard and leading to instances where we are holding twice the position than what we intended or positions on both long and short side unintended. Pls help by solving this issue.

1 Like

Happened again today

1 Like