maxdrawdown function

finance, r

Solution

You're trying to find the `maxDrawDown` of the `cumsum` of PnL (which is the same as the account value).

> library(fTrading)
> maxDrawDown(cumsum(c(0, c(12,10,5,-4,-2,1,5,6))))
$maxdrawdown
[1] 6

$from
[1] 3

$to
[1] 5

Problem

In R, I see there are two packages that have a maxdrawdown function. One is fTrading and the other is PerformaceAnalytics. Each of those does a different calculation. - fTrading seems to make the assumption that the values are prices of an asset so the drawdown is in valuation. - The same applies to PerformanceAnalytics except it gives the answer as a percentage. Is there a package with a maxdrawdown function that expects P/L data in a series and gives the draw down based on that? e.g if you had the following data ``` c(12,10,5,-4,-2,1,5,6) ``` The max drawdown would be : ``` -4 + -2=-6. ```

Original source