[Returnanalytics-commits] r2396 - pkg/PortfolioAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jun 22 02:23:08 CEST 2013


Author: rossbennett34
Date: 2013-06-22 02:23:07 +0200 (Sat, 22 Jun 2013)
New Revision: 2396

Modified:
   pkg/PortfolioAnalytics/R/constrained_objective.R
Log:
adding turnover_objective functionality to constrained_objective.R

Modified: pkg/PortfolioAnalytics/R/constrained_objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/constrained_objective.R	2013-06-22 00:14:16 UTC (rev 2395)
+++ pkg/PortfolioAnalytics/R/constrained_objective.R	2013-06-22 00:23:07 UTC (rev 2396)
@@ -181,6 +181,9 @@
                   if(!inherits(objective,"risk_budget_objective") & is.null(objective$arguments$portfolio_method)& is.null(nargs$portfolio_method)) nargs$portfolio_method='single'
                   if(is.null(objective$arguments$invert)) objective$arguments$invert = FALSE
               },
+                 turnover = {
+                   fun = match.fun(turnover) # turnover function included in objectiveFUN.R
+                   },
               {   # see 'S Programming p. 67 for this matching
                   fun<-try(match.fun(objective$name))
               }
@@ -244,6 +247,15 @@
             out = out + abs(objective$multiplier)*tmp_measure
           } #  univariate risk objectives
           
+          if(inherits(objective,"turnover_objective")){
+            if (!is.null(objective$target) & is.numeric(objective$target)){ # we have a target
+              out = out + penalty*abs(objective$multiplier)*abs(tmp_measure-objective$target)
+              # Does this penalize for turnover below target
+            }  
+            # target is null or doesn't exist, just maximize, or minimize violation of constraint
+            out = out + abs(objective$multiplier)*tmp_measure
+          } #  univariate turnover objectives
+          
           if(inherits(objective,"risk_budget_objective")){
             # setup
             



More information about the Returnanalytics-commits mailing list