Hi all, I want to calculate interanual (not year to date) variation of a stock, I am able to obtain year to date with annualReturn, but no way to obtain the interanual increase. It says me no numerical output. Can anyone guide me to obtain it. library(PerformanceAnalytics) library(dplyr) library(tibble) library(lubridate) library(PerformanceAnalytics) library(quantmod) library(ggplot2) library(png) library(RCurl) fecha<-Sys.Date()-365 #with this I obtain one year back beginning precio<-getSymbols("ACX.MC",from='fecha') ret2<- na.omit(CalculateReturns(Cl(ACX.MC))) g<-annualReturn(ACX.MC) #This is year to date d<-CalculateReturns(Cl(ACX.MCC)) aaa<-getQuote('ACX.MC',from='fecha') Lastprice<-aaa[1,2] lo<-c(diff(log(aaa),250)) #With this I try to obtain interanual year variation but error Hope you can help me [[alternative HTML version deleted]]
What is the error message? Knowing this may help others diagnose the problem. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Jul 25, 2020 at 8:41 AM Pedro p?ramo <percentil101 at gmail.com> wrote:> Hi all, > > I want to calculate interanual (not year to date) variation of a stock, I > am able to obtain year to date with annualReturn, but no way to obtain the > interanual increase. It says me no numerical output. > > Can anyone guide me to obtain it. > > library(PerformanceAnalytics) > library(dplyr) > library(tibble) > library(lubridate) > library(PerformanceAnalytics) > library(quantmod) > library(ggplot2) > library(png) > library(RCurl) > > fecha<-Sys.Date()-365 #with this I obtain one year back beginning > precio<-getSymbols("ACX.MC",from='fecha') > ret2<- na.omit(CalculateReturns(Cl(ACX.MC))) > g<-annualReturn(ACX.MC) #This is year to date > d<-CalculateReturns(Cl(ACX.MCC)) > aaa<-getQuote('ACX.MC',from='fecha') > Lastprice<-aaa[1,2] > > lo<-c(diff(log(aaa),250)) #With this I try to obtain interanual year > variation but error > > > Hope you can help me > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]
Hello, I believe the error message comes from the last line, getQuote returns a data.frame with a Date column and log(aaa) will try to log a date. Error. log(aaa[-1]) works, maybe the OP wants to revise the code and then come back to this or other thread. Hope this helps, Rui Barradas ?s 19:06 de 25/07/2020, Bert Gunter escreveu:> What is the error message? Knowing this may help others diagnose the > problem. > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Sat, Jul 25, 2020 at 8:41 AM Pedro p?ramo <percentil101 at gmail.com> wrote: > >> Hi all, >> >> I want to calculate interanual (not year to date) variation of a stock, I >> am able to obtain year to date with annualReturn, but no way to obtain the >> interanual increase. It says me no numerical output. >> >> Can anyone guide me to obtain it. >> >> library(PerformanceAnalytics) >> library(dplyr) >> library(tibble) >> library(lubridate) >> library(PerformanceAnalytics) >> library(quantmod) >> library(ggplot2) >> library(png) >> library(RCurl) >> >> fecha<-Sys.Date()-365 #with this I obtain one year back beginning >> precio<-getSymbols("ACX.MC",from='fecha') >> ret2<- na.omit(CalculateReturns(Cl(ACX.MC))) >> g<-annualReturn(ACX.MC) #This is year to date >> d<-CalculateReturns(Cl(ACX.MCC)) >> aaa<-getQuote('ACX.MC',from='fecha') >> Lastprice<-aaa[1,2] >> >> lo<-c(diff(log(aaa),250)) #With this I try to obtain interanual year >> variation but error >> >> >> Hope you can help me >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. >> > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.-- Este e-mail foi verificado em termos de v?rus pelo software antiv?rus Avast. https://www.avast.com/antivirus