No BSD License  

Highlights from
Option Pricing Demo

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

blsstrval(SpotPrice, ...
function [StraddleValue, SpotMat, TimeMat] = blsstrval(SpotPrice, ...
     StrikePrice, RiskFreeRate, TimeExpiry, Volatility, SpotTimeRange)
%BLSSTRVAL Straddle value over a range of spot prices and times to expiry
%
%     [StraddleValue, SpotMat, TimeMat] = blsstrval(SpotPrice, 
%          StrikePrice, RiskFreeRate, TimeExpiry, Volatility, SpotTimeRange)
%
%This function computes the value surface of a straddle using the 
%     Black Scholes option pricing model given a range of spot prices and a
%     range of times to expiry. The range of spot prices and times to expiry
%     is specified as an input argument. A straddle consists of a long
%     position in both a call and a put option struck at the same price.
%
% Inputs: SpotPrice - Current price of the underlying asset
%         StrikePrice - Strike price of the straddle
%         RiskFreeRate - Risk free rate of return
%         TimeExpiry - Time to expiry of the option in months
%         Volatility - Volatility of the underlying asset
%         SpotTimeRange - Percentage range of spot prices and times to expiry
%              for which the option's value will be computed
%
%Outputs: StraddleValue - Values of the straddle over the range of spot prices
%              and times to expiry
%         SpotMat - Range of spot prices
%         TimeMat - Range of times to expiry
%
%         Outputs are NxM matrices where N is the number of times in the range
%         of times to expiry and M is the number of prices in the range of
%         spot prices. SpotMat and TimeMat are returned for plotting purposes.
%
%See Also: BLSCALLVAL, BLSPUTVAL, BLSBTYVAL

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

%-----------------------------------------------------------------------------
%
%                             PARSE INPUT ARGUMENTS
%
%-----------------------------------------------------------------------------

%Check the number of input arguments
if (nargin < 6)
     error('Too few input arguments!')
end

%Check that all inputs are scalars
InputSz = [size(SpotPrice) size(StrikePrice) size(RiskFreeRate) ...
          size(TimeExpiry) size(Volatility) size(SpotTimeRange)];
if (prod(InputSz) > 1)
     error('All input arguments must be scalar!')
end


%-----------------------------------------------------------------------------
%
%                                 COMPUTE OUTPUTS
%
%-----------------------------------------------------------------------------

%Create a range of spot prices around the input price, where the range is
%determined by SpotTimeRange and stepping by increments of $0.40
SpotRange = SpotPrice .* (1 - SpotTimeRange ./ 2) : 0.40 : SpotPrice ...
     .* ((1 + SpotTimeRange ./ 2));


%Create a range of times to expiry by starting at time zero and then stepping
%by increments of 2 days (remember times to expiry is in months)
TimeRange = 0 : (2 ./ 365) : (TimeExpiry ./ 12);


%Create NxM matrix inputs for the spot price and time to expiry where:
%
%     N = number of times in the rage of times to expiry
%     M = number of prices in the range of spot prices
%
[SpotMat, TimeMat] = meshgrid(SpotRange, TimeRange);


%Call the BLSPRICE function to value the call option
[CallValue, PutValue] = blsprice(SpotMat, StrikePrice, RiskFreeRate, TimeMat,...
     Volatility);

StraddleValue = CallValue + PutValue;

%end of BLSSTRVAL function



Contact us at files@mathworks.com