[Returnanalytics-commits] r3046 - pkg/PortfolioAnalytics/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Sep 10 21:29:51 CEST 2013
Author: rossbennett34
Date: 2013-09-10 21:29:51 +0200 (Tue, 10 Sep 2013)
New Revision: 3046
Modified:
pkg/PortfolioAnalytics/R/constrained_objective.R
Log:
Adding penalty term for transaction costs to constrained_objective.
Modified: pkg/PortfolioAnalytics/R/constrained_objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/constrained_objective.R 2013-09-10 17:47:18 UTC (rev 3045)
+++ pkg/PortfolioAnalytics/R/constrained_objective.R 2013-09-10 19:29:51 UTC (rev 3046)
@@ -495,6 +495,15 @@
}
}
} # End factor exposure constraint penalty
+
+ # Add penalty for transaction costs
+ if(!is.null(constraints$ptc)){
+ # calculate total transaction cost using portfolio$assets as initial set of weights
+ tc <- sum(abs(w - portfolio$assets) * constraints$ptc)
+ # for now use a multiplier of 1, may need to adjust this later
+ mult <- 1
+ out <- out + penalty * mult * tc
+ } # End transaction cost penalty
nargs <- list(...)
if(length(nargs)==0) nargs <- NULL
More information about the Returnanalytics-commits
mailing list