Monday, September 14, 2009

Pricing European Options by Black-Scholes Model

In my previous blogs, price of european call and put options are estimated by Monte Carlo Simulation and Binomial Model. In this blog, these options' prices are estimated by Black-Scholes (BS) model. BS model is more optimal pricing model than previous two methods. Actually, Monte Carlo simulation and Binomal model aims to approximate BS model.

Price of european call and put options is estimated as follows by using BS model:

where
S: Asset price
E:Strike price
D: Divident
r:Interest Rate
Sigma: Variance
t:Current time
T:Strike time
N(x): Normal Cumulative Density Function

Below sample C# and Matlab source code of Black-Scholes Model without any divident contribution is listed.


1:  % Matlab Source Code  
2: % Estimatation of European Call and Put Option by Black-Scholes Model
3: % denizstij (http://denizstij.blogspot.com/),
4: % Sep,2009
5: asset=230; %S
6: strike=210;%X
7: volatility=0.25; %sigma
8: r=0.04545;
9: time=0.5;
10: d1=(log(asset/strike)+(r+(volatility^2)/2)*time)/volatility/(sqrt(time));
11: %d2=(log(asset/strike)+(r-(volatility^2)/2)*time)/volatility/(sqrt(time));
12: d2=d1-volatility*(sqrt(time))
13: eu_call_option_price= asset*normcdf(d1,0,1)-strike*exp(-r*time)*normcdf(d2,0,1)
14: eu_put_option_price= -asset*normcdf(-d1,0,1)+strike*exp(-r*time)*normcdf(-d2,0,1)


1:  using System;  
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Text;
5: using CenterSpace.Free;
6: namespace Denizstij.Finance.Pricing.EuropeanOptionPricingByBlackScholes
7: {
8: /// <summary>
9: /// Estimates European Call and Put options by using Black-Scholes model
10: /// denizstij (http://denizstij.blogspot.com/)
11: /// Sep-2009
12: /// </summary>
13: class EuropeanOptionPricingByBlackScholes
14: {
15: // CenterSpace.Free.NormalDist to estimate normal cumulative density function
16: // by CenterSpace Software (http://www.centerspace.net/resources.php)
17: private NormalDist normDist = new NormalDist(0, 1);
18: // Price estimator
19: public List<double> estimatePrice(double asset, double strike, double volatility, double intRate, double time)
20: {
21: double d1 = (Math.Log(asset / strike) + (intRate + Math.Pow(volatility, 2) / 2) * time) / volatility / (Math.Sqrt(time));
22: double d2 = d1 - volatility * (Math.Sqrt(time));
23: double eu_call_option_price = asset * normDist.CDF(d1) - strike * Math.Exp(-intRate * time) * normDist.CDF(d2);
24: double eu_put_option_price = -asset * normDist.CDF(-d1) + strike * Math.Exp(-intRate * time) * normDist.CDF(-d2);
25: List<double> prices = new List<double>();
26: prices.Add(eu_call_option_price);
27: prices.Add(eu_put_option_price);
28: return prices;
29: }
30: static void Main(string[] args)
31: {
32: EuropeanOptionPricingByBlackScholes pricing = new EuropeanOptionPricingByBlackScholes();
33: List<double> prices = pricing.estimatePrice(230,
34: 210,
35: 0.25,
36: 0.04545,
37: 0.5 // In terms of years
38: );
39: System.Console.WriteLine("Call Option Price:" + prices.ElementAt(0)); // £30.741
40: System.Console.WriteLine("Put Option Price:" + prices.ElementAt(1)); // £6.023
41: }
42: }
43: }

No comments: