A set of MATLAB functions for calculating option prices, along with several examples of how the functions can be used.
Developed from theory presented in Option Trading by Euan Sinclair.
The function "permn.m" is copyright (c) 2016, Jos van der Geest: permn - Mathworks.com.
clear
clc
addpath(genpath('functions'))r = 0.03; % override defaults
sigma = 0.28;
run loadParams % run after setting parametersparameters =
6×1 table
Parameters
__________
periods 3
time 1
spot 100
strike 100
rate 0.03
sigma 0.28 opt_tod = optionToday(o_prm, call);
fprintf('Call today:\n\n')
disp(opt_tod)Call today:
13.4163put_tod = optionToday(o_prm, put);
fprintf('Put today:\n\n')
disp(put_tod)Put today:
10.4609asset_tr = assetTree(s_prm);
fprintf('Asset tree:\n\n')
disp(asset_tr)Asset tree:
100.0000 117.5458 138.1702 162.4133
0 85.0732 100.0000 117.5458
0 0 100.0000 117.5458
0 0 72.3745 85.0732
0 0 0 117.5458
0 0 0 85.0732
0 0 0 85.0732
0 0 0 61.5713
Trees are organized so that the element (i,j) in row i and column j branches into elements (2i,j+1) and (2i-1,j+1). Elements with i > 2^(j-1) are unused and ignored.
Call and put values plotted against a varying risk-free rate, strike price and spot price. Generated by ExamplePlot.m.