[Returnanalytics-commits] r2856 - in pkg/PortfolioAnalytics: R vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 22 19:59:18 CEST 2013


Author: rossbennett34
Date: 2013-08-22 19:59:17 +0200 (Thu, 22 Aug 2013)
New Revision: 2856

Modified:
   pkg/PortfolioAnalytics/R/applyFUN.R
   pkg/PortfolioAnalytics/vignettes/ROI_vignette.Rnw
   pkg/PortfolioAnalytics/vignettes/ROI_vignette.pdf
Log:
Adding ETL and mETL to applyFUN. Correcting error in ROI_vignette.

Modified: pkg/PortfolioAnalytics/R/applyFUN.R
===================================================================
--- pkg/PortfolioAnalytics/R/applyFUN.R	2013-08-22 15:48:17 UTC (rev 2855)
+++ pkg/PortfolioAnalytics/R/applyFUN.R	2013-08-22 17:59:17 UTC (rev 2856)
@@ -44,6 +44,8 @@
          mES =,
          CVaR =,
          cVaR =,
+         ETL=,
+         mETL=,
          ES = {
            fun = match.fun(ES)
            if(is.null(nargs$portfolio_method)) nargs$portfolio_method='single'

Modified: pkg/PortfolioAnalytics/vignettes/ROI_vignette.Rnw
===================================================================
--- pkg/PortfolioAnalytics/vignettes/ROI_vignette.Rnw	2013-08-22 15:48:17 UTC (rev 2855)
+++ pkg/PortfolioAnalytics/vignettes/ROI_vignette.Rnw	2013-08-22 17:59:17 UTC (rev 2856)
@@ -83,7 +83,7 @@
 The next step is to run the optimization. Note that \code{optimize\_method="ROI"} is specified in the call to \code{optimize.portfolio} to select the solver used for the optimization.
 <<>>=
 # Run the optimization
-opt_maxret <- optimize.portfolio(R=returns, portfolio=portf_maxret, optimize_method="ROI")
+opt_maxret <- optimize.portfolio(R=returns, portfolio=portf_maxret, optimize_method="ROI", trace=TRUE)
 @
 
 The print method for the \code{opt\_maxret} object shows the call, optimal weights, and the objective measure
@@ -122,18 +122,23 @@
 
 Volatility as the risk metric
 <<fig.align='center',fig.height=5, fig.width=5>>=
-chart.Scatter.ROI(opt_maxret, R=returns,return.col="mean", risk.col="sd", main="Maximum Return")
+chart.RiskReward(opt_maxret,return.col="mean", risk.col="sd", 
+                 chart.assets=TRUE, xlim=c(0.01, 0.05), main="Maximum Return")
 @
 
 Expected tail loss as the risk metric
 <<fig.align='center',fig.height=5, fig.width=5>>=
-chart.Scatter.ROI(opt_maxret, R=returns, return.col="mean", risk.col="ETL", main="Maximum Return", invert=FALSE, p=0.9)
+chart.RiskReward(opt_maxret, return.col="mean", risk.col="ES", 
+                 chart.assets=TRUE, xlim=c(0.02, 0.18), main="Maximum Return")
 @
 
 \subsection{Backtesting}
 An out of sample backtest is run with \code{optimize.portfolio.rebalancing}. In this example, an initial training period of 36 months is used and the portfolio is rebalanced quarterly. 
 <<>>=
-bt_maxret <- optimize.portfolio.rebalancing(R=returns, portfolio=portf_maxret, optimize_method="ROI", rebalance_on="quarters", training_period=36, trace=TRUE)
+bt_maxret <- optimize.portfolio.rebalancing(R=returns, portfolio=portf_maxret,
+                                            optimize_method="ROI", 
+                                            rebalance_on="quarters", 
+                                            training_period=36)
 @
 
 The \code{bt\_maxret} object is a list containing the optimal weights and objective measure at each rebalance period.
@@ -168,13 +173,16 @@
 <<>>=
 # Run the optimization
 opt_gmv <- optimize.portfolio(R=returns, portfolio=portf_minvar, 
-                              optimize_method="ROI")
+                              optimize_method="ROI", trace=TRUE)
 print(opt_gmv)
 @
 
 \subsubsection{Backtesting}
 <<>>=
-bt_gmv <- optimize.portfolio.rebalancing(R=returns, portfolio=portf_minvar, optimize_method="ROI", rebalance_on="quarters", training_period=36)
+bt_gmv <- optimize.portfolio.rebalancing(R=returns, portfolio=portf_minvar,
+                                         optimize_method="ROI", 
+                                         rebalance_on="quarters", 
+                                         training_period=36)
 @
 
 
@@ -184,7 +192,8 @@
 Constraints can be added to the \code{portf\_minvar} portfolio object previously created.
 <<>>=
 # Add long only constraints
-portf_minvar <- add.constraint(portfolio=portf_minvar, type="box", min=0, max=1)
+portf_minvar <- add.constraint(portfolio=portf_minvar, type="box", 
+                               min=0, max=1)
 
 # Add group constraints
 portf_minvar <- add.constraint(portfolio=portf_minvar, 
@@ -197,13 +206,17 @@
 \subsubsection{Optimization}
 <<>>=
 # Run the optimization
-opt_minvar <- optimize.portfolio(R=returns, portfolio=portf_minvar, optimize_method="ROI")
+opt_minvar <- optimize.portfolio(R=returns, portfolio=portf_minvar, 
+                                 optimize_method="ROI", trace=TRUE)
 print(opt_minvar)
 @
 
 \subsubsection{Backtesting}
 <<>>=
-bt_minvar <- optimize.portfolio.rebalancing(R=returns, portfolio=portf_minvar, optimize_method="ROI", rebalance_on="quarters", training_period=36)
+bt_minvar <- optimize.portfolio.rebalancing(R=returns, portfolio=portf_minvar,
+                                            optimize_method="ROI", 
+                                            rebalance_on="quarters", 
+                                            training_period=36)
 @
 
 \section{Maximizing Quadratic Utility}
@@ -250,7 +263,8 @@
 opt_qu <- optimize.portfolio(R=returns, portfolio=init_portf, 
                              constraints=qu_constr, 
                              objectives=qu_obj, 
-                             optimize_method="ROI")
+                             optimize_method="ROI",
+                             trace=TRUE)
 @
 
 \subsection{Backtesting}

Modified: pkg/PortfolioAnalytics/vignettes/ROI_vignette.pdf
===================================================================
(Binary files differ)



More information about the Returnanalytics-commits mailing list