# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

# spreadbyls

Price European or American spread options using Monte Carlo simulations

## Syntax

``Price = spreadbyls(RateSpec,StockSpec1,StockSpec2,Settle,Maturity,OptSpec,Strike,Corr)``
``Price = spreadbyls(___,Name,Value)``
``````[Price,Paths,Times,Z] = spreadbyls(RateSpec,StockSpec1,StockSpec2,Settle,Maturity,OptSpec,Strike,Corr)``````
``````[Price,Paths,Times,Z] = spreadbyls(___,Name,Value)``````

## Description

example

````Price = spreadbyls(RateSpec,StockSpec1,StockSpec2,Settle,Maturity,OptSpec,Strike,Corr)` returns the price of a European or American call or put spread option using Monte Carlo simulations.For American options, the Longstaff-Schwartz least squares method is used to calculate the early exercise premium.```
````Price = spreadbyls(___,Name,Value)` returns the price of a European or American call or put spread option using Monte Carlo simulations using optional name-value pair arguments.```
``````[Price,Paths,Times,Z] = spreadbyls(RateSpec,StockSpec1,StockSpec2,Settle,Maturity,OptSpec,Strike,Corr)``` returns the `Price`, `Paths`, `Times`, and `Z` of a European or American call or put spread option using Monte Carlo simulations.```
``````[Price,Paths,Times,Z] = spreadbyls(___,Name,Value)``` returns the `Price`, `Paths`, `Times`, and `Z` of a European or American call or put spread option using Monte Carlo simulations using optional name-value pair arguments.```

## Examples

collapse all

Define the spread option dates.

```Settle = '01-Jan-2012'; Maturity = '01-April-2012';```

Define asset 1. Price and volatility of RBOB gasoline

``` Price1gallon = 2.85; % \$/gallon Price1 = Price1gallon * 42; % \$/barrel Vol1 = 0.29;```

Define asset 2. Price and volatility of WTI crude oil

``` Price2 = 93.20; % \$/barrel Vol2 = 0.36;```

Define the correlation between the underlying asset prices of asset 1 and asset 2.

`Corr = 0.42;`

Define the spread option.

```OptSpec = 'call'; Strike = 20;```

Define the `RateSpec`.

```rates = 0.05; Compounding = -1; Basis = 1; RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, ... 'EndDates', Maturity, 'Rates', rates, ... 'Compounding', Compounding, 'Basis', Basis)```
```RateSpec = struct with fields: FinObj: 'RateSpec' Compounding: -1 Disc: 0.9876 Rates: 0.0500 EndTimes: 0.2500 StartTimes: 0 EndDates: 734960 StartDates: 734869 ValuationDate: 734869 Basis: 1 EndMonthRule: 1 ```

Define the `StockSpec` for the two assets.

`StockSpec1 = stockspec(Vol1, Price1)`
```StockSpec1 = struct with fields: FinObj: 'StockSpec' Sigma: 0.2900 AssetPrice: 119.7000 DividendType: [] DividendAmounts: 0 ExDividendDates: [] ```
`StockSpec2 = stockspec(Vol2, Price2)`
```StockSpec2 = struct with fields: FinObj: 'StockSpec' Sigma: 0.3600 AssetPrice: 93.2000 DividendType: [] DividendAmounts: 0 ExDividendDates: [] ```

Compute the spread option price using Monte Carlo simulation based on the Longstaff-Schwartz model.

```Price = spreadbyls(RateSpec, StockSpec1, StockSpec2, Settle, ... Maturity, OptSpec, Strike, Corr)```
```Price = 11.0799 ```

## Input Arguments

collapse all

Interest-rate term structure (annualized and continuously compounded), specified by the `RateSpec` obtained from `intenvset`. For information on the interest-rate specification, see `intenvset`.

Data Types: `struct`

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

`stockspec` can handle other 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`

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

`stockspec` can handle other 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`

Settlement date for the spread option specified, as a date character vector or nonnegative scalar integer.

Data Types: `char` | `double`

Maturity date for spread option, specified as a date character vector or a nonnegative scalar integer.

Data Types: `char` | `double`

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

Data Types: `char`

Option strike price value, specified, as a nonnegative scalar integer.

Data Types: `single` | `double`

Correlation between underlying asset prices, specified as a scalar integer.

Data Types: `single` | `double`

### Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside single quotes (`' '`). You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: `Price = spreadbyls(RateSpec,StockSpec1,StockSpec2,Settle,Maturity,OptSpec,Strike,Corr,'AmericanOpt',1)`

collapse all

Option type, specified as an integer scalar flag with value:

• `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: `single` | `double`

Scalar number of independent sample paths (simulation trials), specified as a nonnegative integer.

Data Types: `single` | `double`

Scalar number of simulation periods per trial, specified as a nonnegative integer. `NumPeriods` is considered only when pricing European basket options. For American spread options, `NumPeriod` is equal to the number of exercise days during the life of the option.

Data Types: `single` | `double`

Time series array of dependent random variates specified as a `NumPeriods`-by-`2`-by-`NumTrials` 3-D array. The `Z` value generates the Brownian motion vector (that is, Wiener processes) that drives the simulation.

Data Types: `single` | `double`

Indicator for antithetic sampling, specified with a value of `true` or `false`.

Data Types: `logical`

## Output Arguments

collapse all

Expected price of the spread option, returned as a `1`-by-`1` scalar.

Simulated paths of correlated state variables, returned as a ```NumPeriods + 1```-by-`2`-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.

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`.

Time series array of dependent random variates, returned as a `NumPeriods`-by-`2`-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.

## References

[1] Carmona, R., Durrleman, V. “Pricing and Hedging Spread Options.” SIAM Review. Vol. 45, No. 4, pp. 627–685, Society for Industrial and Applied Mathematics, 2003.

## See Also

### External Websites

#### Introduced in R2013b

Was this topic helpful?

#### Financial Risk Management: Improving Model Governance with MATLAB

Download the white paper