Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to simulate european call payoff in R. I got the code from Brownian motion and Geometric Brownian motion, however, I cannot get

I am trying to simulate european call payoff in R. I got the code from Brownian motion and Geometric Brownian motion, however, I cannot get the Payoff model run. Here are my codes: #Standard Brownian Motion set.seed(123) dt=0.001 x=rnorm(1,mean=0,sd=dt) D=5000 i=seq(1,D,by=1) n=length(i) B[0]=0 B=numeric(n) for(t in 2:D){ B[t]=B[t-1]+rnorm(1,mean=0,sd=dt) print(B[t])} plot(i,B,main="Standard Brownian Motion",xlab="time",ylab="position",type="l")

#Geometric Brownian Motion GBM<- function(mu, sigma, T, g0) { dt <-0.001 t <-seq(0,T,by=dt) n <-length(t) g <-numeric(n) g<-g0*exp(cumsum((mu-sigma*sigma/2)*T/n + sigma*sqrt(T/n)*rnorm(n))) plot(t,g,main="Geometric Brownian Motion",xlab="time",ylab="Value",type="l") } GBM(0.5,0.08,50,10)

#Black-Scholes model C<-function(sigma,t,K,r,g0) { s0=g0 S<-g d1<-(ln(S/K)+(r+sigma/2)*t)/sqrt(sigma*t) d2<-d1-sqrt(sigma*t) n<-length(t) c<-numeric(n) c<-S*norm(d1)-norm(d2)*K*exp(cumsum(-r*t)) plot(t,c,main="European call option payoff",xlab="time",ylab="payoff",type="l") } C(0.08,1,150,0.03,10)

I don't know what's wrong with my Black-Schole, model. Seems like I can't make S=g work.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems On GPUs In Databases

Authors: Johns Paul ,Shengliang Lu ,Bingsheng He

1st Edition

1680838482, 978-1680838480

More Books

Students also viewed these Databases questions

Question

Do not go, wait until I come

Answered: 1 week ago