I have a table with the following columns:
id int(10)
winner int(10)
profit double
created datetime
I'm trying to create a query that returns the largest drawdown, or "peak to trough decline" in terms of the profit column. (More info on drawdown here.)
Ideally it would return the value for created for the beginning and end of the drawdown and the depth in profit from beginning to end.
Edit: The profit column is not cumulative, but the query needs to look for cumulative drawdown. A drawdown can have rises, but once the cumulative profit reaches a new high, the drawdown is over. Here's a line graph that shows it. The X distance between the red dot and the green dot is the maximum drawdown.