hi, guys,

I am just a beginner to the excellent R package, quantmod. I quite don't know how to change the y-axis name in the chartSeries function. Actually, I want to write some sort of the following function, by which I could use just one code sentence to complete the financial analysis.

The following function is designed to provide some aspects of the S&P500. And now I want to change the "stock.name" on the y-axis as "S&P500". Is there anyway to realize this?

THX

        William


#################################################################
stock.price <- function(stock.name, stock.code){
  #### Loading......
  library(zoo)
  library(xts)
  library(TTR)
  library(Defaults)
  library(quantmod)
#------------------------------------------------------------------------------------------------------------------------------------------
  ## Theme: white
  theme.white <- chartTheme("white")
  names(theme.white)
  theme.white$bg.col <- "white"
  theme.white$up.col <- "red"
  theme.white$dn.col <- "green"
#------------------------------------------------------------------------------------------------------------------------------------------
  #### main function
  stock.name <- getSymbols(stock.code, from = "2010-01-01",
to = Sys.Date(), src = "yahoo", auto.assign=FALSE)
  chartSeries(stock.name, theme = theme.white,
              # subset = 'last 12 months',
              TA = "addVo(); addSMA(); addEnvelope();
                  addMACD(); addMomentum(); addROC();
                  addBBands()")
  addLines(v = which(stock.name[,4] == max(stock.name[,4])),
           col = "gray")
}
#################################################################
stock.price(S&P500, "^GSPC")

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to