Precios <- dygraph(retornos, main = "Precios de Amazon, Apple, Netflix y NVIDIA") %>%
dyAxis("y", label = "Precios") %>%
dyRangeSelector(dateWindow = c("2015-01-01", "2023-09-01")) %>%
dyLegend(show = "always") %>%
dyOptions(colors = RColorBrewer::brewer.pal(4, "Set1"))
Precios
round(tail(precio.cierre, n = 5), 3)
## AMZN.Close AAPL.Close NFLX.Close NVDA.Close
## 2023-08-24 131.84 176.38 406.93 471.63
## 2023-08-25 133.26 178.61 416.03 460.18
## 2023-08-28 133.14 180.19 418.06 468.35
## 2023-08-29 134.91 184.12 429.99 487.84
## 2023-08-30 135.07 187.65 434.67 492.64
dy_graficos <- list(
dygraphs::dygraph(retornos[, c("AMZN", "NFLX", "nvda")], main = "Precios de Amazon, Netflix y NVIDIA"),
dygraphs::dygraph(retornos[, "AAPL", drop = FALSE], main = "Precio de Apple")
)
htmltools::browsable(htmltools::tagList(dy_graficos))
AMZN_2015 <- subset(precio.cierre[, 1], index(precio.cierre) >= "2015-01-01" & index(precio.cierre) <= "2015-12-31")
AMZN_2015[c(1:5, nrow(AMZN_2015))]
## AMZN.Close
## 2015-01-02 15.4260
## 2015-01-05 15.1095
## 2015-01-06 14.7645
## 2015-01-07 14.9210
## 2015-01-08 15.0230
## 2015-12-31 33.7945
AMZN_2020 <- subset(precio.cierre[, 1], index(precio.cierre) >= "2020-01-01" & index(precio.cierre) <= "2020-12-31")
AMZN_2020[c(1:5, nrow(AMZN_2020))]
## AMZN.Close
## 2020-01-02 94.9005
## 2020-01-03 93.7485
## 2020-01-06 95.1440
## 2020-01-07 95.3430
## 2020-01-08 94.5985
## 2020-12-31 162.8465
par(mfrow = c(2, 1))
# Histograma 2015
hist(AMZN_2015, col = "yellow", border = "blue", main = "Densidad de los Precios AMZN en 2015", xlab = "Precios Cierre", breaks = 20)
lines(density(AMZN_2015), lwd = 2, col = 'red')
# Histograma 2020
hist(AMZN_2020, col = "blue", border = "blue", main = "Densidad de los Precios AMZN en 2020", xlab = "Precios Cierre", breaks = 20)
lines(density(AMZN_2020), lwd = 2, col = 'red')
