Code covered by the BSD License  

Highlights from
Pricing Derivatives Securities using MATLAB

image thumbnail

Pricing Derivatives Securities using MATLAB

by

 

02 Apr 2007 (Updated )

Examples of pricing derivatives securities using MATLAB

examplemonteBS.m
%% Pricing Derivatives Securities using Matlab
%
% This demo illustrates how to price options using Monte 
% Carlo simulation and compares the results with the Black-Scholes formula. 

% Copyright 1995-2010 The MathWorks, Inc.

%% Price options using Monte Carlo simulation
%
% Use monte carlo simulation to price an european call and put with the
% following data
%
% Option: Price = 50, Strike = 60, Maturity = 24 months 
%
% Interest rate = 4%, Volatility = 30%

%OptionPrice = optionvanilla(So, Strike, Rate, Maturity, Sigma, DivYield, NSims, NSteps, OptType)

% Compute the price of the call option and display the simulated paths
 CallPrice = optionvanilla(50,60,0.04,2,0.30,0,15000,50,'call','true')
 
% Compute the price of the put option
 PutPrice = optionvanilla(50,60,0.04,2,0.30,0,15000,50,'put')
 

%% Compute the price of the options using the Black-Scholes formula
%
% Use Black-Scholes to price the vanilla options
%
% [Call,Put] = blsprice(Price, Strike, Rate, Time, Volatility) 

[BSCall,BSPut] = blsprice(50, 60, 0.04, 24/12, 0.30)

%% Compare the two methods by increasing the number of simulations
%
% Increase the number of simulations to 500000

CallPrice50 = optionvanilla(50,60,0.04,2,0.30,0,500000,50,'call')

%%
% Increase the number of steps to 60
CallPrice60 = optionvanilla(50,60,0.04,2,0.30,0,500000,60,'call')

Contact us