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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 11 19:27:19 CEST 2013


Author: rossbennett34
Date: 2013-09-11 19:27:19 +0200 (Wed, 11 Sep 2013)
New Revision: 3059

Added:
   pkg/PortfolioAnalytics/man/transaction_cost_constraint.Rd
Modified:
   pkg/PortfolioAnalytics/NAMESPACE
   pkg/PortfolioAnalytics/R/chart.RiskReward.R
   pkg/PortfolioAnalytics/R/charts.DE.R
   pkg/PortfolioAnalytics/R/charts.GenSA.R
   pkg/PortfolioAnalytics/R/charts.PSO.R
   pkg/PortfolioAnalytics/R/charts.ROI.R
   pkg/PortfolioAnalytics/R/charts.RP.R
   pkg/PortfolioAnalytics/R/constraints.R
   pkg/PortfolioAnalytics/man/chart.RiskReward.Rd
Log:
Making chart.RiskReward a more simple S3 generic. Updating documentation.

Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE	2013-09-11 17:20:09 UTC (rev 3058)
+++ pkg/PortfolioAnalytics/NAMESPACE	2013-09-11 17:27:19 UTC (rev 3059)
@@ -67,6 +67,7 @@
 export(set.portfolio.moments_v2)
 export(set.portfolio.moments)
 export(trailingFUN)
+export(transaction_cost_constraint)
 export(turnover_constraint)
 export(turnover_objective)
 export(turnover)
@@ -81,6 +82,7 @@
 S3method(chart.EfficientFrontier,efficient.frontier)
 S3method(chart.EfficientFrontier,optimize.portfolio.ROI)
 S3method(chart.EfficientFrontier,optimize.portfolio)
+S3method(chart.RiskReward,opt.list)
 S3method(chart.RiskReward,optimize.portfolio.DEoptim)
 S3method(chart.RiskReward,optimize.portfolio.GenSA)
 S3method(chart.RiskReward,optimize.portfolio.pso)
@@ -94,6 +96,8 @@
 S3method(chart.Weights,optimize.portfolio.ROI)
 S3method(chart.Weights.EF,efficient.frontier)
 S3method(chart.Weights.EF,optimize.portfolio)
+S3method(extractObjectiveMeasures,opt.list)
+S3method(extractObjectiveMeasures,optimize.portfolio)
 S3method(extractStats,optimize.portfolio.DEoptim)
 S3method(extractStats,optimize.portfolio.GenSA)
 S3method(extractStats,optimize.portfolio.parallel)

Modified: pkg/PortfolioAnalytics/R/chart.RiskReward.R
===================================================================
--- pkg/PortfolioAnalytics/R/chart.RiskReward.R	2013-09-11 17:20:09 UTC (rev 3058)
+++ pkg/PortfolioAnalytics/R/chart.RiskReward.R	2013-09-11 17:27:19 UTC (rev 3059)
@@ -21,13 +21,17 @@
 #' @param cex.axis The magnification to be used for axis annotation relative to the current setting of \code{cex}
 #' @param xlim set the x-axis limit, same as in \code{\link{plot}}
 #' @param ylim set the y-axis limit, same as in \code{\link{plot}}
+#' @param rp TRUE/FALSE to generate random portfolios to plot the feasible space
+#' @param main a main title for the plot
+#' @param labels.assets TRUE/FALSE to include the names in the plot. 
+#' @param pch.assets plotting character of the assets, same as in \code{\link{plot}}
+#' @param cex.assets A numerical value giving the amount by which the asset points should be magnified relative to the default.
+#' @param cex.lab A numerical value giving the amount by which the labels should be magnified relative to the default.
+#' @param colorset color palette or vector of colors to use
 #' @seealso \code{\link{optimize.portfolio}}
 #' @rdname chart.RiskReward
-#' @aliases chart.RiskReward.optimize.portfolio.DEoptim chart.RiskReward.optimize.portfolio.RP 
-#' chart.RiskReward.optimize.portfolio.ROI chart.RiskReward.optimize.portfolio.pso 
-#' chart.RiskReward.optimize.portfolio.GenSA
 #' @export
-chart.RiskReward <- function(object, neighbors, ..., return.col, risk.col, chart.assets, element.color, cex.axis, xlim, ylim){
+chart.RiskReward <- function(object, ...){
   UseMethod("chart.RiskReward")
 }
 

Modified: pkg/PortfolioAnalytics/R/charts.DE.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.DE.R	2013-09-11 17:20:09 UTC (rev 3058)
+++ pkg/PortfolioAnalytics/R/charts.DE.R	2013-09-11 17:27:19 UTC (rev 3059)
@@ -92,7 +92,7 @@
 chart.Weights.optimize.portfolio.DEoptim <- chart.Weights.DE
 
 
-chart.Scatter.DE <- function(object, neighbors = NULL, ..., return.col='mean', risk.col='ES', chart.assets=FALSE, element.color = "darkgray", cex.axis=0.8, xlim=NULL, ylim=NULL){
+chart.Scatter.DE <- function(object, ..., neighbors = NULL, return.col='mean', risk.col='ES', chart.assets=FALSE, element.color = "darkgray", cex.axis=0.8, xlim=NULL, ylim=NULL){
   # more or less specific to the output of the DEoptim portfolio code with constraints
   # will work to a point with other functions, such as optimize.porfolio.parallel
   # there's still a lot to do to improve this.
@@ -289,9 +289,9 @@
   box(col = element.color)
 }
 
+#' @rdname chart.RiskReward
 #' @method chart.RiskReward optimize.portfolio.DEoptim
 #' @S3method chart.RiskReward optimize.portfolio.DEoptim
-#' @export
 chart.RiskReward.optimize.portfolio.DEoptim <- chart.Scatter.DE
 
 

Modified: pkg/PortfolioAnalytics/R/charts.GenSA.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.GenSA.R	2013-09-11 17:20:09 UTC (rev 3058)
+++ pkg/PortfolioAnalytics/R/charts.GenSA.R	2013-09-11 17:27:19 UTC (rev 3059)
@@ -78,7 +78,7 @@
 #' @S3method chart.Weights optimize.portfolio.GenSA
 chart.Weights.optimize.portfolio.GenSA <- chart.Weights.GenSA
 
-chart.Scatter.GenSA <- function(object, neighbors=NULL, ..., return.col="mean", risk.col="ES", chart.assets=FALSE, element.color="darkgray", cex.axis=0.8, ylim=NULL, xlim=NULL, rp=FALSE){
+chart.Scatter.GenSA <- function(object, ..., neighbors=NULL, return.col="mean", risk.col="ES", chart.assets=FALSE, element.color="darkgray", cex.axis=0.8, ylim=NULL, xlim=NULL, rp=FALSE){
   
   if(!inherits(object, "optimize.portfolio.GenSA")) stop("object must be of class 'optimize.portfolio.GenSA'")
   
@@ -135,9 +135,9 @@
   box(col = element.color)
 }
 
+#' @rdname chart.RiskReward
 #' @method chart.RiskReward optimize.portfolio.GenSA
 #' @S3method chart.RiskReward optimize.portfolio.GenSA
-#' @export
 chart.RiskReward.optimize.portfolio.GenSA <- chart.Scatter.GenSA
 
 

Modified: pkg/PortfolioAnalytics/R/charts.PSO.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.PSO.R	2013-09-11 17:20:09 UTC (rev 3058)
+++ pkg/PortfolioAnalytics/R/charts.PSO.R	2013-09-11 17:27:19 UTC (rev 3059)
@@ -78,7 +78,7 @@
 #' @S3method chart.Weights optimize.portfolio.pso
 chart.Weights.optimize.portfolio.pso <- chart.Weights.pso
 
-chart.Scatter.pso <- function(object, neighbors=NULL, ..., return.col="mean", risk.col="ES", chart.assets=FALSE, element.color = "darkgray", cex.axis=0.8, xlim=NULL, ylim=NULL){
+chart.Scatter.pso <- function(object, ..., neighbors=NULL, return.col="mean", risk.col="ES", chart.assets=FALSE, element.color = "darkgray", cex.axis=0.8, xlim=NULL, ylim=NULL){
   if(!inherits(object, "optimize.portfolio.pso")) stop("object must be of class 'optimize.portfolio.pso'")
   
   R <- object$R
@@ -193,9 +193,9 @@
   box(col = element.color)
 }
 
+#' @rdname chart.RiskReward
 #' @method chart.RiskReward optimize.portfolio.pso
 #' @S3method chart.RiskReward optimize.portfolio.pso
-#' @export
 chart.RiskReward.optimize.portfolio.pso <- chart.Scatter.pso
 
 

Modified: pkg/PortfolioAnalytics/R/charts.ROI.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.ROI.R	2013-09-11 17:20:09 UTC (rev 3058)
+++ pkg/PortfolioAnalytics/R/charts.ROI.R	2013-09-11 17:27:19 UTC (rev 3059)
@@ -79,7 +79,7 @@
 chart.Weights.optimize.portfolio.ROI <- chart.Weights.ROI
 
 
-chart.Scatter.ROI <- function(object, neighbors=NULL, ..., return.col="mean", risk.col="ES", chart.assets=FALSE, element.color = "darkgray", cex.axis=0.8, xlim=NULL, ylim=NULL, rp=FALSE){
+chart.Scatter.ROI <- function(object, ..., neighbors=NULL, return.col="mean", risk.col="ES", chart.assets=FALSE, element.color = "darkgray", cex.axis=0.8, xlim=NULL, ylim=NULL, rp=FALSE){
   
   if(!inherits(object, "optimize.portfolio.ROI")) stop("object must be of class 'optimize.portfolio.ROI'")
   
@@ -137,9 +137,9 @@
   box(col = element.color)
 }
 
+#' @rdname chart.RiskReward
 #' @method chart.RiskReward optimize.portfolio.ROI
 #' @S3method chart.RiskReward optimize.portfolio.ROI
-#' @export
 chart.RiskReward.optimize.portfolio.ROI <- chart.Scatter.ROI
 
 

Modified: pkg/PortfolioAnalytics/R/charts.RP.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.RP.R	2013-09-11 17:20:09 UTC (rev 3058)
+++ pkg/PortfolioAnalytics/R/charts.RP.R	2013-09-11 17:27:19 UTC (rev 3059)
@@ -93,7 +93,7 @@
 #' @S3method chart.Weights optimize.portfolio.random
 chart.Weights.optimize.portfolio.random <- chart.Weights.RP
 
-chart.Scatter.RP <- function(object, neighbors = NULL, ..., return.col='mean', risk.col='ES', chart.assets=FALSE, element.color = "darkgray", cex.axis=0.8, xlim=NULL, ylim=NULL){
+chart.Scatter.RP <- function(object, ..., neighbors = NULL, return.col='mean', risk.col='ES', chart.assets=FALSE, element.color = "darkgray", cex.axis=0.8, xlim=NULL, ylim=NULL){
   # more or less specific to the output of the random portfolio code with constraints
   # will work to a point with other functions, such as optimize.porfolio.parallel
   # there's still a lot to do to improve this.
@@ -246,9 +246,9 @@
   box(col = element.color)
 }
 
+#' @rdname chart.RiskReward
 #' @method chart.RiskReward optimize.portfolio.random
 #' @S3method chart.RiskReward optimize.portfolio.random
-#' @export
 chart.RiskReward.optimize.portfolio.random <- chart.Scatter.RP
 
 

Modified: pkg/PortfolioAnalytics/R/constraints.R
===================================================================
--- pkg/PortfolioAnalytics/R/constraints.R	2013-09-11 17:20:09 UTC (rev 3058)
+++ pkg/PortfolioAnalytics/R/constraints.R	2013-09-11 17:27:19 UTC (rev 3059)
@@ -983,6 +983,7 @@
 #' utility problems with ROI quadprog plugin.
 #' 
 #' @param type character type of the constraint
+#' @param assets number of assets, or optionally a named vector of assets specifying initial weights
 #' @param ptc proportional transaction cost value
 #' @param enabled TRUE/FALSE
 #' @param message TRUE/FALSE. The default is message=FALSE. Display messages if TRUE.

Modified: pkg/PortfolioAnalytics/man/chart.RiskReward.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/chart.RiskReward.Rd	2013-09-11 17:20:09 UTC (rev 3058)
+++ pkg/PortfolioAnalytics/man/chart.RiskReward.Rd	2013-09-11 17:27:19 UTC (rev 3059)
@@ -1,15 +1,46 @@
-\name{chart.RiskReward}
+\name{chart.RiskReward.optimize.portfolio.DEoptim}
 \alias{chart.RiskReward}
+\alias{chart.RiskReward.opt.list}
 \alias{chart.RiskReward.optimize.portfolio.DEoptim}
 \alias{chart.RiskReward.optimize.portfolio.GenSA}
 \alias{chart.RiskReward.optimize.portfolio.pso}
+\alias{chart.RiskReward.optimize.portfolio.random}
 \alias{chart.RiskReward.optimize.portfolio.ROI}
-\alias{chart.RiskReward.optimize.portfolio.RP}
 \title{classic risk reward scatter}
 \usage{
-  chart.RiskReward(object, neighbors, ..., return.col,
-    risk.col, chart.assets, element.color, cex.axis, xlim,
-    ylim)
+  \method{chart.RiskReward}{optimize.portfolio.DEoptim} (object, ..., neighbors = NULL, return.col = "mean",
+    risk.col = "ES", chart.assets = FALSE,
+    element.color = "darkgray", cex.axis = 0.8,
+    xlim = NULL, ylim = NULL)
+
+  \method{chart.RiskReward}{optimize.portfolio.random} (object, ..., neighbors = NULL, return.col = "mean",
+    risk.col = "ES", chart.assets = FALSE,
+    element.color = "darkgray", cex.axis = 0.8,
+    xlim = NULL, ylim = NULL)
+
+  \method{chart.RiskReward}{optimize.portfolio.ROI} (object, ..., neighbors = NULL, return.col = "mean",
+    risk.col = "ES", chart.assets = FALSE,
+    element.color = "darkgray", cex.axis = 0.8,
+    xlim = NULL, ylim = NULL, rp = FALSE)
+
+  \method{chart.RiskReward}{optimize.portfolio.pso} (object, ..., neighbors = NULL, return.col = "mean",
+    risk.col = "ES", chart.assets = FALSE,
+    element.color = "darkgray", cex.axis = 0.8,
+    xlim = NULL, ylim = NULL)
+
+  \method{chart.RiskReward}{optimize.portfolio.GenSA} (object, ..., neighbors = NULL, return.col = "mean",
+    risk.col = "ES", chart.assets = FALSE,
+    element.color = "darkgray", cex.axis = 0.8,
+    ylim = NULL, xlim = NULL, rp = FALSE)
+
+  chart.RiskReward(object, ...)
+
+  \method{chart.RiskReward}{opt.list} (object, ...,
+    risk.col = "ES", return.col = "mean", main = "",
+    ylim = NULL, xlim = NULL, labels.assets = TRUE,
+    pch.assets = 1, cex.assets = 0.8, cex.axis = 0.8,
+    cex.lab = 0.8, colorset = NULL,
+    element.color = "darkgray")
 }
 \arguments{
   \item{object}{optimal portfolio created by
@@ -40,6 +71,27 @@
 
   \item{ylim}{set the y-axis limit, same as in
   \code{\link{plot}}}
+
+  \item{rp}{TRUE/FALSE to generate random portfolios to
+  plot the feasible space}
+
+  \item{main}{a main title for the plot}
+
+  \item{labels.assets}{TRUE/FALSE to include the names in
+  the plot.}
+
+  \item{pch.assets}{plotting character of the assets, same
+  as in \code{\link{plot}}}
+
+  \item{cex.assets}{A numerical value giving the amount by
+  which the asset points should be magnified relative to
+  the default.}
+
+  \item{cex.lab}{A numerical value giving the amount by
+  which the labels should be magnified relative to the
+  default.}
+
+  \item{colorset}{color palette or vector of colors to use}
 }
 \description{
   \code{neighbors} may be specified in three ways. The

Added: pkg/PortfolioAnalytics/man/transaction_cost_constraint.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/transaction_cost_constraint.Rd	                        (rev 0)
+++ pkg/PortfolioAnalytics/man/transaction_cost_constraint.Rd	2013-09-11 17:27:19 UTC (rev 3059)
@@ -0,0 +1,50 @@
+\name{transaction_cost_constraint}
+\alias{transaction_cost_constraint}
+\title{constructor for transaction_cost_constraint}
+\usage{
+  transaction_cost_constraint(type = "transaction_cost",
+    assets, ptc, enabled = TRUE, message = FALSE, ...)
+}
+\arguments{
+  \item{type}{character type of the constraint}
+
+  \item{assets}{number of assets, or optionally a named
+  vector of assets specifying initial weights}
+
+  \item{ptc}{proportional transaction cost value}
+
+  \item{enabled}{TRUE/FALSE}
+
+  \item{message}{TRUE/FALSE. The default is message=FALSE.
+  Display messages if TRUE.}
+
+  \item{\dots}{any other passthru parameters to specify box
+  and/or group constraints}
+}
+\description{
+  The transaction cost constraint specifies a proportional
+  cost value. This function is called by add.constraint
+  when type="transaction_cost" is specified, see
+  \code{\link{add.constraint}}.
+}
+\details{
+  Note that with the ROI solvers, proportional transaction
+  cost constraint is currently only supported for the
+  global minimum variance and quadratic utility problems
+  with ROI quadprog plugin.
+}
+\examples{
+data(edhec)
+ret <- edhec[, 1:4]
+
+pspec <- portfolio.spec(assets=colnames(ret))
+
+pspec <- add.constraint(portfolio=pspec, type="transaction_cost", ptc=0.01)
+}
+\author{
+  Ross Bennett
+}
+\seealso{
+  \code{\link{add.constraint}}
+}
+



More information about the Returnanalytics-commits mailing list