Skip to content

Commit

Permalink
small changes to chart.EFCompare and meanes.efficient.frontier
Browse files Browse the repository at this point in the history
  • Loading branch information
xinran1228 committed Nov 4, 2024
1 parent c7ec6b7 commit 5bdba27
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/charts.efficient.frontier.R
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,8 @@ chart.EfficientFrontierCompare <- function(R, portfolio, risk_type, n.portfolios
text(out$frontier[1,m.p], out$frontier[1,2], labels = paste("(", round(out$frontier[1,m.p], 4), ",", round(out$frontier[1,2], 4), ")"), pos = 4, cex = cex.assets)
text(out$frontier[which(x_diff == x_index),1], out$frontier[which(x_diff == x_index),2], labels = paste("(", round(out$frontier[which(x_diff == x_index),1], 4), ",", round(out$frontier[which(x_diff == x_index),2], 4), ")"), pos = 2, cex = cex.assets)
}
legend.labels <- append(legend.labels, paste("% Change in Risk =", round((out$frontier[1,m.p] - out$frontier[1,1]) * 100 / out$frontier[1,1], 2)))
legend.labels <- append(legend.labels, paste("% Change in Return =", round((out$frontier[which(x_diff == x_index),2] - out$frontier[1,2]) * 100 / out$frontier[1,2], 2)))
legend.labels <- append(legend.labels, paste("% Decrease in Risk =", round((out$frontier[1,m.p] - out$frontier[1,1]) * 100 / out$frontier[1,1], 2)))
legend.labels <- append(legend.labels, paste("% Increase in Return =", round((out$frontier[which(x_diff == x_index),2] - out$frontier[1,2]) * 100 / out$frontier[1,2], 2)))
}
legend("bottomright", legend=legend.labels, col=col, lty=lty, lwd=lwd, cex=cex.legend, bty="n")
return(invisible(out))
Expand Down
2 changes: 1 addition & 1 deletion R/extract.efficient.frontier.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ meanvar.efficient.frontier <- function(portfolio, R, optimize_method='ROI', n.po
#' @return a matrix of objective measure values and weights along the efficient frontier
#' @author Ross Bennett
#' @export
meanetl.efficient.frontier <- function(portfolio, R, optimize_method='ROI', n.portfolios=25, ...){
meanetl.efficient.frontier <- meanes.efficient.frontier <- function(portfolio, R, optimize_method='ROI', n.portfolios=25, ...){
if(!is.portfolio(portfolio)) stop("portfolio object must be of class 'portfolio'")
# step 1: find the minimum return given the constraints
# step 2: find the maximum return given the constraints
Expand Down
4 changes: 2 additions & 2 deletions man/optimize.portfolio.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5bdba27

Please sign in to comment.