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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 26 06:54:08 CEST 2013


Author: rossbennett34
Date: 2013-06-26 06:54:07 +0200 (Wed, 26 Jun 2013)
New Revision: 2440

Modified:
   pkg/PortfolioAnalytics/R/constrained_objective.R
Log:
adjusted penalty for turnover function to only penalize if turnover greater than target. see comments in constrained_objective function

Modified: pkg/PortfolioAnalytics/R/constrained_objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/constrained_objective.R	2013-06-26 03:17:29 UTC (rev 2439)
+++ pkg/PortfolioAnalytics/R/constrained_objective.R	2013-06-26 04:54:07 UTC (rev 2440)
@@ -249,8 +249,14 @@
           
           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
+              # out = out + penalty*abs(objective$multiplier)*abs(tmp_measure-objective$target)
+              # Does this penalize for turnover below target?
+              # I want to only penalize turnover above the given target. 
+              # Seems to be giving correct results, but only if multiplier=0.01
+              # I would expect this to be the same result when multiplier=0, but it is not.
+              # max(tmp_measure - objective$target, 0) should equal 0 when tmp_measure is less than objective$target
+              print(max(tmp_measure - objective$target, 0))
+              out = out + penalty * objective$multiplier * max(tmp_measure - objective$target, 0)
             }  
             # target is null or doesn't exist, just maximize, or minimize violation of constraint
             out = out + abs(objective$multiplier)*tmp_measure



More information about the Returnanalytics-commits mailing list