Learn Algo Trading with Python | Codes | Youtube Series

Hi @vinothsaravanan ,

Rate limit issues may occur while fetching data. One way to handle this is by creating multiple APIs to increase the overall rate limit.

Tagging @Dhan for multiple API creation.

@Tradehull_Imran sir,

API market exit got converted to limit ₹20 and didn’t execute, while manual market exit worked at ₹18.95.

Facing execution issue with API + MPP. Need clarity:

  1. What is the exact logic used to convert API market orders into limit prices under MPP?

  2. In my case, limit was set to ₹20 while traded range was ₹18.40–₹18.90 — why such a mismatch?

  3. Is there any way to control or reduce MPP for API users?

  4. What’s the recommended way to ensure reliable exits in options via API (since market orders are converted)?

  5. Are IOC or aggressive limit strategies supported/recommended for such scenarios?

Hi @Rakesh_Durgam

  1. MPP conversion logic:
    In Dhan API, market orders are not sent as pure market orders. They are converted into limit orders using MPP based on the reference/LTP price at that time and the allowed protection percentage.

  2. Why ₹20 limit when market traded around ₹18.40–₹18.90:
    The ₹20 limit was most likely calculated from the reference price at the time the API order was placed. After that, the option price moved down. Since it became a SELL LIMIT at ₹20, it could not execute at ₹18.95 or below.

  3. Can we control/reduce MPP from API?
    As per current API behavior, there is no direct field to set or reduce MPP percentage from our side. It is handled by Dhan/exchange internally.

  4. Recommended reliable exit method:
    For option exits through API, instead of relying on MARKET orders, we should use aggressive LIMIT orders with IOC validity. For SELL exit, place limit slightly below current bid/LTP. For BUY exit, place limit slightly above current ask/LTP. Then check filled quantity and retry remaining quantity if required.

In this case, the pending SELL LIMIT at ₹20 will execute only if buyers are available at ₹20 or above. It will not execute at ₹18.95.