# lookbackbyls

Price European or American lookback options using Monte Carlo simulations

## Syntax

## Description

`[`

returns prices of lookback options using the Longstaff-Schwartz model for Monte Carlo
simulations. `Price`

,`Paths`

,`Times`

,`Z`

]
= lookbackbyls(`RateSpec`

,`StockSpec`

,`OptSpec`

,`Strike`

,`Settle`

,`ExerciseDates`

)`lookbackbyls`

computes prices of European and American
lookback options.

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

`lookbackbyls`

calculates values of fixed- and floating-strike
lookback options. To compute the value of a floating-strike lookback option,
`Strike`

must be specified as `NaN`

.

**Note**

Alternatively, you can use the `Lookback`

object to price
lookback options. For more information, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.

## Examples

### Compute the Price for a Floating Lookback Option Using Monte Carlo Simulation

Define the `RateSpec`

.

StartDates = datetime(2013,1,1); EndDates = datetime(2014,1,1); Rates = 0.042; Compounding = -1; RateSpec = intenvset('ValuationDate', StartDates, 'StartDates', StartDates,... 'EndDates', EndDates, 'Rates', Rates, 'Compounding', Compounding)

`RateSpec = `*struct with fields:*
FinObj: 'RateSpec'
Compounding: -1
Disc: 0.9589
Rates: 0.0420
EndTimes: 1
StartTimes: 0
EndDates: 735600
StartDates: 735235
ValuationDate: 735235
Basis: 0
EndMonthRule: 1

Define the `StockSpec`

.

AssetPrice = 50; Sigma = 0.36; StockSpec = stockspec(Sigma, AssetPrice)

`StockSpec = `*struct with fields:*
FinObj: 'StockSpec'
Sigma: 0.3600
AssetPrice: 50
DividendType: []
DividendAmounts: 0
ExDividendDates: []

Define the floating lookback option.

```
Settle = datetime(2013,1,1);
Maturity = datetime(2013,4,1);
OptSpec = 'put';
Strike = NaN;
```

Compute the price of the European floating lookback option.

Price = lookbackbyls(RateSpec, StockSpec, OptSpec, Strike, Settle, Maturity)

Price = 6.6471

### Compute the Price of a Fixed Lookback Option Using Monte Carlo Simulation

Define the `RateSpec`

.

StartDates = 'Jan-1-2013'; EndDates = 'Jan-1-2014'; Rates = 0.045; Compounding = -1; RateSpec = intenvset('ValuationDate', StartDates, 'StartDates', StartDates,... 'EndDates', EndDates, 'Rates', Rates,'Compounding', Compounding)

`RateSpec = `*struct with fields:*
FinObj: 'RateSpec'
Compounding: -1
Disc: 0.9560
Rates: 0.0450
EndTimes: 1
StartTimes: 0
EndDates: 735600
StartDates: 735235
ValuationDate: 735235
Basis: 0
EndMonthRule: 1

Define the `StockSpec`

.

AssetPrice = 102; Sigma = 0.45; StockSpec = stockspec(Sigma, AssetPrice)

`StockSpec = `*struct with fields:*
FinObj: 'StockSpec'
Sigma: 0.4500
AssetPrice: 102
DividendType: []
DividendAmounts: 0
ExDividendDates: []

Define the fixed lookback option.

Settle = 'Jan-1-2013'; Maturity = 'July-1-2013'; OptSpec = 'call'; Strike = 98;

Compute the price of the European fixed lookback option.

Price = lookbackbyls(RateSpec, StockSpec, OptSpec, Strike, Settle, Maturity)

Price = 30.2368

## Input Arguments

`StockSpec`

— Stock specification for underlying asset

structure

Stock specification for the underlying asset. For information on the stock
specification, see `stockspec`

.

`stockspec`

handles several types of
underlying assets. For example, for physical commodities the price is represented by
`StockSpec.Asset`

, the volatility is represented by
`StockSpec.Sigma`

, and the convenience yield is represented by
`StockSpec.DividendAmounts`

.

**Data Types: **`struct`

`OptSpec`

— Definition of option

character vector with values `'call'`

or
`'put'`

| cell array of character vectors

Definition of option as `'call'`

or `'put'`

,
specified as a `NINST`

-by-`1`

cell array of character
vectors.

**Data Types: **`char`

| `cell`

`Strike`

— Option strike price values

integer | vector of integers

Option strike price values, specified as an integer using a
`NINST`

-by-`1`

vector of strike price values.

**Data Types: **`single`

| `double`

`Settle`

— Settlement or trade date

datetime array | string array | date character vector

Settlement or trade date for the lookback option, specified as a
`NINST`

-by-`1`

vector using a datetime array, string
array, or date character vectors.

To support existing code, `lookbackbyls`

also
accepts serial date numbers as inputs, but they are not recommended.

`ExerciseDates`

— Exercise callable or puttable dates for European or American options

datetime array | string array | date character vector

Exercise callable or puttable dates for European or American options, specified as a datetime array, string array, or date character vectors as follows:

European option —

`NINST`

-by-`1`

vector of exercise dates. For a European option, there is only one exercise date which is the option expiry date.American option —

`NINST`

-by-`2`

vector of exercise date boundaries. For each instrument, the option is exercised on any coupon date between or including the pair of dates on that row. If only one non-`NaN`

date is listed, or if`ExerciseDates`

is a`NINST`

-by-`1`

vector of dates, the option is exercised between`Settle`

and the single listed exercise date.

To support existing code, `lookbackbyls`

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 =
lookbackbyls(RateSpec,StockSpec1,StockSpec2,Settle,Maturity,OptSpec,Strike,Corr,'AmericanOpt',1)
```

`AmericanOpt`

— Option type

`0`

European (default) | scalar with value `[0,1]`

Option type, specified as the comma-separated pair consisting of
`'AmericanOpt'`

and an integer scalar flag with these values:

`0`

— European`1`

— American

**Note**

For American options, the Longstaff-Schwartz least squares method is used to calculate the early exercise premium. For more information on the least squares method, see https://people.math.ethz.ch/%7Ehjfurrer/teaching/LongstaffSchwartzAmericanOptionsLeastSquareMonteCarlo.pdf.

**Data Types: **`double`

`NumTrials`

— Scalar number of independent sample paths

`1000`

(default) | nonnegative scalar integer

Scalar number of independent sample paths (simulation trials), specified as the
comma-separated pair consisting of `'NumTrials'`

and a nonnegative
integer.

**Data Types: **`double`

`NumPeriods`

— Scalar number of simulation periods per trial

`100`

(default) | nonnegative scalar integer

Scalar number of simulation periods per trial, specified as the comma-separated
pair consisting of `'NumPeriods'`

and a nonnegative integer.
`NumPeriods`

is considered only when pricing European lookback
options. For American lookback options, `NumPeriods`

is equal to the
number of exercise days during the life of the option.

**Data Types: **`double`

`Z`

— Time series array of dependent random variates

vector

Time series array of dependent random variates, specified as the comma-separated
pair consisting of `'Z'`

and a
`NumPeriods`

-by-`1`

-by-`NumTrials`

3-D array. The `Z`

value generates the Brownian motion vector (that
is, Wiener processes) that drives the simulation.

**Data Types: **`double`

`Antithetic`

— Indicator for antithetic sampling

`false`

(default) | scalar logical flag with value of `true`

or
`false`

Indicator for antithetic sampling, specified as the comma-separated pair
consisting of `'Antithetic'`

and a value of `true`

or `false`

.

**Data Types: **`logical`

## Output Arguments

`Price`

— Expected price of lookback option

scalar

Expected price of the lookback option, returned as a
`1`

-by-`1`

scalar.

`Paths`

— Simulated paths of correlated state variables

vector

Simulated paths of correlated state variables, returned as a ```
NumPeriods +
1
```

-by-`1`

-by-`NumTrials`

3-D time series
array. Each row of `Paths`

is the transpose of the state vector
*X*(*t*) at time *t* for a given
trial.

`Times`

— Observation times associated with simulated paths

vector

Observation times associated with simulated paths, returned as a ```
NumPeriods
+ 1
```

-by-`1`

column vector of observation times associated
with the simulated paths. Each element of `Times`

is associated with
the corresponding row of `Paths`

.

`Z`

— Time series array of dependent random variates

vector

Time series array of dependent random variates, returned as a
`NumPeriods`

-by-`1`

-by-`NumTrials`

3-D array when `Z`

is specified as an input argument. If the
`Z`

input argument is not specified, then the `Z`

output argument contains the random variates generated internally.

## More About

### Lookback Option

A *lookback option* is a path-dependent option
based on the maximum or minimum value the underlying asset achieves during the entire life
of the option.

Financial Instruments Toolbox™ software supports two types of lookback options: fixed and floating. Fixed lookback options have a specified strike price, while floating lookback options have a strike price determined by the asset path. For more information, see Lookback Option.

## References

[1] Hull, J. C. *Options, Futures, and Other Derivatives* 5th
Edition. Englewood Cliffs, NJ: Prentice Hall, 2002.

## Version History

**Introduced in R2014a**

### R2022b: Serial date numbers not recommended

Although `lookbackbyls`

supports serial date numbers,
`datetime`

values are recommended instead. The
`datetime`

data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.

To convert serial date numbers or text to `datetime`

values, use the `datetime`

function. For example:

t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)

y = 2021

There are no plans to remove support for serial date number inputs.

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)