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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 27 20:08:49 CEST 2013


Author: rossbennett34
Date: 2013-08-27 20:08:48 +0200 (Tue, 27 Aug 2013)
New Revision: 2904

Modified:
   pkg/PortfolioAnalytics/NAMESPACE
   pkg/PortfolioAnalytics/R/generics.R
   pkg/PortfolioAnalytics/man/summary.optimize.portfolio.Rd
Log:
Cleaning up summary method for optimize.portfolio objects. Invisibly returning data that is printed in summary method.

Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE	2013-08-27 17:53:00 UTC (rev 2903)
+++ pkg/PortfolioAnalytics/NAMESPACE	2013-08-27 18:08:48 UTC (rev 2904)
@@ -90,6 +90,7 @@
 export(pos_limit_fail)
 export(position_limit_constraint)
 export(print.constraint)
+export(print.efficient.frontier)
 export(print.optimize.portfolio.DEoptim)
 export(print.optimize.portfolio.GenSA)
 export(print.optimize.portfolio.pso)
@@ -112,6 +113,7 @@
 export(set.portfolio.moments_v1)
 export(set.portfolio.moments_v2)
 export(set.portfolio.moments)
+export(summary.efficient.frontier)
 export(summary.optimize.portfolio.rebalancing)
 export(summary.optimize.portfolio)
 export(summary.portfolio)

Modified: pkg/PortfolioAnalytics/R/generics.R
===================================================================
--- pkg/PortfolioAnalytics/R/generics.R	2013-08-27 17:53:00 UTC (rev 2903)
+++ pkg/PortfolioAnalytics/R/generics.R	2013-08-27 18:08:48 UTC (rev 2904)
@@ -446,6 +446,7 @@
 #' 
 #' @param object an object of class "optimize.portfolio.pso" resulting from a call to optimize.portfolio
 #' @param ... any other passthru parameters. Currently not used.
+#' @author Ross Bennett
 #' @export
 summary.optimize.portfolio <- function(object, ...){
   
@@ -526,8 +527,9 @@
   }
   
   # group constraints
-  cat("Group Constraints:\n")
+  group_weights <- NULL
   if(!is.null(constraints$groups) & !is.null(constraints$cLO) & !is.null(constraints$cUP)){
+    cat("Group Constraints:\n")
     cat("Groups:\n")
     groups <- constraints$groups
     group_labels <- constraints$group_labels
@@ -599,8 +601,9 @@
   cat("\n")
   
   # Factor exposure constraint
-  cat("Factor Exposure Constraints:\n")
+  tmpexp <- NULL
   if(!is.null(constraints$B) & !is.null(constraints$lower) & !is.null(constraints$upper)){
+    cat("Factor Exposure Constraints:\n")
     t.B <- t(constraints$B)
     cat("Factor Exposure B Matrix:\n")
     print(constraints$B)
@@ -641,6 +644,15 @@
   cat("Elapsed Time:\n")
   print(object$elapsed_time)
   cat("\n")
+  invisible(list(weights=object$weights,
+                 opt_values=object$objective_measures,
+                 group_weights=group_weights,
+                 factor_exposures=tmpexp,
+                 diversification=diversification(object$weights),
+                 turnover=turnover(object$weights, wts.init=object$portfolio$assets),
+                 positions=sum(abs(object$weights) > tolerance),
+                 long_positions=sum(object$weights > tolerance),
+                 short_positions=sum(object$weights < -tolerance)))
 }
 
 #' Print an efficient frontier object

Modified: pkg/PortfolioAnalytics/man/summary.optimize.portfolio.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/summary.optimize.portfolio.Rd	2013-08-27 17:53:00 UTC (rev 2903)
+++ pkg/PortfolioAnalytics/man/summary.optimize.portfolio.Rd	2013-08-27 18:08:48 UTC (rev 2904)
@@ -14,4 +14,7 @@
 \description{
   summary method for class "optimize.portfolio"
 }
+\author{
+  Ross Bennett
+}
 



More information about the Returnanalytics-commits mailing list