[R] One year return not year to date

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Sat Jul 25 20:06:10 CEST 2020


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 using 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 using 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]]



More information about the R-help mailing list