I'm trying to get the monthly percentage return from each day, not from every month. As you can see from the current output, it gets the monthly percentage return every month.
library(tidyquant)
library(dplyr)
df <- c('AMZN','FB') %>%
tq_get(get='stock.prices',
from='1999-01-01',
to=Sys.Date()) %>%
na.omit() %>%
group_by(symbol) %>%
tq_transmute(select=adjusted,
mutate_fun=periodReturn,
period='monthly',
col_rename='monthly.close') %>%
arrange(desc(date))
Current output:
symbol date monthly.close
AMZN 2019-02-15 -0.0644545858
FB 2019-02-15 -0.0251364926
AMZN 2019-01-31 0.1443171389
FB 2019-01-31 0.2715692050
AMZN 2018-12-31 -0.1113497862
FB 2018-12-31 -0.0677050347
AMZN 2018-11-30 0.0576717501
Expected output
symbol date monthly.close
AMZN 2019-02-15 ...
FB 2019-02-15 ...
AMZN 2019-02-14 ...
FB 2019-02-14 ...
AMZN 2019-02-13 ...
FB 2019-02-13 ...
AMZN 2019-02-12 ...
[...]