We will obtain the price data of AAPLstock from Yahoo! -R Finance for the given time period
plot(ni.garch11$zx, ni.garch11$zy, type="l", lwd=2,col="blue",main="GARCH(1,1)-newsimpact", ylab=ni.garch11$yexpr, xlab=ni.garch11$xexpr)
egarch11.spec = ugarchspec(variance.model = list(model="eGARCH",
+ garchOrder=c(1,1)), mean.model = list(armaOrder=c(0,0)))
> aapl.egarch11.fit = ugarchfit(spec=egarch11.spec, data=ret.aapl)
> coef(aapl.egarch11.fit)
mu omega alpha1
0.001355199 -0.313404827 -0.107024135
beta1 gamma1
0.960077271 0.174988083
"AAPL"
> ret.aapl <- dailyReturn(Cl(AAPL), type='log')
> chartSeries(ret.aapl)
> chartSeries(Cl(AAPL))
> addRSI()
> tail(AAPL)
AAPL.Open AAPL.High AAPL.Low
2020-01-16 313.59 315.70 312.09
2020-01-17 316.27 318.74 315.00
2020-01-21 317.19 319.02 316.00
2020-01-22 318.58 319.99 317.31
2020-01-23 317.92 319.56 315.65
2020-01-24 320.25 323.33 317.52
AAPL.Close AAPL.Volume
2020-01-16 315.24 27207300
2020-01-17 318.73 34454100
2020-01-21 316.57 27710800
2020-01-22 317.70 25458100
2020-01-23 319.23 26118000
2020-01-24 318.31 36600500
AAPL.Adjusted
2020-01-16 315.24
2020-01-17 318.73
2020-01-21 316.57
2020-01-22 317.70
2020-01-23 319.23
2020-01-24 318.31
> getSymbols("AAPL", env = aapl_stock, src = "yahoo", from = as.Date("2010-01-01"), to = as.Date("2019-08-12"))
[1] "AAPL"
we need to define the character vector
AAPL<-aapl_stock$AAPL> head(AAPL)
AAPL.Open AAPL.High AAPL.Low
2010-01-04 30.49000 30.64286 30.34000
2010-01-05 30.65714 30.79857 30.46429
2010-01-06 30.62571 30.74714 30.10714
2010-01-07 30.25000 30.28571 29.86429
2010-01-08 30.04286 30.28571 29.86572
2010-01-11 30.40000 30.42857 29.77857
AAPL.Close AAPL.Volume
2010-01-04 30.57286 123432400
2010-01-05 30.62571 150476200
2010-01-06 30.13857 138040000
2010-01-07 30.08286 119282800
2010-01-08 30.28286 111902700
2010-01-11 30.01572 115557400
AAPL.Adjusted
2010-01-04 26.68133
2010-01-05 26.72746
2010-01-06 26.30233
2010-01-07 26.25370
2010-01-08 26.42825
2010-01-11 26.19511
> chartSeries(AAPL,multi.col=TRUE,theme="white")
> addMACD()
> addBBands()
> AAPL_return <-
+ log(AAPL$AAPL.Close/AAPL$AAPL.Open)
> qqnorm(AAPL_return, main = "Normal Q-Q Plot of AAPL daily log return",
+ xlab = "Theoretical Quantiles",
+ ylab = "Sample Quantiles", plot.it = TRUE, datax = FALSE
+ )
> qqline(AAPL_return, col="red")



0 Comments