Login     Register

        Contact Us     Search

XLeratorDB/financial Documentation

SQL Server maximum drawdown of asset returns


MAXDD

Updated: 09 May 2014


Use MAXDD to calculate the maximum drawdown based on net asset or portfolio values. The inputs into the function are dates and values and the maximum drawdown is calculated as the largest percentage drop in the asset values from peak to trough in chronological order.
Syntax
Syntax for XLeratorDB MAXXDD maximum drawdown function for SQL Server
Arguments
@PDate
The date associated with @PValue. @PDate is an expression of type datetime or of a type that can be implicitly converted to datetime.
@PValue
the net asset or portfolio value. @PValue is an expression of type float or of a type that can be implicitly converted to float.
Return Type
float
Remarks
·         Returns are calculated by sorting @PValue in chronological order based on @PDate and calculating the largest percentage drop from peak to trough.
·         Available in XLeratorDB / financial 2008 only
Examples
In this example we have portfolio values from 2011-12-31 to 2014-12-31 and we want to calculate the maximum drawdown.
SELECT
      wct.MAXDD(pdate,pvalue) as [Max Drawdown]
FROM (
      VALUES
      ('2011-12-31',109.39),
      ('2012-01-31',102.46),
      ('2012-02-29',102.98),
      ('2012-03-31',102.38),
      ('2012-04-30',113.23),
      ('2012-05-31',93.06),
      ('2012-06-30',90.13),
      ('2012-07-31',79.55),
      ('2012-08-31',108.59),
      ('2012-09-30',108.39),
      ('2012-10-31',103.31),
      ('2012-11-30',101.83),
      ('2012-12-31',131.3),
      ('2013-01-31',127.31),
      ('2013-02-28',92.56),
      ('2013-03-31',65.05),
      ('2013-04-30',108.19),
      ('2013-05-31',95.3),
      ('2013-06-30',76.85),
      ('2013-07-31',84.59),
      ('2013-08-31',82.59),
      ('2013-09-30',107.36),
      ('2013-10-31',101.79),
      ('2013-11-30',143.82),
      ('2013-12-31',124.53),
      ('2014-01-31',109.66),
      ('2014-02-28',95.17),
      ('2014-03-31',108.4),
      ('2014-04-30',104.61),
      ('2014-05-31',84.24),
      ('2014-06-30',86.99),
      ('2014-07-31',92.34),
      ('2014-08-31',99.92),
      ('2014-09-30',128.53),
      ('2014-10-31',108.63),
      ('2014-11-30',101.59),
      ('2014-12-31',82.25)
      )n(pdate,pvalue)
This produces the following result.
          Max Drawdown
----------------------
    -0.504569687738005
Here is a graphical representation of the solution:
 
As you can see from the graph, the largest percentage drop was from a peak of 131.30 on 2012-12-31 to a trough of 65.05 on 2013-03-31 (-50.5%). Even though there was higher peak of 143.82 on 2013-11-30, the trough of 82.25 on 2014-12-31 is a drawdown of only -42.8%. 

 

See Also

 



Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service