【发布时间】:2020-06-23 07:29:06
【问题描述】:
我正在尝试就股票价格的变化(股票路径)绘制类似于布朗运动的线。
# Parameter Setting
S0<-1
r<-0.555
M<-1000 # the number of time steps
sigma<-0.5
T<-1 # Time to Expiration
X<-1
N<-1000 # The number of simulations
dt<-T/M; # Calculate the time interval
S<-matrix(0L, nrow = M+1, ncol =N)
ds<-matrix(0L, nrow = M, ncol = N)
S[1,]<-matrix(S0,1,N) # Initialize Stock
Value
for (t in 1:M){
ds[t,]<-
r*S[t,]*dt+sigma*sqrt(dt)*S[t,]*rnorm(N)
S[t+1,]<-ds[t,]+S[t,]
}
call_price<-pmax(S[M+1,]-X,0)
这是我迄今为止所做的,但试图表达计算库存路径的方程式是个问题。
这是等式:
此外,绘制显示股票价格随时间变化的图表的最佳方法是什么?
需要这样的图表或包含 5 条股票价格路径的图表:
【问题讨论】:
-
我不明白方程式部分。你想用 R 写一个乳胶式的方程吗?