Dhan API Stress Test- Dark Magic?


Can you pls Help us Understand this Dark Magic! :sweat_smile:


1 Like

Hey @Gangavarapu ,

Can you please summarise the script, how many times did you try to place the order?

Is it possible for you to include multiple brokers in this test?

Hello @Gangavarapu

Great to see that you are stress testing DhanHQ APIs. As @amit said, would be happy to know your approach and results for the same.

For the case highlighted by you, terminal prints your system time, whereas Dhan Web platform shows time recorded on our server. This case happened because of difference in device time and Dhan server time by a fraction of seconds. I request you to kindly check your device time in case this is causing discrepancy in testing.

Hi Amit,

Its a Simple Python script. Testing is Being Done with Local System. Will do the same in Cloud as well soon. It is possible to Do for Multiple brokers. I Have Done this with Zerodha/Fyers as well.
Dhan is Equally good w.r.t Placing order compared to fyers/zerodha. This has improved a lot in recent times even though they Did not even Update API in the recent past.

Seems they Dhan scales servers up during Peak Market Hours/NSE trading hours. They Seem to be scaling down considerably during MCX trading hours post NSE/BSE market hours close.

Hi @Hardik i Ran this a Few Days back with 10 Millisecond latency i.e more than 25 Orders per second. My API was banned thereafter. May i know after How many hours is the API Ban lifted.
I will also write a Detailed Notes and post it Here especially Reg Security ID and the CSV Provided Soon.

Good Stuff Dhan :+1:

Here is the code running in an infinite loop.
#Importing DhanModule

from dhanhq import dhanhq

import dhancred

import time

import datetime

client_id= dhancred.client_id()
access_token= dhancred.access_token()

dhan = dhanhq(client_id,access_token)

Loop dhan.place_order

x = 1
while x == 1:
dt= datetime
print(datetime.datetime.now(),“Before Placing Order”)
dhan.place_order(security_id= ‘246083’,
exchange_segment= dhan.MCX,
transaction_type= dhan.BUY,
product_type= dhan.MARGIN,
print(datetime.datetime.now(),“After Placing Order”)
print(datetime.datetime.now(),“After Sleep”)

1 Like

Yes, Trading MCX at night is slow at night. I generally watch CRUDEOOIL trade opportunities at Night but the chart becomes slow at night.

1 Like

Hi @Gangavarapu Thanks for this detail. Just to add, Dhan APIs specially for order placement are way different from some of the industry leaders. When you place order on Dhan, it is RMS validated order, which means it will trade on exchange 100% unless exchange rejects for some reason. Some other platforms first give you order confirmation with an order ID, and RMS validation happens later. This is as far as I know, the feedback we have got from API traders who are using Dhan.

1 Like

Our charting systems are independent of our trading systems. Do let us know if you come across this on, drop a note on help@dhan.co. Will track MCX charts.

Overall MCX trade volumes in Jan were down by 40-50% when compared to early-Dec.

Hi @Hardik
You are Correct, Seems to be a Time Sync Issue w.r.t Local machine/server

Have Tested in AWS and No Time Discrepancy Sighted.
As per My Tests on AWS with Mumbai Server Seems your API Speed Beats the Market Leader in terms of Order placement Latency, Seems to be far less<250 ms on avg even with an inefficient programming language like python :+1:

Pls provide a decent Historical API, Intraday Historical API, Good Websockets. I Think This API is Almost There to compete for Enterprise grade API for Retail.
Security ID is Still is a Painpoint for Retail(Reason is the Approach of Us retail Traders in Coding our Systems to Construct the Instrument we are interested in Trading as per Rules/strategy)

As per Feedback Received from Existing Platforms integrated with Dhan, they Don’t Use Dhan API Feeds/Quotes. They Simply Use Trading API’s and take Feeds from other Data Providers/Brokers like Truedata.

Kindly focus on Data API’s as well

@Hardik @PravinJ