| drawdowns | R Documentation |
Compute series of drawdowns from financial returns and calculate drawdown statisitcs.
drawdowns(x, ...)
drawdownsStats(x, ...)
x |
a |
... |
optional arguments passed to |
The code in the core of the function drawdownsStats
was borrowed from the package PerformanceAnalytics
authored by Peter Carl and Sankalp Upadhyay.
for drawdowns, an object of class timeSeries.
for drawdownsStats an object of
class "data.frame" with the following components:
drawdown |
the depth of the drawdown, |
from |
the start date, |
trough |
the trough period, |
to |
the end date, |
length |
the length in number of records, |
peaktrough |
the peak trough, and |
recovery |
the recovery length in number of records. |
Peter Carl and Sankalp Upadhyay for code from the contributed R
package PerformanceAnalytics used in the function
drawdownsStats.
returns,
cumulated,
splits,
midquotes,
index2wealth
## Use Swiss Pension Fund Data Set of Returns -
head(LPP2005REC)
SPI <- LPP2005REC[, "SPI"]
head(SPI)
## Plot Drawdowns -
dd = drawdowns(LPP2005REC[, "SPI"], main = "Drawdowns")
plot(dd)
dd = drawdowns(LPP2005REC[, 1:6], main = "Drawdowns")
plot(dd)
## Compute Drawdowns Statistics -
ddStats <- drawdownsStats(SPI)
class(ddStats)
ddStats
## Note, Only Univariate Series are allowd -
ddStats <- try(drawdownsStats(LPP2005REC))
class(ddStats)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.