[Returnanalytics-commits] r2256 - in pkg/PortfolioAnalytics: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 20 20:47:57 CEST 2012


Author: hezkyvaron
Date: 2012-08-20 20:47:57 +0200 (Mon, 20 Aug 2012)
New Revision: 2256

Added:
   pkg/PortfolioAnalytics/man/extractStats.optimize.portfolio.ROI.Rd
Modified:
   pkg/PortfolioAnalytics/NAMESPACE
   pkg/PortfolioAnalytics/R/extractstats.R
Log:
- added extractStats for ROI

Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE	2012-08-20 05:51:13 UTC (rev 2255)
+++ pkg/PortfolioAnalytics/NAMESPACE	2012-08-20 18:47:57 UTC (rev 2256)
@@ -12,6 +12,7 @@
 export(extract.efficient.frontier)
 export(extractStats)
 export(extractStats.optimize.portfolio.DEoptim)
+export(extractStats.optimize.portfolio.ROI)
 export(extractStats.optimize.portfolio.parallel)
 export(extractStats.optimize.portfolio.random)
 export(extractWeights.rebal)

Modified: pkg/PortfolioAnalytics/R/extractstats.R
===================================================================
--- pkg/PortfolioAnalytics/R/extractstats.R	2012-08-20 05:51:13 UTC (rev 2255)
+++ pkg/PortfolioAnalytics/R/extractstats.R	2012-08-20 18:47:57 UTC (rev 2256)
@@ -177,4 +177,25 @@
   rownames(result) = names(RebalResults)
   result = as.xts(result)
   return(result)
+}
+
+
+#' extract some stats from a portfolio list run with DEoptim via
+#' \code{\link{optimize.portfolio}}
+#' 
+#' This function will take everything in the objective_measures slot and \code{unlist} it.  
+#' This may produce a very large number of columns or strange column names.
+#' 
+#' @param object list returned by optimize.portfolio
+#' @param prefix prefix to add to output row names
+#' @param ... any other passthru parameters
+#' @export 
+extractStats.optimize.portfolio.ROI <- function(object, prefix=NULL, ...) {
+  
+  trow<-c(out=object$out, object$weights)
+  result<-trow
+  
+  rnames<-c('out',paste('w',names(object$weights),sep='.'))
+  names(result)<-rnames
+  return(result)
 }
\ No newline at end of file

Added: pkg/PortfolioAnalytics/man/extractStats.optimize.portfolio.ROI.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/extractStats.optimize.portfolio.ROI.Rd	                        (rev 0)
+++ pkg/PortfolioAnalytics/man/extractStats.optimize.portfolio.ROI.Rd	2012-08-20 18:47:57 UTC (rev 2256)
@@ -0,0 +1,22 @@
+\name{extractStats.optimize.portfolio.ROI}
+\alias{extractStats.optimize.portfolio.ROI}
+\title{extract some stats from a portfolio list run with DEoptim via
+\code{\link{optimize.portfolio}}}
+\usage{
+  extractStats.optimize.portfolio.ROI(object,
+    prefix = NULL, ...)
+}
+\arguments{
+  \item{object}{list returned by optimize.portfolio}
+
+  \item{prefix}{prefix to add to output row names}
+
+  \item{...}{any other passthru parameters}
+}
+\description{
+  This function will take everything in the
+  objective_measures slot and \code{unlist} it. This may
+  produce a very large number of columns or strange column
+  names.
+}
+



More information about the Returnanalytics-commits mailing list