You are on page 1of 1

hw5

YIK LUN, KEI


2017/6/2

Exercise 1 (b)

p0 = 50;mu = 0.2;sigma = 0.25;weeks = 52


mu.weekly = mu / weeks
sigma.weekly = sigma * 1/sqrt(weeks)
set.seed(1)
r <- rnorm(52, mu.weekly, sigma.weekly)
price = p0 + cumsum(r)
plot(price, type = "l", lwd = 2, xlab = "time", main = "Stock Price Simulation")

Stock Price Simulation


50.4
50.3
50.2
price

50.1
50.0

0 10 20 30 40 50

time

Exercise 6
The annual volatility for APPLE is 21.1%
AAPL <- read.csv("/Users/air/Downloads/AAPL.csv", sep = ",", header = TRUE)
s1 <- AAPL[316:1,]
u <- s1$Adj.Close[-nrow(s1)] / s1$Adj.Close[-1]
volatility <- sd(log(u))*sqrt(length(u));volatility

## [1] 0.2110254

You might also like