Questions tagged [performanceanalytics]

R package of Econometric tools for performance and risk analysis.

A package for R

Collection of econometric functions for performance and risk analysis. This package aims to aid practitioners and researchers in utilizing the latest research in analysis of non-normal return streams. In general, it is most tested on return (rather than price) data on a regular scale, but most functions will work with irregular return data as well, and increasing numbers of functions will work with P&L or price data where possible.

See http://cran.r-project.org/web/packages/PerformanceAnalytics/index.html

See PDF Reference Manual (Describes how to use functions) MANUAL

176 questions
9
votes
2 answers

rollapply for large data using sparklyr

I want to estimate rolling value-at-risk for a dataset of about 22.5 million observations, thus I want to use sparklyr for fast computation. Here is what I did (using a sample…
Jairaj Gupta
  • 347
  • 4
  • 16
7
votes
2 answers

ggplot version of charts.PerformanceSummary

I would like to make a "ggplot version" of the basic functionality of charts.PerformanceSummary that is available in the PerformanceAnalytics package, as I think that ggplot is generally prettier and theoretically more powerful in term of editing…
h.l.m
  • 13,015
  • 22
  • 82
  • 169
6
votes
1 answer

Maximum number of assets in R package 'performanceanalytics' optimizer

This is just a general question regarding the maximum number of stocks I can use in the r performanceanalytics optimizer function. My code works fine for optimizing anything up to around 110 assets but anything exceeding that gives an error. I…
6
votes
2 answers

Estimation of rolling Value at Risk (VaR) using R

I need to perform rolling VaR estimation of daily stock returns. At first I did the following: library(PerformanceAnalytics) data(edhec) sample<-edhec[,1:5] var605<-rollapply(as.zoo(sample),width=60,FUN=function(x)…
6
votes
1 answer

Faster alternative to function 'rollapply'

I need to run rolling window function on a xts data which contains about 7,000 rows and 11,000 columns. I did the following: require(PerformanceAnalytics) ssd60<-rollapply(wddxts,width=60,FUN=function(x) SemiDeviation(x),by.column=TRUE) I waited…
Jairaj Gupta
  • 347
  • 4
  • 16
4
votes
2 answers

R: Convert daily returns to monthly returns

I have an xts of daily returns and I'd like to convert it to monthly returns. I can find tonnes of threads to convert daily prices to period returns, but I need to convert daily returns. Having followed the advice in this thread, which works well, I…
Jimbo Mahoney
  • 220
  • 2
  • 9
4
votes
1 answer

font size in chart.correlation (performanceAnalytics)

I use and like the function chart.correlation (package: PerformanceAnalytics), however the entanglement of the coefficient's font size with the correlation extent is unpleasant, leading to unreadable numbers. Can anyone tell me whether it's…
4
votes
1 answer

Incorrect number of dimensions in using findDrawdowns function in R

I've been trying to run the findDrawdowns function in R from the PerformanceAnalytics package and kept getting a dimension error. My data set is called dataset and is a 200 rows, 1 column vector, with no NA in it. I've set up row names as dates as…
LordMonte
  • 51
  • 5
4
votes
1 answer

R: Calculate 12-month cumulative returns

I have a time series dataset, and I'd like to get rolling 12-month cumulative returns. Below is what my code and data look like: df <- data.frame( A = c(-0.0195, 0.0079, 0.0034, 0.0394, -0.0065, 0.0034, 0.0136, 0.0683, -0.0063, -0.0537, …
T-T
  • 693
  • 1
  • 10
  • 24
4
votes
0 answers

How do blotter/quantstrat/quantmod/performanceanalytics handle internal cashflows and expiring instruments?

I don't understand how internal cashflows are handled in blotter/quantstrat/quantmod/performanceanalytics. This mainly concerns two aspects: Regular cashflows like dividends, coupons etc. as well as cashflows from expiring instruments (e.g. a cash…
Ueli Hofstetter
  • 2,409
  • 4
  • 29
  • 52
4
votes
1 answer

Cumulative Returns with NA's in R

I have the following data frame: df <- data.frame(Return1=c(NA, NA, .03, .04, .05), Return2=c(.25, .33, NA, .045, .90), Return3=c(.04, .073, .08, .04, .01)) Return1 Return2 Return3 1 NA 0.250 0.040 2 NA …
rwn1v
  • 777
  • 3
  • 10
  • 23
4
votes
2 answers

R Recession Dates Conversion

I am downloading recession band data into R via quantmod. Now this comes as a binary information (in xts format) looking like this (just the first recession period shown) 1857-01-01 0 1857-02-01 0 1857-03-01 0 1857-04-01 0 1857-05-01 …
user2157086
  • 525
  • 1
  • 5
  • 20
3
votes
1 answer

Trying to create a rolling period cummax

I am trying to create a function that buys an N period high. So if I have a vector: x = c(1, 2, 3, 4, 5, 1, 2, 3, 4, 5) I want to take the rolling 3 period high. This is how I would like the function to look x = c(1, 2, 3, 4, 5, 5, 5, 3, 4,…
Jordan Wrong
  • 1,205
  • 1
  • 12
  • 32
3
votes
1 answer

Quantstrat: Backtesting custom 'bollinger band' like strategy

I'm new with quantstrat and I would like to use then to simulate my strategy that essentially is a Bollinger Band. My code isn't working to close the open position when the Premium crosses the Avg. The algo logic that defines the strategy…
Jose Filho
  • 61
  • 3
3
votes
0 answers

Rolling Expected Shortfall and Tail Risk using PerformanceAnalytics

Since rolling VaR gives error when complete window is missing, I have done the following to estimate 36 months rolling VaR (36 months window missing for HAM5 and…
Jairaj Gupta
  • 347
  • 4
  • 16
1
2 3
11 12