Invalid trade history for Dhan API

Hello, I have been using following snippet of code to get trade history, It worked so well till now, But from past days, there is a lack of trades for a given day like 23 May for so many symbols, Could you please look into this?

def _fetch_trade_book(self, start_date, end_date):
    self._tradebookfull = []
    page = 0
    while True:
        data = self._dhan.get_trade_history(start_date, end_date, page)
        if data['status'] == 'failure' and data['remarks']['error_code'] == 'HTTP429':
            time.sleep(1)
            continue
        page += 1
        if not data['data']:
            break
        self._tradebookfull.extend(data['data'])

@Hardik Anyone would care to reply?

For example, this trade is duplicated

{
	"brokerageCharges": 0.0,
	"createTime": "NA",
	"customSymbol": "ICICI Pru BSE Midcap Select ETF",
	"dhanClientId": "1100063652",
	"drvExpiryDate": "NA",
	"drvOptionType": "NA",
	"drvStrikePrice": 0.0,
	"exchangeOrderId": "1200000016216121",
	"exchangeSegment": "NSE_EQ",
	"exchangeTime": "2025-05-19 10:00:46",
	"exchangeTradeId": "0",
	"exchangeTransactionCharges": 0.0195,
	"instrument": "EQUITY",
	"isin": "INF109KC10W0",
	"orderId": "7125051915281",
	"orderType": "MARKET",
	"productType": "CNC",
	"sebiTax": 0.0029,
	"securityId": "17702",
	"serviceTax": 0.0046,
	"stampDuty": -0.07,
	"stt": 0.0,
	"tradedPrice": 17.22,
	"tradedQuantity": 29,
	"tradingSymbol": null,
	"transactionType": "BUY",
	"updateTime": "NA"
},

Hello @killer3d

There shouldn’t be such discrepancy, that too in historical trades data. I just tried replicating the exact scenario, but couldn’t. Will need to check this on logs itself.

Can you please share the timestamp along with the date when you requested historical data, would be helpful to debug faster.

There is , I can confirm this as trade history from multiple accounts are broken
Have start date as 1 may 24 , end date today and try to get trades page by page

Sometimes, dupliocate entries are responded and sometimes buy orders are not responded, It shows correct info on Dhan web page in Trades section
Issue only with API

@Hardik Did you have time to test? Yesterday just because of getting incorrect trade history, my algo mistakenly bought many shares.
It didnt detect something that I bought on last Monday.

@Hardik Would you care to reply? I hope you understand that currently we cant trade with buggy API

Hey , Why no one is replying?
@RahulDeshpande @Alok_Pandey @PravinJ @Hardik @Naman

Looks like no one is interested,
Fair enough, I have sufficient proof that your APIs returns missing data.
I hope you must have metadata to see if trade was executed using algo or manual.
And for any loss after executing algo trade, Dhan should be responsible for it as you guys are busy ignoring message.

Hey @killer3d

Apologies for missing this thread.

We will get back soon to your query.