[Returnanalytics-commits] r2073 - pkg/PortfolioAnalytics/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jun 25 20:45:23 CEST 2012
Author: braverock
Date: 2012-06-25 20:45:23 +0200 (Mon, 25 Jun 2012)
New Revision: 2073
Modified:
pkg/PortfolioAnalytics/R/constraints.R
pkg/PortfolioAnalytics/R/moment.functions.R
pkg/PortfolioAnalytics/R/objective.R
pkg/PortfolioAnalytics/R/optimize.portfolio.R
pkg/PortfolioAnalytics/R/random_portfolios.R
Log:
- fix some problems with momentFUN reported by Mark Allen
- remove no-longer supported @CallGraph roxygen directives
Modified: pkg/PortfolioAnalytics/R/constraints.R
===================================================================
--- pkg/PortfolioAnalytics/R/constraints.R 2012-06-25 16:34:57 UTC (rev 2072)
+++ pkg/PortfolioAnalytics/R/constraints.R 2012-06-25 18:45:23 UTC (rev 2073)
@@ -25,7 +25,7 @@
#' @examples
#' exconstr <- constraint(assets=10, min_sum=1, max_sum=1, min=.01, max=.35, weight_seq=generatesequence())
#' @export
-#' @callGraph
+#' .
constraint <- function(assets=NULL, ... ,min,max,min_mult,max_mult,min_sum=.99,max_sum=1.01,weight_seq=NULL)
{ # based on GPL R-Forge pkg roi by Stefan Thuessel,Kurt Hornik,David Meyer
if (hasArg(min) & hasArg(max)) {
Modified: pkg/PortfolioAnalytics/R/moment.functions.R
===================================================================
--- pkg/PortfolioAnalytics/R/moment.functions.R 2012-06-25 16:34:57 UTC (rev 2072)
+++ pkg/PortfolioAnalytics/R/moment.functions.R 2012-06-25 18:45:23 UTC (rev 2073)
@@ -139,6 +139,16 @@
return(momentargs)
}
+garch.mm <- function(R,mu_ts, covlist,momentargs=list(),...) {
+ #momentargs<-list()
+ #momentargs$mu<-mu_ts[last(index(R)),]
+ momentargs$mu<-mu_ts[last(index(R)),]
+
+ momentargs$sigma<-covlist[as.character(last(index(R)))]
+ if(is.null(momentargs$m3)) momentargs$m3 = PerformanceAnalytics:::M3.MM(R)
+ if(is.null(momentargs$m4)) momentargs$m4 = PerformanceAnalytics:::M4.MM(R)
+ return(momentargs)
+}
###############################################################################
# $Id$
###############################################################################
\ No newline at end of file
Modified: pkg/PortfolioAnalytics/R/objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/objective.R 2012-06-25 16:34:57 UTC (rev 2072)
+++ pkg/PortfolioAnalytics/R/objective.R 2012-06-25 18:45:23 UTC (rev 2073)
@@ -21,7 +21,7 @@
#' @param objclass string class to apply, default 'objective'
#' @author Brian G. Peterson
#' @export
-#' @callGraph
+#' .
objective<-function(name , target=NULL , arguments, enabled=FALSE , ..., multiplier=1, objclass='objective'){
if(!hasArg(name)) stop("you must specify an objective name")
if (hasArg(name)) if(is.null(name)) stop("you must specify an objective name")
@@ -70,7 +70,7 @@
#' @seealso \code{\link{constraint}}
#'
#' @export
-#' @callGraph
+#' .
add.objective <- function(constraints, type, name, arguments=NULL, enabled=FALSE, ..., indexnum=NULL)
{
if (!is.constraint(constraints)) {stop("constraints passed in are not of class constraint")}
Modified: pkg/PortfolioAnalytics/R/optimize.portfolio.R
===================================================================
--- pkg/PortfolioAnalytics/R/optimize.portfolio.R 2012-06-25 16:34:57 UTC (rev 2072)
+++ pkg/PortfolioAnalytics/R/optimize.portfolio.R 2012-06-25 18:45:23 UTC (rev 2073)
@@ -42,11 +42,19 @@
#' @param \dots any other passthru parameters
#' @param rp matrix of random portfolio weights, default NULL, mostly for automated use by rebalancing optimization or repeated tests on same portfolios
#' @param momentFUN the name of a function to call to set portfolio moments, default \code{\link{set.portfolio.moments}}
-#' @callGraph
+#'
#' @return a list containing the optimal weights, some summary statistics, the function call, and optionally trace information
#' @author Kris Boudt, Peter Carl, Brian G. Peterson
#' @export
-optimize.portfolio <- function(R,constraints,optimize_method=c("DEoptim","random","ROI"), search_size=20000, trace=FALSE, ..., rp=NULL)
+optimize.portfolio <- function(
+ R,
+ constraints,
+ optimize_method=c("DEoptim","random","ROI"),
+ search_size=20000,
+ trace=FALSE, ...,
+ rp=NULL,
+ momentFUN='set.portfolio.moments'
+)
{
optimize_method=optimize_method[1]
tmptrace=NULL
@@ -273,7 +281,7 @@
#' @param rebalance_on a periodicity as returned by xts function periodicity and usable by endpoints
#' @param training_period period to use as training in the front of the data
#' @param trailing_periods if set, an integer with the number of periods to roll over, default NULL will run from inception
-#' @callGraph
+#' .
#' @return a list containing the optimal weights, some summary statistics, the function call, and optionally trace information
#' @author Kris Boudt, Peter Carl, Brian G. Peterson
#' @export
@@ -340,7 +348,7 @@
#' @param trace TRUE/FALSE if TRUE will attempt to return additional information on the path or portfolios searched
#' @param \dots any other passthru parameters
#' @param nodes how many processes to run in the foreach loop, default 4
-#' @callGraph
+#' .
#' @return a list containing the optimal weights, some summary statistics, the function call, and optionally trace information
#' @author Kris Boudt, Peter Carl, Brian G. Peterson
#' @export
Modified: pkg/PortfolioAnalytics/R/random_portfolios.R
===================================================================
--- pkg/PortfolioAnalytics/R/random_portfolios.R 2012-06-25 16:34:57 UTC (rev 2072)
+++ pkg/PortfolioAnalytics/R/random_portfolios.R 2012-06-25 18:45:23 UTC (rev 2073)
@@ -37,7 +37,7 @@
#' @author Peter Carl, Brian G. Peterson
#' @seealso \code{\link{constraint}}, \code{\link{objective}}
#' @export
-#' @callGraph
+#' .
generatesequence <- function (min=.01, max=1, by=min/max, rounding=3 )
{
# this creates the sequence of possible weights, not constrained by asset
@@ -51,11 +51,11 @@
#' @param rpconstraints an object of type "constraints" specifying the constraints for the optimization, see \code{\link{constraint}}
#' @param max_permutations integer: maximum number of iterations to try for a valid portfolio, default 200
#' @param rounding integer how many decimals should we round to
-#' @callGraph
+#' .
#' @return named weighting vector
#' @author Peter Carl, Brian G. Peterson, (based on an idea by Pat Burns)
#' @export
-#' @callGraph
+#' .
randomize_portfolio <- function (rpconstraints, max_permutations=200, rounding=3)
{ # @author: Peter Carl, Brian Peterson (based on an idea by Pat Burns)
@@ -176,7 +176,7 @@
#' rpconstraint<-constraint(assets=10, min_mult=-Inf, max_mult=Inf, min_sum=.99, max_sum=1.01, min=.01, max=.4, weight_seq=generatesequence())
#' rp<- random_portfolios(rpconstraints=rpconstraint,permutations=1000)
#' head(rp)
-#' @callGraph
+#' .
random_portfolios <- function (rpconstraints,permutations=100,...)
{ #
# this function generates a series of portfolios that are a "random walk" from the current portfolio
More information about the Returnanalytics-commits
mailing list