Learn R Programming

timeSeries (version 280.75)

drawdowns: Calculations of Drawdowns

Description

Compute series of drawdowns from financial returns and ccalculate drawdown statisitcs. The functions are: ll{ drawdowns Generates 'timeSeries' object of drawdown levels, drawdownsStats Compute drawdown stats for univariate time series. }

Usage

drawdowns(x, ...)

drawdownsStats(x, ...)

Arguments

x
[drawdowns] - an uni- or multivariate 'timeSeries' object of financial returns, [drawdowns] - an univariate 'timeSeries' object of financial returns.
...
[drawdowns] - optional arguments passed to the function na.omit, [drawdownsStats] - arguments passed to the function drawdowns.

Value

  • drawdowns returns an object of class 'timeSeries'. drawdownsStats returns an object of class 'data.frame' wit the following entries: "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.

Examples

Run this code
## data -
   # Microsoft Data: 
   setRmetricsOptions(myFinCenter = "GMT")
   MSFT = as.timeSeries(data(msft.dat))[1:10, 1:4]
   head(MSFT)

## drawdownsStats -
   drawdownsStats(as.timeSeries(data(LPP2005REC))[, "SPI"])

Run the code above in your browser using DataLab