[Returnanalytics-commits] r2488 - in pkg/PortfolioAnalytics: . R man sandbox
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 2 13:37:45 CEST 2013
Author: rossbennett34
Date: 2013-07-02 13:37:45 +0200 (Tue, 02 Jul 2013)
New Revision: 2488
Added:
pkg/PortfolioAnalytics/man/txfrm_position_limit_constraint.Rd
Modified:
pkg/PortfolioAnalytics/NAMESPACE
pkg/PortfolioAnalytics/R/constraints.R
pkg/PortfolioAnalytics/man/diversification_constraint.Rd
pkg/PortfolioAnalytics/man/position_limit_constraint.Rd
pkg/PortfolioAnalytics/man/turnover_constraint.Rd
pkg/PortfolioAnalytics/man/volatility_constraint.Rd
pkg/PortfolioAnalytics/sandbox/constraints_vignette.Rnw
pkg/PortfolioAnalytics/sandbox/constraints_vignette.pdf
Log:
changing div.target to div_target and turnover.target to turnover_target to be consistent with naming e.g. min_sum, max_sum, etc.. updating documentation
Modified: pkg/PortfolioAnalytics/NAMESPACE
===================================================================
--- pkg/PortfolioAnalytics/NAMESPACE 2013-07-02 11:33:19 UTC (rev 2487)
+++ pkg/PortfolioAnalytics/NAMESPACE 2013-07-02 11:37:45 UTC (rev 2488)
@@ -53,6 +53,7 @@
export(turnover_objective)
export(txfrm_box_constraint)
export(txfrm_group_constraint)
+export(txfrm_position_limit_constraint)
export(txfrm_weight_sum_constraint)
export(update.constraint)
export(volatility_constraint)
Modified: pkg/PortfolioAnalytics/R/constraints.R
===================================================================
--- pkg/PortfolioAnalytics/R/constraints.R 2013-07-02 11:33:19 UTC (rev 2487)
+++ pkg/PortfolioAnalytics/R/constraints.R 2013-07-02 11:37:45 UTC (rev 2488)
@@ -565,7 +565,7 @@
#' variance problem with ROI quadprog plugin
#'
#' @param type character type of the constraint
-#' @param turnover.target target turnover value
+#' @param turnover_target target turnover value
#' @param enabled TRUE/FALSE
#' @param \dots any other passthru parameters to specify box and/or group constraints
#' @author Ross Bennett
@@ -575,11 +575,11 @@
#'
#' pspec <- portfolio.spec(assets=colnames(ret))
#'
-#' pspec <- add.constraint(portfolio=pspec, type="turnover", turnover.target=0.6)
+#' pspec <- add.constraint(portfolio=pspec, type="turnover", turnover_target=0.6)
#' @export
-turnover_constraint <- function(type, turnover.target, enabled=FALSE, ...){
+turnover_constraint <- function(type, turnover_target, enabled=FALSE, ...){
Constraint <- constraint_v2(type, enabled=enabled, constrclass="turnover_constraint", ...)
- Constraint$toc <- turnover.target
+ Constraint$turnover_target <- turnover_target
return(Constraint)
}
@@ -588,7 +588,7 @@
#' This function is called by add.constraint when type="diversification" is specified, \code{\link{add.constraint}}
#'
#' @param type character type of the constraint
-#' @param div.target diversification target value
+#' @param div_target diversification target value
#' @param enabled TRUE/FALSE
#' @param \dots any other passthru parameters to specify box and/or group constraints
#' @author Ross Bennett
@@ -598,11 +598,11 @@
#'
#' pspec <- portfolio.spec(assets=colnames(ret))
#'
-#' pspec <- add.constraint(portfolio=pspec, type="diversification", div.target=0.7)
+#' pspec <- add.constraint(portfolio=pspec, type="diversification", div_target=0.7)
#' @export
-diversification_constraint <- function(type, div.target, enabled=FALSE, ...){
+diversification_constraint <- function(type, div_target, enabled=FALSE, ...){
Constraint <- constraint_v2(type, enabled=enabled, constrclass="diversification_constraint", ...)
- Constraint$div <- div.target
+ Constraint$div_target <- div_target
return(Constraint)
}
@@ -612,16 +612,16 @@
#' Penalize if portfolio standard deviation deviates from volatility target
#'
#' @param type character type of the constraint
-#' @param vol.target target volatilty constraint
+#' @param vol_target target volatilty constraint
#' @param enabled TRUE/FALSE
#' @param \dots any other passthru parameters to specify box and/or group constraints
#' @author Ross Bennett
#' @export
-volatility_constraint <- function(type, vol.target, enabled=FALSE, ...){
+volatility_constraint <- function(type, vol_target, enabled=FALSE, ...){
Constraint <- constraint_v2(type, enabled=enabled, constrclass="volatility_constraint", ...)
# Constraint$min.vol <- min.vol
# Constraint$max.vol <- max.vol
- Constraint$vol.target <- vol.target
+ Constraint$vol_target <- vol_target
return(Constraint)
}
Modified: pkg/PortfolioAnalytics/man/diversification_constraint.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/diversification_constraint.Rd 2013-07-02 11:33:19 UTC (rev 2487)
+++ pkg/PortfolioAnalytics/man/diversification_constraint.Rd 2013-07-02 11:37:45 UTC (rev 2488)
@@ -2,13 +2,13 @@
\alias{diversification_constraint}
\title{constructor for diversification_constraint}
\usage{
- diversification_constraint(type, div.target,
+ diversification_constraint(type, div_target,
enabled = FALSE, ...)
}
\arguments{
\item{type}{character type of the constraint}
- \item{div.target}{diversification target value}
+ \item{div_target}{diversification target value}
\item{enabled}{TRUE/FALSE}
@@ -26,7 +26,7 @@
pspec <- portfolio.spec(assets=colnames(ret))
-pspec <- add.constraint(portfolio=pspec, type="diversification", div.target=0.7)
+pspec <- add.constraint(portfolio=pspec, type="diversification", div_target=0.7)
}
\author{
Ross Bennett
Modified: pkg/PortfolioAnalytics/man/position_limit_constraint.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/position_limit_constraint.Rd 2013-07-02 11:33:19 UTC (rev 2487)
+++ pkg/PortfolioAnalytics/man/position_limit_constraint.Rd 2013-07-02 11:37:45 UTC (rev 2488)
@@ -2,13 +2,13 @@
\alias{position_limit_constraint}
\title{constructor for position_limit_constraint}
\usage{
- position_limit_constraint(type, max.pos, enabled = FALSE,
+ position_limit_constraint(type, max_pos, enabled = FALSE,
...)
}
\arguments{
\item{type}{character type of the constraint}
- \item{max.pos}{maximum number of positions}
+ \item{max_pos}{maximum number of positions}
\item{enabled}{TRUE/FALSE}
@@ -28,7 +28,7 @@
pspec <- portfolio.spec(assets=colnames(ret))
-pspec <- add.constraint(portfolio=pspec, type="position_limit", max.pos=3)
+pspec <- add.constraint(portfolio=pspec, type="position_limit", max_pos=3)
}
\author{
Ross Bennett #'
Modified: pkg/PortfolioAnalytics/man/turnover_constraint.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/turnover_constraint.Rd 2013-07-02 11:33:19 UTC (rev 2487)
+++ pkg/PortfolioAnalytics/man/turnover_constraint.Rd 2013-07-02 11:37:45 UTC (rev 2488)
@@ -2,13 +2,13 @@
\alias{turnover_constraint}
\title{constructor for turnover_constraint}
\usage{
- turnover_constraint(type, turnover.target,
+ turnover_constraint(type, turnover_target,
enabled = FALSE, ...)
}
\arguments{
\item{type}{character type of the constraint}
- \item{turnover.target}{target turnover value}
+ \item{turnover_target}{target turnover value}
\item{enabled}{TRUE/FALSE}
@@ -32,7 +32,7 @@
pspec <- portfolio.spec(assets=colnames(ret))
-pspec <- add.constraint(portfolio=pspec, type="turnover", turnover.target=0.6)
+pspec <- add.constraint(portfolio=pspec, type="turnover", turnover_target=0.6)
}
\author{
Ross Bennett
Added: pkg/PortfolioAnalytics/man/txfrm_position_limit_constraint.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/txfrm_position_limit_constraint.Rd (rev 0)
+++ pkg/PortfolioAnalytics/man/txfrm_position_limit_constraint.Rd 2013-07-02 11:37:45 UTC (rev 2488)
@@ -0,0 +1,26 @@
+\name{txfrm_position_limit_constraint}
+\alias{txfrm_position_limit_constraint}
+\title{Transform weights for position_limit constraints}
+\usage{
+ txfrm_position_limit_constraint(weights, max_pos,
+ nassets, tolerance = .Machine$double.eps^0.5)
+}
+\arguments{
+ \item{weights}{vector of weights}
+
+ \item{max_pos}{maximum position of assets with non_zero
+ weights}
+
+ \item{nassets}{number of assets}
+}
+\description{
+ This is a helper function called inside constraint_fnMap
+ to transform the weights vector to satisfy position_limit
+ constraints. This function sets the minimum
+ nassets-max_pos assets equal to 0 such that the max_pos
+ number of assets will have non-zero weights.
+}
+\author{
+ Ross Bennett
+}
+
Modified: pkg/PortfolioAnalytics/man/volatility_constraint.Rd
===================================================================
--- pkg/PortfolioAnalytics/man/volatility_constraint.Rd 2013-07-02 11:33:19 UTC (rev 2487)
+++ pkg/PortfolioAnalytics/man/volatility_constraint.Rd 2013-07-02 11:37:45 UTC (rev 2488)
@@ -2,13 +2,13 @@
\alias{volatility_constraint}
\title{constructor for volatility_constraint}
\usage{
- volatility_constraint(type, vol.target, enabled = FALSE,
+ volatility_constraint(type, vol_target, enabled = FALSE,
...)
}
\arguments{
\item{type}{character type of the constraint}
- \item{vol.target}{target volatilty constraint}
+ \item{vol_target}{target volatilty constraint}
\item{enabled}{TRUE/FALSE}
Modified: pkg/PortfolioAnalytics/sandbox/constraints_vignette.Rnw
===================================================================
--- pkg/PortfolioAnalytics/sandbox/constraints_vignette.Rnw 2013-07-02 11:33:19 UTC (rev 2487)
+++ pkg/PortfolioAnalytics/sandbox/constraints_vignette.Rnw 2013-07-02 11:37:45 UTC (rev 2488)
@@ -24,10 +24,10 @@
\item[weight\_sum] The weight\_sum constraint is used to constrain the sum of weights. Common use cases of this are to apply a full investment, dollar neutral, or leverage constraint.
\item[box] Box constraints are used to constrain the minimum and maximum weights of assets. Standard box constraints with a single upper bound and single lower bound as well as per asset inequality constraints on weights can be specified. A special case of box constraints is a long only constraint where the minimum weight is 0 and maximum weight is 1.
\item[group] Group constraints are used to specify the minimum and maximum weights of groups of assets. A common use case to group assets by market cap or style. Note that group constraints is only implemented for the ROI solvers. Implementing the group constraints for other solvers should be possible in \code{constrained\_objective} using the \code{constrained\_group\_tmp} function.
- \item[turnover] Turnover can be specified as a constraint, but is not currently implemented in any solvers. Turnover constraint may not be able to be implemented in the ROI glpk solver. It is implemented for the ROI quadprog solver in sandbox/testing\_turnover.gmv.R. Currently, turnover can be implemented as an objective function and the function has been added to the file \code{R/objectiveFUN.R}. The user can specify a turnover target \code{turnover.target}. Any deviation from the target will be penalized.
- \item[diversification] Diversification can be specified as a constraint, but is not currently implemented in any solvers. This can be done in the mapping function in the next part or implemented inside \code{constrained\_objective}. The user can specify a diversification target value \code{div.target}. Any deviation from the target will be penalized.
- \item[volatility] Volatility can be specified as a constraint, but it is not currently implemented for any solvers. This can be done in the mapping function in the next part or implemented inside \code{constrained\_objective}. See \code{constrained\_objective} for how volatility is handled as an objective. The user can specify a volatility target value \code{vol.target}. Any deviation from the target will be penalized.
- \item[position\_limit] Integer constraint for max position cardinality constraint. This may be able to be implemented in \code{randomize\_portfolio} by generating portfolios with the number of non-zero weights equal to \code{max.pos}, then fill in weights of zero so the length of the weights vector is equal to the number of assets, then scramble the weights vector. The number of non-zero weights could also be random so that the number of non-zero weights is not always equal to \code{max.pos}. This could be implemented in the DEoptim solver with the mapping function. This might be do-able in Rglpk for max return and min ETL. Rglpk supports mixed integer types, but solve.QP does not. May be able to use branch-and-bound technique using solve.QP.
+ \item[turnover] Turnover can be specified as a constraint, but is not currently implemented in any solvers. Turnover constraint may not be able to be implemented in the ROI glpk solver. It is implemented for the ROI quadprog solver in sandbox/testing\_turnover.gmv.R. Currently, turnover can be implemented as an objective function and the function has been added to the file \code{R/objectiveFUN.R}. The user can specify a turnover target \code{turnover\_target}. Any deviation from the target will be penalized.
+ \item[diversification] Diversification can be specified as a constraint, but is not currently implemented in any solvers. This can be done in the mapping function in the next part or implemented inside \code{constrained\_objective}. The user can specify a diversification target value \code{div\_target}. Any deviation from the target will be penalized.
+ \item[volatility] Volatility can be specified as a constraint, but it is not currently implemented for any solvers. This can be done in the mapping function in the next part or implemented inside \code{constrained\_objective}. See \code{constrained\_objective} for how volatility is handled as an objective. The user can specify a volatility target value \code{vol\_target}. Any deviation from the target will be penalized.
+ \item[position\_limit] Integer constraint for max position cardinality constraint. This may be able to be implemented in \code{randomize\_portfolio} by generating portfolios with the number of non-zero weights equal to \code{max\_pos}, then fill in weights of zero so the length of the weights vector is equal to the number of assets, then scramble the weights vector. The number of non-zero weights could also be random so that the number of non-zero weights is not always equal to \code{max\_pos}. This could be implemented in the DEoptim solver with the mapping function. This might be do-able in Rglpk for max return and min ETL. Rglpk supports mixed integer types, but solve.QP does not. May be able to use branch-and-bound technique using solve.QP.
\end{itemize}
Constraint TODO
@@ -92,29 +92,29 @@
pspec$constraints[[3]]
@
-Add turnover constraint. Any deviation from \code{turnover.target} is penalized.
+Add turnover constraint. Any deviation from \code{turnover\_target} is penalized.
<<>>=
pspec <- add.constraint(portfolio=pspec,
type="turnover",
- turnover.target=0.6,
+ turnover_target=0.6,
enabled=TRUE)
pspec$constraints[[4]]
@
-Add diversification constraint. Any deviation from \code{div.target} will be penalized.
+Add diversification constraint. Any deviation from \code{div\_target} will be penalized.
<<>>=
pspec <- add.constraint(portfolio=pspec,
type="diversification",
- div.target=0.7,
+ div_target=0.7,
enabled=TRUE)
pspec$constraints[[5]]
@
-Add volatility constraint. Any deviation from \code{vol.target} will be penalized.
+Add volatility constraint. Any deviation from \code{vol\_target} will be penalized.
<<>>=
pspec <- add.constraint(portfolio=pspec,
type="volatility",
- vol.target=0.035,
+ vol_target=0.035,
enabled=TRUE)
pspec$constraints[[6]]
@
@@ -123,7 +123,7 @@
<<>>=
pspec <- add.constraint(portfolio=pspec,
type="position_limit",
- max.pos=3,
+ max_pos=3,
enabled=TRUE)
pspec$constraints[[7]]
@
Modified: pkg/PortfolioAnalytics/sandbox/constraints_vignette.pdf
===================================================================
(Binary files differ)
More information about the Returnanalytics-commits
mailing list