Friday, August 21, 2009

Pricing European Options by using Monte Carlo Simulation


In my previous article, price of european option (put and call) is estimated by using binomial model (Cox-Ross-Rubinstein (CRR) approach [1]). In this article, i provide java and Scilab (similar to Matlab)
source code to estimate these option prices by Monte Carlo simulation.

In binomial model, intrinsic value of an asset (S_T) at expiry t
ime (T) is estimated with a sequence of discrete time steps, at each step, stock price is estimated with a probability (either down or up probability. In monte carlo simulation, intrinsic value of an asset (S_T) at expiry time (T) is obtained from a normal distribution such as [2]:
where, r is annual interest rate S_t asset price at time t and sigma is volatility and x is normal distribution variable.

Having estimated S_T, option's payoff can be estimated easily (max (0, X-S_T) or max (0, S_T-X) for call and put options respectively, where X is options strike, exercise price). Based on expected values of pay off functions which generated with monte carlo simulation, option prices can be calculated as follows for european call option:


Source code of this estimation in java and
Scilab is listed


1:  // SciLab (Matlab) Source code
2: // Estimate European Option price by Monte Carlo Simulation
3: // denizstij (http://denizstij.blogspot.com/),
4: // Aug-2009
5: asset=230; //S
6: strike=210;//X
7: volatility=0.25; //sigma
8: r=0.04545;
9: time=0.5;
10: num_sims=10000;
11: R= (r-0.5*volatility^2)*time;
12: SD=volatility*sqrt(time);
13: sum_call_payoffs=0.0;
14: sum_put_payoffs=0.0;
15: for i=0:num_sims,
16: S_T= asset*exp(R+SD*rand(1,'normal'));
17: sum_call_payoffs=sum_call_payoffs+max([0,S_T-strike]);
18: sum_put_payoffs=sum_put_payoffs+max([0,strike-S_T]);
19: end
20: eu_call_option_price= exp(-r*time)*(sum_call_payoffs/double(num_sims))
21: eu_put_option_price= exp(-r*time)*(sum_put_payoffs/double(num_sims))


1:  package com.denizstij.finance.pricing;
2: import java.util.ArrayList;
3: import java.util.List;
4: import java.util.Random;
5: /**
6: *
7: * Estimate European Option price by Monte Carlo Simulation
8: * @author denizstij (http://denizstij.blogspot.com/)
9: * Aug-2009
10: *
11: */
12: public class EuropeanOptionPricingByMonteCarlo {
13: /**
14: * Estimate European Option price by Monte Carlo Simulation
15: *
16: * @param asset Current Asset Price
17: * @param strike Exercise Price
18: * @param volatility Annual volatility
19: * @param intRate Annual interest rate
20: * @param expiry: Time to maturity (in terms of year)
21: * @param num_sim : Number of simulations
22: * @return Put and call price of european options based on
23: * Monte Carlo Simulation
24: */
25: public strictfp List<Double> estimatePrice(double asset,
26: double strike,
27: double volatility,
28: double intRate,
29: double time,
30: int num_sim) {
31: List<Double> results = new ArrayList<Double>();
32: double R = (intRate - 0.5 *Math.pow(volatility,2))*time;
33: double SD = volatility * Math.sqrt(time);
34: double dF = Math.exp(-intRate*time); // discount Factor
35: double sumCallPayoffs=0.0;
36: double sumPutPayoffs=0.0;
37: Random random= new Random();
38: for (int i = 0; i <= num_sim; i++) {
39: double nextGaussian = random.nextGaussian();
40: double S_T= asset*Math.exp(R+SD*nextGaussian);
41: sumCallPayoffs+=callPayOff(S_T,strike);
42: sumPutPayoffs+=putPayOff(S_T,strike);
43: }
44: double callOptionPrices= dF*sumCallPayoffs/num_sim;
45: double putOptionPrices= dF*sumPutPayoffs/num_sim;
46: results.add(callOptionPrices);
47: results.add(putOptionPrices);
48: return results;
49: }
50: // Pay off method for put options
51: private double putPayOff(double stockPrice, double strike) {
52: return Math.max(strike - stockPrice, 0);
53: }
54: // Pay off method for call options
55: private double callPayOff(double stockPrice, double strike) {
56: return Math.max(stockPrice - strike, 0);
57: }
58: public static void main(String args[]) {
59: EuropeanOptionPricingByMonteCarlo euOptionPricing = new EuropeanOptionPricingByMonteCarlo();
60: List<Double> results = euOptionPricing.estimatePrice(
61: 230,
62: 210,
63: 0.25,
64: 0.04545,
65: 0.5, // In terms of year
66: 10000);
67: Double callOptionPrice = results.get(0);
68: Double putOptionPrice = results.get(1);
69: System.out.println("call Option Price:" + callOptionPrice);
70: System.out.println("put Option Price:" + putOptionPrice);
71: }
72: }

6 comments:

Unknown said...

Maximum payout portion - Professional and well-liked digital options brokers supply maximum payout percentage for their investors. Binary Options One must consider the binary trading platform that may offer minimum 75% in order to 90% payout percentage for each won and lost expense. For every unsuccessful industry, there must be minimal 5% to 10% returns towards the traders.

Unknown said...

7 steps to health & the big diabetes lie is an excellent program, which is especially designed for the diabetes people who are all suffering in a long run in diabetes & 7 steps to health And The Big Diabetes Lie helps how to control your blood sugar level. 7 steps to health And The Big Diabetes Lie is a total natural home course which doesn’t require medication otherwise expensive equipment. Following properly tips and techniques included in 7 steps to health And The Big Diabetes Lie program will give you an important opportunity to be healthy pro the relax of your life. 7 steps to health And The Big Diabetes Lie program show Product Review some top secret on how to enhance the insulin level through natural methods, healthy meals & simple exercises.

Unknown said...

Get the latest FOX technology news for today: breaking news and analysis on computing, the web, blogs, games, gadgets, social media, broadband and more.

Unknown said...

We are best and trusted bangladeshi online news portal website. Everyday we publish the national and international latest news. If you want to get regular newslatter from our newspaper, please go home page পোশাক শিল্প and click the below subscribe button.

Unknown said...

View entertainment news and videos for the latest movie, music, TV and celebrity headlines on entertainment news latest

Sarah Jordan said...

I am heartily impressed by your blog and learn more from your article. Thank you so much for sharing with us. I find another blog as like it. If you want to look, visit here Monte Carlo Simulation Stock Trading Systems , It’s also more informative.