Showing posts with label stock price of google. Show all posts
Showing posts with label stock price of google. Show all posts

Wednesday, October 16, 2019

Stock price of google

The stock price of google

The google stock price has been taken from yahoo.com since 2004 to 15oct20019
[1] "GOOG"
> chartSeries(ClCl(GOOG))
> chartSeries(Cl(GOOG))
> addMACD()
> addRSI()
> addBBands()
stock price of google

> goog <- dailyReturn(Cl(GOOG), type='log')
> par(mfrow=c(2,2))> acf(ret, main="Return ACF");Error in as.ts(x) : object 'ret' not found
> pacf(goog, main="Return PACF");
> acf(goog^2, main="Squared return ACF");
> pacf(goog^2, main="Squared return PACF")
> acf(goog, main="Return ACF");
stock price of google acf

> par(mfrow=c(1,1))
> par(mfrow=c(1,1))
> m=mean(goog);s=sd(goog);
> par(mfrow=c(1,2))
> hist(goog, nclass=40, freq=FALSE, main='Return histogram');curve(dnorm(x,
+ mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")
stock price of google histogram

> plot(density(goog), main='Return empirical distribution');curve(dnorm(x,mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")
stock price of google
Add caption

> par(mfrow=c(1,1))
> kurtosis(goog)
daily.returns 
     12.66967 
> plot(density(goog), main='Return EDF - upper tail', xlim = c(0.1, 0.2),
+      ylim=c(0,2));
> curve(dnorm(x, mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")
> plot(density(goog), xlim=c(-5*s,5*s),log='y', main='Density on log-scale')
> curve(dnorm(x, mean=m,sd=s), from=-5*s, to=5*s, log="y", add=TRUE,
+       col="red")
stock price of google density

> qqnorm(goog);qqline(goog);
stock price of google QQ

> garch11.spec = ugarchspec(variance.model = list(model="sGARCH",
+ garchOrder=c(1,1)), mean.model = list(armaOrder=c(0,0)))
> goog.garch11.fit = ugarchfit(spec=garch11.spec, data=goog)
> coef(goog.garch11.fit)
          mu        omega       alpha1        beta1 
9.274865e-04 1.069049e-05 6.712059e-02 9.035678e-01 
> vcov(goog.garch11.fit) 
              [,1]          [,2]          [,3]
[1,]  6.658647e-08 -6.669035e-12  1.122512e-07
[2,] -6.669035e-12 -1.010435e-13  2.144569e-09
[3,]  1.122512e-07  2.144569e-09  1.135151e-05
[4,] -4.875341e-08 -1.045142e-09 -2.144153e-05
              [,4]
[1,] -4.875341e-08
[2,] -1.045142e-09
[3,] -2.144153e-05

[4,]  2.694538e-05

> infocriteria(goog.garch11.fit)                       Akaike       -5.274825Bayes        -5.268276Shibata      -5.274828Hannan-Quinn -5.272498

> newsimpact(goog.garch11.fit) 
$zy
  [1] 0.0063810911 0.0061394817 0.0059028030 0.0056710552
  [5] 0.0054442381 0.0052223519 0.0050053964 0.0047933718
  [9] 0.0045862780 0.0043841150 0.0041868827 0.0039945813
 [13] 0.0038072107 0.0036247709 0.0034472619 0.0032746838
 [17] 0.0031070364 0.0029443198 0.0027865340 0.0026336791
 [21] 0.0024857549 0.0023427615 0.0022046990 0.0020715672
 [25] 0.0019433663 0.0018200962 0.0017017568 0.0015883483
 [29] 0.0014798706 0.0013763237 0.0012777076 0.0011840223
 [33] 0.0010952678 0.0010114441 0.0009325512 0.0008585891
 [37] 0.0007895579 0.0007254574 0.0006662877 0.0006120489
 [41] 0.0005627408 0.0005183636 0.0004789171 0.0004444015
 [45] 0.0004148166 0.0003901626 0.0003704394 0.0003556470
 [49] 0.0003457854 0.0003408546 0.0003408546 0.0003457854
 [53] 0.0003556470 0.0003704394 0.0003901626 0.0004148166
 [57] 0.0004444015 0.0004789171 0.0005183636 0.0005627408
 [61] 0.0006120489 0.0006662877 0.0007254574 0.0007895579
 [65] 0.0008585891 0.0009325512 0.0010114441 0.0010952678
 [69] 0.0011840223 0.0012777076 0.0013763237 0.0014798706
 [73] 0.0015883483 0.0017017568 0.0018200962 0.0019433663
 [77] 0.0020715672 0.0022046990 0.0023427615 0.0024857549
 [81] 0.0026336791 0.0027865340 0.0029443198 0.0031070364
 [85] 0.0032746838 0.0034472619 0.0036247709 0.0038072107
 [89] 0.0039945813 0.0041868827 0.0043841150 0.0045862780
 [93] 0.0047933718 0.0050053964 0.0052223519 0.0054442381
 [97] 0.0056710552 0.0059028030 0.0061394817 0.0063810911

$zx
  [1] -0.300000000 -0.293939394 -0.287878788 -0.281818182
  [5] -0.275757576 -0.269696970 -0.263636364 -0.257575758
  [9] -0.251515152 -0.245454545 -0.239393939 -0.233333333
 [13] -0.227272727 -0.221212121 -0.215151515 -0.209090909
 [17] -0.203030303 -0.196969697 -0.190909091 -0.184848485
 [21] -0.178787879 -0.172727273 -0.166666667 -0.160606061
 [25] -0.154545455 -0.148484848 -0.142424242 -0.136363636
 [29] -0.130303030 -0.124242424 -0.118181818 -0.112121212
 [33] -0.106060606 -0.100000000 -0.093939394 -0.087878788
 [37] -0.081818182 -0.075757576 -0.069696970 -0.063636364
 [41] -0.057575758 -0.051515152 -0.045454545 -0.039393939
 [45] -0.033333333 -0.027272727 -0.021212121 -0.015151515
 [49] -0.009090909 -0.003030303  0.003030303  0.009090909
 [53]  0.015151515  0.021212121  0.027272727  0.033333333
 [57]  0.039393939  0.045454545  0.051515152  0.057575758
 [61]  0.063636364  0.069696970  0.075757576  0.081818182
 [65]  0.087878788  0.093939394  0.100000000  0.106060606
 [69]  0.112121212  0.118181818  0.124242424  0.130303030
 [73]  0.136363636  0.142424242  0.148484848  0.154545455
 [77]  0.160606061  0.166666667  0.172727273  0.178787879
 [81]  0.184848485  0.190909091  0.196969697  0.203030303
 [85]  0.209090909  0.215151515  0.221212121  0.227272727
 [89]  0.233333333  0.239393939  0.245454545  0.251515152
 [93]  0.257575758  0.263636364  0.269696970  0.275757576
 [97]  0.281818182  0.287878788  0.293939394  0.300000000

$yexpr
expression(sigma[t]^2)

$xexpr
expression(epsilon[t - 1])
conclusion
signbias(goog.garch11.fit) 
                     t-value                             prob sig
Sign Bias          1.0768888                  0.2815981    
Negative Sign Bias 0.6681522           0.5040769    
Positive Sign Bias 0.7067928            0.4797385    
Joint Effect       3.0046371                0.3909108 
> uncvariance(goog.garch11.fit) 
[1] 0.0003647183
> uncmean(goog.garch11.fit) 
[1] 0.0009274865

Black-Scholes formula-R

 Black-Scholes formula-R > BlackScholes <- function(TypeFlag = c("c", "p"), S, X, Time, r, b, sigma) { TypeFla...