1
Through the following code, I import the stock exchange data the Ibovespa Index, Petrobras and the American Index S&P 500. However, the dates of the observations are not exactly matching
# Carregar pacote de importação de dados da bolsa
library(BatchGetSymbols)
# Inputs
# data inicial
first.date <- as.Date("2017-01-01")
#data final
last.date <- Sys.Date()
#frequencia das observações
freq.data <- 'daily'
# Ativos a serem baixados
tickers <- c("^BVSP","PETR4.SA","^GSPC")
#função que baixa ativos
ativos <- BatchGetSymbols(tickers = tickers,
first.date = first.date,
last.date = last.date,
freq.data = freq.data,
cache.folder = file.path(tempdir(),
'BGS_Cache') )
Someone would know to inform me a way to temporarily pair the data, that is, to have only observations of dates with values for the three assets, eliminating from the data those dates where there is observation for only one or two assets.
I couldn’t implement
– Henrique Faria de Oliveira
What was the problem that appeared?
– Tomás Barcellos
sorry for the delay, I managed to solve the problem with your suggestion, thank you very much
– Henrique Faria de Oliveira