Main Content

optpricebysim

Price option given simulated underlying values

Description

example

Price = optpricebysim(RateSpec,SimulatedPrices,Times,OptSpec,Strike,ExerciseTimes) calculates the price of European, American, and Berumdan call/put options based on risk-neutral simulation of the underlying asset. For American and Bermudan options, the Longstaff-Schwartz least squares method calculates the early exercise premium.

example

Price = optpricebysim(___,Name,Value) adds optional name-value pair arguments.

Examples

collapse all

Define the option.

S0 = 100; % Initial price of underlying asset
Sigma = .2; % Volatility of underlying asset
Strike = 110; % Strike
OptSpec = 'call'; % Call option
Settle = datetime(2013,1,1); % Settlement date of option
Maturity = datetime(2014,1,1); % Maturity date of option
r = .05; % Risk-free rate (annual, continuous compounding)
Compounding = -1; % Continuous compounding
Basis = 0; % Act/Act day count convention
T = yearfrac(Settle, Maturity, Basis); % Time to expiration in years

Set up the gbm object and run the Monte Carlo simulation based on Geometric Brownian Motion (GBM) using the simBySolution method from Financial Toolbox™.

NTRIALS = 1000;
NPERIODS = daysact(Settle, Maturity);
dt = T/NPERIODS;
OptionGBM = gbm(r, Sigma, 'StartState', S0);
[Paths, Times, Z] = simBySolution(OptionGBM, NPERIODS, ...
'NTRIALS',NTRIALS, 'DeltaTime',dt,'Antithetic',true);

Create the interest-rate term structure to define RateSpec.

RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, ...
           'EndDates', Maturity, 'Rate', r, 'Compounding', Compounding, ...
           'Basis', Basis)
RateSpec = struct with fields:
           FinObj: 'RateSpec'
      Compounding: -1
             Disc: 0.9512
            Rates: 0.0500
         EndTimes: 1
       StartTimes: 0
         EndDates: 735600
       StartDates: 735235
    ValuationDate: 735235
            Basis: 0
     EndMonthRule: 1

Price an American option.

SimulatedPrices = squeeze(Paths);
OptPrice = optpricebysim(RateSpec, SimulatedPrices, Times, OptSpec, ...
           Strike, T, 'AmericanOpt', 1)
OptPrice = 5.8172

Define the option.

S0 = 100; % Initial price of underlying asset
Sigma = .2; % Volatility of underlying asset
Strike = 110; % Strike
OptSpec = 'call'; % Call option
Settle = datetime(2013,1,1); % Settlement date of option
Maturity = datetime(2014,1,1); % Maturity date of option
r = .05; % Risk-free rate (annual, continuous compounding)
Compounding = -1; % Continuous compounding
Basis = 0; % Act/Act day count convention
T = yearfrac(Settle, Maturity, Basis); % Time to expiration in years

Set up the gbm object and run the Monte Carlo simulation based on Geometric Brownian Motion (GBM) using the simBySolution method from Financial Toolbox™.

NTRIALS = 1000;
NPERIODS = daysact(Settle, Maturity);
dt = T/NPERIODS;
OptionGBM = gbm(r, Sigma, 'StartState', S0);
[Paths, Times, Z] = simBySolution(OptionGBM, NPERIODS, ...
'NTRIALS',NTRIALS, 'DeltaTime',dt,'Antithetic',true);

Create the interest-rate term structure to define RateSpec.

RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, ...
           'EndDates', Maturity, 'Rate', r, 'Compounding', Compounding, ...
           'Basis', Basis)
RateSpec = struct with fields:
           FinObj: 'RateSpec'
      Compounding: -1
             Disc: 0.9512
            Rates: 0.0500
         EndTimes: 1
       StartTimes: 0
         EndDates: 735600
       StartDates: 735235
    ValuationDate: 735235
            Basis: 0
     EndMonthRule: 1

Price an American Asian option (arithmetic mean) by finding the average price over periods.

AvgPrices = zeros(NPERIODS+1, NTRIALS);
    for i = 1:NPERIODS+1
        AvgPrices(i,:) = mean(squeeze(Paths(1:i,:,:)));
    end
    AsianPrice = optpricebysim(RateSpec, AvgPrices, Times, OptSpec, ...
        Strike, T, 'AmericanOpt', 1)
AsianPrice = 1.8221

Define the option.

S0 = 100; % Initial price of underlying asset
Sigma = .2; % Volatility of underlying asset
Strike = 110; % Strike
OptSpec = 'call'; % Call option
Settle = datetime(2013,1,1); % Settlement date of option
Maturity = datetime(2014,1,1); % Maturity date of option
r = .05; % Risk-free rate (annual, continuous compounding)
Compounding = -1; % Continuous compounding
Basis = 0; % Act/Act day count convention
T = yearfrac(Settle, Maturity, Basis); % Time to expiration in years

Set up the gbm object and run the Monte Carlo simulation based on Geometric Brownian Motion (GBM) using the simBySolution method from Financial Toolbox™.

NTRIALS = 1000;
NPERIODS = daysact(Settle, Maturity);
dt = T/NPERIODS;
OptionGBM = gbm(r, Sigma, 'StartState', S0);
[Paths, Times, Z] = simBySolution(OptionGBM, NPERIODS, ...
'NTRIALS',NTRIALS, 'DeltaTime',dt,'Antithetic',true);

Create the interest-rate term structure to define RateSpec.

RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, ...
           'EndDates', Maturity, 'Rate', r, 'Compounding', Compounding, ...
           'Basis', Basis)
RateSpec = struct with fields:
           FinObj: 'RateSpec'
      Compounding: -1
             Disc: 0.9512
            Rates: 0.0500
         EndTimes: 1
       StartTimes: 0
         EndDates: 735600
       StartDates: 735235
    ValuationDate: 735235
            Basis: 0
     EndMonthRule: 1

Price an American lookback option by finding the maximum price over periods.

MaxPrices = zeros(NPERIODS+1, NTRIALS);
    LastPrice = squeeze(Paths(1,:,:))';
    for i = 1:NPERIODS+1;
        MaxPrices(i,:) = max([LastPrice; Paths(i,:)]);
        LastPrice = MaxPrices(i,:);
    end
    LookbackPrice = optpricebysim(RateSpec, MaxPrices, Times, OptSpec, ...
        Strike, T, 'AmericanOpt', 1)
LookbackPrice = 10.4410

Define the option.

S0 = 80; % Initial price of underlying asset
Sigma = .3; % Volatility of underlying asset
Strike = 75; % Strike
OptSpec = 'put'; % Put option
Settle = datetime(2013,1,1); % Settlement date of option
Maturity = datetime(2014,1,1); % Maturity date of option
ExerciseDates = [datetime(2013,1,1) , datetime(2014,1,1)]; % Exercise dates of option
r = .05; % Risk-free rate (annual, continuous compounding)
Compounding = -1; % Continuous compounding
Basis = 0; % Act/Act day count convention
T = yearfrac(Settle, Maturity, Basis); % Time to expiration in years
ExerciseTimes = yearfrac(Settle, ExerciseDates, Basis); % Exercise times

Set up the gbm object and run the Monte Carlo simulation based on Geometric Brownian Motion (GBM) using the simBySolution method from Financial Toolbox™.

NTRIALS = 1000;
NPERIODS = daysact(Settle, Maturity);
dt = T/NPERIODS;
OptionGBM = gbm(r, Sigma, 'StartState', S0);
[Paths, Times, Z] = simBySolution(OptionGBM, NPERIODS, ...
'NTRIALS',NTRIALS, 'DeltaTime',dt,'Antithetic',true);

Create the interest-rate term structure to define RateSpec.

RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, ...
           'EndDates', Maturity, 'Rate', r, 'Compounding', Compounding, ...
           'Basis', Basis)
RateSpec = struct with fields:
           FinObj: 'RateSpec'
      Compounding: -1
             Disc: 0.9512
            Rates: 0.0500
         EndTimes: 1
       StartTimes: 0
         EndDates: 735600
       StartDates: 735235
    ValuationDate: 735235
            Basis: 0
     EndMonthRule: 1

Price the Bermudan option.

SimulatedPrices = squeeze(Paths);
BermudanPrice = optpricebysim(RateSpec, SimulatedPrices, Times, ...
OptSpec, Strike, ExerciseTimes)
BermudanPrice = 4.9889

Define the option.

S1 = 110; % Price of first underlying asset
S2 = 100; % Price of second underlying asset
Sigma1 = .1;  % Volatility of first underlying asset
Sigma2 = .15; % Volatility of second underlying asset
Strike = 15; % Strike
Rho = .3; % Correlation between underlyings
OptSpec = 'put'; % Put option
Settle = datetime(2013,1,1); % Settlement date of option
Maturity = datetime(2014,1,1); % Maturity date of option
r = .05; % Risk-free rate (annual, continuous compounding)
Compounding = -1; % Continuous compounding
Basis = 0; % Act/Act day count convention
T = yearfrac(Settle, Maturity, Basis); % Time to expiration in years

Set up the gbm object and run the Monte Carlo simulation based on Geometric Brownian Motion (GBM) using the simBySolution method from Financial Toolbox™.

NTRIALS = 1000;
NPERIODS = daysact(Settle, Maturity);
dt = T/NPERIODS;
SpreadGBM = gbm(r*eye(2), diag([Sigma1;Sigma2]),'Correlation',...
[1 Rho;Rho 1],'StartState',[S1;S2]);
[Paths, Times, Z] = simBySolution(SpreadGBM, NPERIODS,'NTRIALS',NTRIALS,...
'DeltaTime',dt,'Antithetic',true);

Create the interest-rate term structure to define RateSpec.

RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, ...
           'EndDates', Maturity, 'Rate', r, 'Compounding', Compounding, ...
           'Basis', Basis)
RateSpec = struct with fields:
           FinObj: 'RateSpec'
      Compounding: -1
             Disc: 0.9512
            Rates: 0.0500
         EndTimes: 1
       StartTimes: 0
         EndDates: 735600
       StartDates: 735235
    ValuationDate: 735235
            Basis: 0
     EndMonthRule: 1

Price the American spread option.

Spread = squeeze(Paths(:,1,:) - Paths(:,2,:));
SpreadPrice = optpricebysim(RateSpec, Spread, Times, OptSpec, Strike, ...
T, 'AmericanOpt', 1)
SpreadPrice = 9.0007

Input Arguments

collapse all

Interest-rate term structure of risk-free rates (annualized and continuously compounded), specified by the RateSpec obtained from intenvset. The valuation date must be at the settlement date of the option, and the day-count basis and end-of-month rule must be the same as those used to calculate the Times input. For information on the interest-rate specification, see intenvset.

Data Types: struct

Simulated prices, specified using a (NumPeriods + 1)-by-NumTrials matrix of risk-neutral simulated prices. The first element of SimulatedPrices is the initial value at time 0.

Data Types: double

Annual time factors associated with simulated prices, specified using a (NumPeriods + 1)-by-1 column vector. Each element of Times is associated with the corresponding row of SimulatedPrices. The first element of Times must be 0 (current time).

Data Types: double

Definition of option as 'call' or 'put', specified as a character vector.

Data Types: char

Option strike price values, specified as a scalar value Strike price. Strike for Bermudan options can be specified as a 1-by-NSTRIKES vector or a function handle that returns the value of the strike given the time of the strike.

Data Types: double | function_handle

Exercise time for the option, specified as a datetime array, string array, or date character vectors, as follows:

  • For a European or Bermudan option, ExerciseTimes is a 1-by-1 (European) or 1-by-NSTRIKES (Bermudan) vector of exercise times. For a European option, there is only one ExerciseTimes on the option expiry date.

  • For an American option, ExerciseTimes is a 1-by-2 vector of exercise time boundaries. The option exercises on any date between, or including, the pair of times on that row. If ExerciseTimes is 1-by-1, the option exercises between time 0 and the single listed ExerciseTimes.

To support existing code, optpricebysim also accepts serial date numbers as inputs, but they are not recommended.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: Price = optpricebysim(RateSpec,Prices,Times,OptSpec,Settle,Strike,ExerciseTimes,'AmericanOpt',1)

Option type, specified as the comma-separated pair consisting of 'AmericanOpt' and an integer scalar flag with values:

  • 0 — European or Bermudan

  • 1 — American

For American options, the Longstaff-Schwartz least squares method calculates the early exercise premium.

Data Types: double

Output Arguments

collapse all

Price of the option, returned as a scalar value.

Version History

Introduced in R2014a

expand all