View source: R/EuropeanStandardMonteCarlo.R
EuropeanStandardMonteCarlo | R Documentation |
The function computes the price of a European Option using Monte Carlo simulation
EuropeanStandardMonteCarlo(s, K, r, b, v, nSim, t, type)
s |
price of underliying |
K |
strike price |
r |
risk free rate |
b |
cost of carry rate |
v |
volatility |
nSim |
number of simulations |
t |
time to maturity |
type |
call "C" or put "P" |
Monte Carlo simulation is a numerical method that is useful in many situations when no closed-form solution is available. Monte Carlo simulating in option pricing, originally introduced by Boyle (1977), can be used to value most types of European options and, as we will see, also American options
Price European Option computed using Monte Carlo simulation given the price of the underlying s, the trike price K, the risk free rate r, the cost of carrying rate b, the volatility v, the number of simulation nSim, the time to maturity of the option t, the type of call "C" or put "P"
Colzani Luca, Magni Marta, Mancassola Gaia, Kakkanattu Jenson
Espen Gaarder Haug(2007):The Complete Guide to Option Pricing Formulas
EuropeanStandardMonteCarlo(100,90,0.05,0.02,0.3,1000,0.5,"C") ## The function is currently defined as function (s, K, r, b, v, nSim, t, type) { sum <- 0 if (type == "C") { for (j in 1:nSim) { st <- s * exp(((b - v^2)/2) * t + v * sqrt(t) * rnorm(j)) sum <- sum + max((st - K), 0) } } if (type == "P") { for (j in 1:nSim) { st <- s * exp(((b - v^2)/2) * t + v * sqrt(t) * rnorm(j)) sum <- sum + max((K - st), 0) } price <- (exp(-r * t) * sum)/nSim } price <- (exp(-r * t) * sum)/nSim return(round(price, 2)) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.