Strange result in the to.monthly (quantmod package) cut series

2

Problem with my to.monthly. It cuts my dataset, I do not know why.

####install.packages("quantmod")
library(quantmod)
####install.packages("PerformanceAnalytics")
library(PerformanceAnalytics)
####install.packages("zoo")
library(zoo)

####Definindo diretório principal
setDefaults(getSymbols, src='google')

StartDate = as.Date("2004-01-01") ####data de começo
EndDate = as.Date("2017-01-01") ####data de término


ibovespa <- getSymbols('IBOV', from=StartDate, to=EndDate, auto.assign = F)
ibovespa_monthly <- to.monthly(ibovespa) #->->->->->->->->->problem#####
colnames(ibovespa_monthly) <- c("Open", "High", "Low", "Close","Volume")
ibovespa_return <- (Return.calculate(ibovespa_monthly$Close)[-1,])*100
plot.zoo(ibovespa_return, xlab="Mês", ylab = "Porcentagem")

table.CalendarReturns(ibovespa_return)
    
asked by anonymous 01.06.2017 / 05:15

1 answer

3

Note that as of 2013-06-27, the ibovespa$IBOV.Volume column has only NA . The to.monthly function is not able, as far as I know, to deal with this lack of information.

Notice that if I switch assets, this error no longer occurs:

petr4         <- getSymbols('petr4', from=StartDate, to=EndDate, auto.assign = F)
petr4_monthly <- to.monthly(petr4)
petr4_monthly

I understand little of the stock market, but I do not think it makes sense to record the volume of the Bovespa index as a whole. It makes sense to think about the trading volume of a particular paper, be it VALE5, ITUB4 or PETR4, as in the example. But from the Bovespa as a whole I think it does not make sense. I at least never saw it.

So what I suggest is remove column 5 from object bovespa so that the other results are calculated correctly.

ibovespa         <- getSymbols('IBOV', from=StartDate, to=EndDate, auto.assign = F)
ibovespa         <- ibovespa[, -5]
ibovespa_monthly <- to.monthly(ibovespa)
    
01.06.2017 / 13:41