Showing posts with label Stock-price-siemens. Show all posts
Showing posts with label Stock-price-siemens. Show all posts

Wednesday, October 9, 2019

Stock price siemens

Stock price siemens statistics-R

The stock price of Siemens has been analysed with statistics, addrsi,,macd.
> getSymbols("SIEMENS.NS", from="2004-01-01", to=Sys.Date())
[1] "SIEMENS.NS"
Warning message:
SIEMENS.NS contains missing values. Some functions will not work if objects contain missing values in the middle of the series. Consider using na.omit(), na.approx(), na.fill(), etc to remove or replace them.
> chartSeries(Cl(SIEMENS.NS))
> addMACD()
> addRSI()
> addBBands()
stock price siemens
> siemns <- dailyReturn(Cl(SIEMENS.NS), type='log')
> par(mfrow=c(2,2))
> acf(siemns, main="Return ACF");
> pacf(siemns, main="Return PACF");
> acf(siemns^2, main="Squared return ACF");
> pacf(siemns^2, main="Squared return PACF")
stock price siemens

> par(mfrow=c(1,1))
> m=mean(siemns);s=sd(siemns);
> par(mfrow=c(1,2))
> hist(siemns, 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 siemens

> plot(density(siemns), 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(siemns)
daily.returns 
      9.20781 
> plot(density(siemns), 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")
stock price siemens

> plot(density(siemns), 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 siemens

> qqnorm(siemn);qqline(siemn);
Error in qqnorm(siemn) : object 'siemn' not found
> qqnorm(siemns);qqline(siemns);
 stock price siemens

> chartSeries(siemns)
stock price siemens

> garch11.spec = ugarchspec(variance.model = list(model="sGARCH",
+ garchOrder=c(1,1)), mean.model = list(armaOrder=c(0,0)))
> siemns.garch11.fit = ugarchfit(spec=garch11.spec, data=siemns)
> coef(siemns.garch11.fit)
          mu        omega       alpha1        beta1 
0.0008824435 0.0000469490 0.1848055788 0.7393694448 
> vcov(siemns.garch11.fit) 
              [,1]          [,2]          [,3]
[1,]  9.633059e-08  5.796203e-12 -7.668345e-09
[2,]  5.796203e-12  4.182502e-11  7.238401e-08
[3,] -7.668345e-09  7.238401e-08  3.862402e-04
[4,] -2.261062e-08 -1.426169e-07 -4.186136e-04
              [,4]
[1,] -2.261062e-08
[2,] -1.426169e-07
[3,] -4.186136e-04
[4,]  6.275912e-04
> infocriteria(siemns.garch11.fit)
                      
Akaike       -4.853118
Bayes        -4.846673
Shibata      -4.853120
Hannan-Quinn -4.850830
Conclusion
> uncmean(siemns.garch11.fit) 
[1] 0.0008824435
> uncvariance(siemns.garch11.fit)
[1] 0.000619176

Black-Scholes formula-R

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