I'm trying to write a function to calculate relative drawdown of an account, based on its time series of equity values. In general the function works fine, I'm just having problems with cases when there are withdrawals and additional deposits on the account :
For deposits and withdrawals I adjust the recorded equity so that it isn't affected by these external movements. The problem is that quite frequently the withdraws/deposits come with an 'incorrect' timestamp from the broker.
For example, at point T I have an equity of 10,000. At T+1 the equity of the account drops to $5,000 caused by a withdrawal. However the withdraw transaction from the broker only comes at T+5 and not between T and T+1 as it should be. As a result I calculate the drawdown of 50% instead of 0%.
Anybody has an idea how to solve this? Or is there any other reliable way to calculate the drawdown?