No BSD License  

Highlights from
Option Pricing Demo

image thumbnail
from Option Pricing Demo by Kas Sharma
Demo of an option pricing tool

blsapp2()
function blsapp2()
%BLSAPP2 Option Pricing Tool # 2
%
%This application prices individual calls, puts, straddles, and butterflies
%     using the Black Scholes option pricing model.

%Author: C. Bassignani, 10-08-98

%-----------------------------------------------------------------------------
%Build the main GUI panel

%Set the size parameters and starting points for the main GUI panel
HorizStart = 200;
VertStart = 200;
TotalWidth = 400;
TotalHeight = 275;

%Main panel
h0 = figure('Numbertitle', 'off', ...
     'Menubar', 'none', ...
     'Name', 'Option Pricing Tool', ...
     'Position',[HorizStart VertStart TotalWidth TotalHeight], ...
     'DeleteFcn', 'blsmaincall2 closeall');

%-----------------------------------------------------------------------------
%Define a structure in the UserData of the main GUI to hold application
%variables
set(h0, 'UserData', 'DataStruct');


%-----------------------------------------------------------------------------
%Build the text labels and edit fields for the input arguments

%Set the vertical position from which to start drawing the text labels and
%edit fields (as measured from the bottom of the GUI panel)
VertStart = 220;

%Set the left margin for drawing the text labels
LeftEdge = 25;

%Set the height and width for the text labels and fields
TextWidth = 120;
TextHeight = 25;
EditHeight = 25;
EditWidth = 75;

%Spot price
h1 = uicontrol('Parent', h0, ...
     'Style', 'text', ...
     'FontSize', 10, ...
     'FontWeight', 'bold', ...
     'Position', [LeftEdge VertStart TextWidth TextHeight], ...
     'String', 'Spot Price');

h1 = uicontrol('Parent', h0, ...
     'BackgroundColor', 'white', ...
     'Style', 'edit', ...
     'Position', [LeftEdge+TextWidth+5 VertStart EditWidth EditHeight], ...
     'Tag', 'EditSpotPrice', ...
     'String', '98');

%Strike price
h1 = uicontrol('Parent', h0, ...
     'Style', 'text', ...
     'FontSize', 10, ...
     'FontWeight', 'bold', ...
     'Position', [LeftEdge VertStart-35 TextWidth TextHeight], ...
     'String', 'Strike Price');

h1 = uicontrol('Parent', h0, ...
     'BackgroundColor', 'white', ...
     'Style', 'edit', ...
     'Position', [LeftEdge+TextWidth+5 VertStart-35 EditWidth EditHeight], ...
     'Tag', 'EditStrikePrice', ...
     'String', '98');

%Risk free rate
h1 = uicontrol('Parent', h0, ...
     'Style', 'text', ...
     'FontSize', 10, ...
     'FontWeight', 'bold', ...
     'Position', [LeftEdge VertStart-70 TextWidth TextHeight], ...
     'String', 'Risk Free Rate');

h1 = uicontrol('Parent', h0, ...
     'BackgroundColor', 'white', ...
     'Style', 'edit', ...
     'Position', [LeftEdge+TextWidth+5 VertStart-70 EditWidth EditHeight], ...
     'Tag', 'EditRiskFreeRate', ...
     'String', '0.07');

%Time to Expiry
h1 = uicontrol('Parent', h0, ...
     'Style', 'text', ...
     'FontSize', 10, ...
     'FontWeight', 'bold', ...
     'Position', [LeftEdge VertStart-105 TextWidth TextHeight], ...
     'String', 'Months to Expiry');

h1 = uicontrol('Parent', h0, ...
     'BackgroundColor', 'white', ...
     'Style', 'edit', ...
     'Position', [LeftEdge+TextWidth+5 VertStart-105 EditWidth EditHeight], ...
     'Tag', 'EditTimeExpiry', ...
     'String', '2');

%Volatility
h1 = uicontrol('Parent', h0, ...
     'Style', 'text', ...
     'FontSize', 10, ...
     'FontWeight', 'bold', ...
     'Position', [LeftEdge VertStart-140 TextWidth TextHeight], ...
     'String', 'Volatility');

h1 = uicontrol('Parent', h0, ...
     'BackgroundColor', 'white', ...
     'Style', 'edit', ...
     'Position', [LeftEdge+TextWidth+5 VertStart-140 EditWidth EditHeight], ...
     'Tag', 'EditVolatility', ...
     'String', '0.20');


%-----------------------------------------------------------------------------
%Build the radio buttons for selecting the type of option

%Set the variable to position and size the radion buttons
RadioEdge = LeftEdge + (TotalWidth .* 0.55);
RadioWidth = 120;
RadioHeight = 25;

%Call option
h1 = uicontrol('Parent', h0, ...
     'Style', 'radio', ...
     'Position', [RadioEdge VertStart RadioWidth RadioHeight], ...
     'String', 'Call Option', ...
     'FontSize', 10, ...
     'FontWeight', 'bold', ...
     'Tag', 'RadioButton', ...
     'Callback', 'blsmaincall2 radiocall');

%Put option
h1 = uicontrol('Parent', h0, ...
     'Style', 'radio', ...
     'Position', [RadioEdge VertStart-35 RadioWidth RadioHeight], ...
     'String', 'Put Option', ...
     'FontSize', 10, ...
     'FontWeight', 'bold', ...
     'Tag', 'RadioButton', ...
     'Callback', 'blsmaincall2 radioput');

%Straddle
h1 = uicontrol('Parent', h0, ...
     'Style', 'radio', ...
     'Position', [RadioEdge VertStart-70 RadioWidth RadioHeight], ...
     'String', 'Straddle', ...
     'FontSize', 10, ...
     'FontWeight', 'bold', ...
     'Tag', 'RadioButton', ...
     'Callback', 'blsmaincall2 radiostraddle');

%Butterfly
h1 = uicontrol('Parent', h0, ...
     'Style', 'radio', ...
     'Position', [RadioEdge VertStart-105 RadioWidth RadioHeight], ...
     'String', '10% Butterfly', ...
     'FontSize', 10, ...
     'FontWeight', 'bold', ...
     'Tag', 'RadioButton', ...
     'Callback', 'blsmaincall2 radiobutterfly');


%-----------------------------------------------------------------------------
%Build the main buttons for the GUI

ButtonWidth = 100;
ButtonHeight = 25;

h1 = uicontrol('Parent', h0, ...
     'Style', 'pushbutton', ...
     'Position', [RadioEdge VertStart-180 ButtonWidth ButtonHeight], ...
     'String', 'Calculate', ...
     'FontSize', 12, ...
     'FontWeight', 'bold', ...
     'Tag', 'ButtonCalculate', ...
     'Callback', 'blsmaincall2 calculate');

%end of BLSAPP2 GUI

Contact us at files@mathworks.com