[Returnanalytics-commits] r3234 - pkg/PortfolioAnalytics/demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Oct 19 07:14:32 CEST 2013


Author: rossbennett34
Date: 2013-10-19 07:14:31 +0200 (Sat, 19 Oct 2013)
New Revision: 3234

Modified:
   pkg/PortfolioAnalytics/demo/demo_ROI.R
   pkg/PortfolioAnalytics/demo/demo_factor_exposure.R
   pkg/PortfolioAnalytics/demo/demo_return_target.R
Log:
minor modification to demo scripts

Modified: pkg/PortfolioAnalytics/demo/demo_ROI.R
===================================================================
--- pkg/PortfolioAnalytics/demo/demo_ROI.R	2013-10-19 00:21:16 UTC (rev 3233)
+++ pkg/PortfolioAnalytics/demo/demo_ROI.R	2013-10-19 05:14:31 UTC (rev 3234)
@@ -43,7 +43,7 @@
 ret_constr <- return_constraint(return_target=0.007)
 
 # Group constraint
-group_constr <- group_constraint(assets=pspec$assets, groups=c(1, 2, 1), 
+group_constr <- group_constraint(assets=pspec$assets, groups=list(1, 2:3, 4), 
                                  group_min=0, group_max=0.5)
 
 # Factor exposure constraint
@@ -173,11 +173,11 @@
 opt_qu
 
 # Full investment, long only, target return, and group constraints
-opt_qu <- optimize.portfolio(R=ret, portfolio=pspec, 
-                             constraints=list(fi_constr, lo_constr, ret_constr, group_constr),
-                             objectives=list(ret_obj, var_obj),
-                             optimize_method="ROI")
-opt_qu
+# opt_qu <- optimize.portfolio(R=ret, portfolio=pspec, 
+#                              constraints=list(fi_constr, lo_constr, ret_constr, group_constr),
+#                              objectives=list(ret_obj, var_obj),
+#                              optimize_method="ROI")
+# opt_qu
 
 ##### Minimize ETL Optimization #####
 # The ROI solver uses the glpk plugin to interface to the Rglpk package for 

Modified: pkg/PortfolioAnalytics/demo/demo_factor_exposure.R
===================================================================
--- pkg/PortfolioAnalytics/demo/demo_factor_exposure.R	2013-10-19 00:21:16 UTC (rev 3233)
+++ pkg/PortfolioAnalytics/demo/demo_factor_exposure.R	2013-10-19 05:14:31 UTC (rev 3234)
@@ -15,7 +15,7 @@
 # box constraint
 lo_constr <- box_constraint(assets=pspec$assets, min=c(0.01, 0.02, 0.03, 0.04), max=0.65)
 # group constraint
-grp_constr <- group_constraint(assets=pspec$assets, groups=c(2, 1, 1), group_min=0.1, group_max=0.4)
+grp_constr <- group_constraint(assets=pspec$assets, groups=list(1:2, 3, 4), group_min=0.1, group_max=0.4)
 # position limit constraint
 pl_constr <- position_limit_constraint(assets=pspec$assets, max_pos=4)
 

Modified: pkg/PortfolioAnalytics/demo/demo_return_target.R
===================================================================
--- pkg/PortfolioAnalytics/demo/demo_return_target.R	2013-10-19 00:21:16 UTC (rev 3233)
+++ pkg/PortfolioAnalytics/demo/demo_return_target.R	2013-10-19 05:14:31 UTC (rev 3234)
@@ -8,7 +8,7 @@
 
 # set up portfolio specification object target in the return object
 pspec1 <- portfolio.spec(assets=colnames(ret))
-pspec1 <- add.constraint(portfolio=pspec1, type="leverage", min_sum=1, max_sum=1)
+pspec1 <- add.constraint(portfolio=pspec1, type="leverage", min_sum=0.99, max_sum=1.01)
 pspec1 <- add.constraint(portfolio=pspec1, type="box")
 pspec1 <- add.objective(portfolio=pspec1, type="return", name="mean", target=0.007)
 
@@ -20,7 +20,7 @@
 
 # set up portfolio specification object target with the return constraint
 pspec2 <- portfolio.spec(assets=colnames(ret))
-pspec2 <- add.constraint(portfolio=pspec2, type="leverage", min_sum=1, max_sum=1)
+pspec2 <- add.constraint(portfolio=pspec2, type="leverage", min_sum=0.99, max_sum=1.01)
 pspec2 <- add.constraint(portfolio=pspec2, type="box")
 pspec2 <- add.constraint(portfolio=pspec2, type="return", return_target=0.007)
 pspec2 <- add.objective(portfolio=pspec2, type="return", name="mean")



More information about the Returnanalytics-commits mailing list