Showing posts with label Stock price GE. Show all posts
Showing posts with label Stock price GE. Show all posts

## Stock price GE with R

[1] "GE"
> chartSeries(Cl(GE))

> ge.ret <- dailyReturn(Cl(GE), type='log')
> par(mfrow=c(2,2))
> acf(ge.ret, main="Return ACF");
> pacf(ge.ret, main="Return PACF");
> acf(ge.ret^2, main="Squared return ACF");
> pacf(ge.ret^2, main="Squared return PACF")

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

> plot(density(ge.ret), main='Return empirical distribution');curve(dnorm(x,
+ mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")

> par(mfrow=c(1,1))
> kurtosis(ge.ret)
daily.returns
13.41263
> plot(density(ge.ret), 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(ge.ret), xlim=c(-5*s,5*s),log='y', main='Density on log-scale')

Warning message:
In xy.coords(x, y, xlabel, ylabel, log) :
2 y values <= 0 omitted from logarithmic plot
> curve(dnorm(x, mean=m,sd=s), from=-5*s, to=5*s, log="y", add=TRUE,
+       col="red")
> qqnorm(ge.ret);qqline(ge.ret);
> library("rugarch", lib.loc="~/R/win-library/3.6")

Attaching package: ‘rugarch’

The following object is masked from ‘package:stats’:

sigma

> chartSeries(ge.ret)

> garch11.spec = ugarchspec(variance.model = list(model="sGARCH",
+ garchOrder=c(1,1)), mean.model = list(armaOrder=c(0,0)))
> ge.garch11.fit = ugarchfit(spec=garch11.spec, data=ge.ret)
> coef(ge.garch11.fit)
mu        omega       alpha1        beta1
3.861505e-05 2.575845e-06 8.131172e-02 9.123514e-01
> vcov(ge.garch11.fit)
[,1]          [,2]          [,3]          [,4]
[1,]  3.614127e-08 -4.351465e-11 -4.218265e-07  4.497121e-07
[2,] -4.351465e-11  9.720901e-12  9.102558e-08 -9.774757e-08
[3,] -4.218265e-07  9.102558e-08  9.246542e-04 -9.716136e-04
[4,]  4.497121e-07 -9.774757e-08 -9.716136e-04  1.030021e-03
> infocriteria(ge.garch11.fit)

Akaike       -5.650048
Bayes        -5.643716
Shibata      -5.650050
Hannan-Quinn -5.647803

> uncmean(ge.garch11.fit)
[1] 3.861505e-05
> uncvariance(ge.garch11.fit)
[1] 0.0004064876
> signbias(ge.garch11.fit)
t-value      prob sig
Sign Bias          1.3269412 0.1846045
Negative Sign Bias 2.1802516 0.0292974  **
Positive Sign Bias 0.2160352 0.8289714
Joint Effect       5.1781793 0.1592054

> newsimpact(ge.garch11.fit)
\$zy
[1] 0.0076914904 0.0073987981 0.0071120791 0.0068313333
[5] 0.0065565609 0.0062877619 0.0060249361 0.0057680836
[9] 0.0055172045 0.0052722987 0.0050333662 0.0048004070
[13] 0.0045734211 0.0043524085 0.0041373692 0.0039283033
[17] 0.0037252106 0.0035280913 0.0033369453 0.0031517726
[21] 0.0029725732 0.0027993471 0.0026320944 0.0024708149
[25] 0.0023155088 0.0021661760 0.0020228164 0.0018854302
[29] 0.0017540174 0.0016285778 0.0015091115 0.0013956186
[33] 0.0012880990 0.0011865526 0.0010909796 0.0010013799
[37] 0.0009177536 0.0008401005 0.0007684207 0.0007027143
[41] 0.0006429812 0.0005892213 0.0005414348 0.0004996217
[45] 0.0004637818 0.0004339152 0.0004100220 0.0003921020
[49] 0.0003801554 0.0003741821 0.0003741821 0.0003801554
[53] 0.0003921020 0.0004100220 0.0004339152 0.0004637818
[57] 0.0004996217 0.0005414348 0.0005892213 0.0006429812
[61] 0.0007027143 0.0007684207 0.0008401005 0.0009177536
[65] 0.0010013799 0.0010909796 0.0011865526 0.0012880990
[69] 0.0013956186 0.0015091115 0.0016285778 0.0017540174
[73] 0.0018854302 0.0020228164 0.0021661760 0.0023155088
[77] 0.0024708149 0.0026320944 0.0027993471 0.0029725732
[81] 0.0031517726 0.0033369453 0.0035280913 0.0037252106
[85] 0.0039283033 0.0041373692 0.0043524085 0.0045734211
[89] 0.0048004070 0.0050333662 0.0052722987 0.0055172045
[93] 0.0057680836 0.0060249361 0.0062877619 0.0065565609
[97] 0.0068313333 0.0071120791 0.0073987981 0.0076914904

\$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])

### Black-Scholes formula-R

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