Tarea 4

library(ggplot2)
library(plotly)
library(forecast)
library(tseries)
library(fGarch)

con=url("https://finance.yahoo.com")

A continuación analizaremos el comportamiento de los precios de la empresa The Clorox Company.

Clorox_Company = get.hist.quote(instrument = "CLX", start = "2016-12-31",quote = "Close",compression = "m")
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
## 
## This message is shown once per session and may be disabled by setting 
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
## time series starts 2017-01-01
## time series ends   2020-10-01
plot(Clorox_Company)

Clorox es una compañia dedicada a productos de aseo y desinfección, por lo que la situación de la pandemia de este año le benefició notablemente, dado que los hogares demandaron más sus productos para poder desinfectar y tomar medidas preventivas frente al Covid 19.

Clorox = as.numeric(Clorox_Company)
length(Clorox_Company)
## [1] 46
fecha=time(Clorox_Company)  

fecha1=rep(fecha,1) 
precios=(Clorox_Company)  
empresa=(rep("Clorox_Company",length(Clorox_Company)))


df1=data.frame(fecha1,precios,empresa)
df1
##                fecha1  Close        empresa
## 2017-01-01 2017-01-01 120.00 Clorox_Company
## 2017-02-01 2017-02-01 136.81 Clorox_Company
## 2017-03-01 2017-03-01 134.83 Clorox_Company
## 2017-04-01 2017-04-01 133.69 Clorox_Company
## 2017-05-01 2017-05-01 135.73 Clorox_Company
## 2017-06-01 2017-06-01 133.24 Clorox_Company
## 2017-07-01 2017-07-01 133.49 Clorox_Company
## 2017-08-01 2017-08-01 138.53 Clorox_Company
## 2017-09-01 2017-09-01 131.91 Clorox_Company
## 2017-10-01 2017-10-01 126.53 Clorox_Company
## 2017-11-01 2017-11-01 139.29 Clorox_Company
## 2017-12-01 2017-12-01 148.74 Clorox_Company
## 2018-01-01 2018-01-01 141.69 Clorox_Company
## 2018-02-01 2018-02-01 129.08 Clorox_Company
## 2018-03-01 2018-03-01 133.11 Clorox_Company
## 2018-04-01 2018-04-01 117.20 Clorox_Company
## 2018-05-01 2018-05-01 120.83 Clorox_Company
## 2018-06-01 2018-06-01 135.25 Clorox_Company
## 2018-07-01 2018-07-01 135.17 Clorox_Company
## 2018-08-01 2018-08-01 144.98 Clorox_Company
## 2018-09-01 2018-09-01 150.41 Clorox_Company
## 2018-10-01 2018-10-01 148.45 Clorox_Company
## 2018-11-01 2018-11-01 165.62 Clorox_Company
## 2018-12-01 2018-12-01 154.14 Clorox_Company
## 2019-01-01 2019-01-01 148.38 Clorox_Company
## 2019-02-01 2019-02-01 158.03 Clorox_Company
## 2019-03-01 2019-03-01 160.46 Clorox_Company
## 2019-04-01 2019-04-01 159.73 Clorox_Company
## 2019-05-01 2019-05-01 148.81 Clorox_Company
## 2019-06-01 2019-06-01 153.11 Clorox_Company
## 2019-07-01 2019-07-01 162.60 Clorox_Company
## 2019-08-01 2019-08-01 158.16 Clorox_Company
## 2019-09-01 2019-09-01 151.87 Clorox_Company
## 2019-10-01 2019-10-01 147.69 Clorox_Company
## 2019-11-01 2019-11-01 148.23 Clorox_Company
## 2019-12-01 2019-12-01 153.54 Clorox_Company
## 2020-01-01 2020-01-01 157.31 Clorox_Company
## 2020-02-01 2020-02-01 159.42 Clorox_Company
## 2020-03-01 2020-03-01 173.25 Clorox_Company
## 2020-04-01 2020-04-01 186.44 Clorox_Company
## 2020-05-01 2020-05-01 206.25 Clorox_Company
## 2020-06-01 2020-06-01 219.37 Clorox_Company
## 2020-07-01 2020-07-01 236.51 Clorox_Company
## 2020-08-01 2020-08-01 223.50 Clorox_Company
## 2020-09-01 2020-09-01 210.17 Clorox_Company
## 2020-10-01 2020-10-01 218.37 Clorox_Company
Graf1=ggplot(df1, aes(x=fecha1, y=precios, col=empresa))+geom_line()+theme_bw()+xlab("Fecha")+ylab("Precio de Apertura")+
ggtitle("Precio Acciones Clorox Company en Bolsa (Us Dolar)")+theme(legend.position = "bottom", plot.title = element_text(hjust= 0.5)) 

Graf1
## Don't know how to automatically pick scale for object of type zoo. Defaulting to continuous.

ggplotly(Graf1)
## Don't know how to automatically pick scale for object of type zoo. Defaulting to continuous.

Si observamos en la gráfica interactiva, desde el primero de febrero del 2020 inició una tendencia alcista más pronunciada delo que venía antes, llevando a superar máximos históricos hasta julio, que fue donde inició un retroceso dado que en muchos países ya empezó a controlarse los efectos de la pandemia.