# LinearGaussian2F

Create `LinearGaussian2F` model object for `Cap`, `Floor`, `Swaption`, `Swap`, `FixedBond`, `FloatBond`, `FloatBondOption`, `FixedBondOption`, `OptionEmbeddedFixedBond`, or `OptionEmbeddedFloatBond` instrument

Since R2021b

## Description

Create and price a `Cap`, `Floor`, `Swaption`, `Swap`, `FloatBond`, `FloatBondOption`, `FixedBond`, `FixedBondOption`, `OptionEmbeddedFixedBond`, or `OptionEmbeddedFloatBond` instrument object with a `LinearGaussian2F` model using this workflow:

1. Use `finmodel` to specify a `LinearGaussian2F` model object for the `Cap`, `Floor`, `Swaption`, `Swap`, `FixedBond`, `FloatBond`, `FloatBondOption`, `FixedBondOption`, `OptionEmbeddedFixedBond`, or `OptionEmbeddedFloatBond` instrument object.

2. Use `finpricer` to specify an `IRMonteCarlo` pricing method for a `Cap`, `Floor`, `Swaption`, `Swap`, `FixedBond`, `FloatBond`, `FloatBondOption`, `FixedBondOption`, `OptionEmbeddedFixedBond`, or `OptionEmbeddedFloatBond` instrument object.

For more information on this workflow, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.

For more information on the available pricing methods for a `Cap`, `Floor`, `Swaption`, `Swap`, `FixedBond`, `FloatBond`, `FloatBondOption`, `FixedBondOption`, `OptionEmbeddedFixedBond`, or `OptionEmbeddedFloatBond` instrument, see Choose Instruments, Models, and Pricers.

## Creation

### Syntax

``LinearGaussian2FModelObj = finmodel(ModelType,Alpha1=alpha1_value,Sigma1=sigma1_value,Alpha2=alpha2_value,Sigma2=sigma2_value,Correlation=correlation_value)``

### Description

example

````LinearGaussian2FModelObj = finmodel(ModelType,Alpha1=alpha1_value,Sigma1=sigma1_value,Alpha2=alpha2_value,Sigma2=sigma2_value,Correlation=correlation_value)` creates a `LinearGaussian2F` model object by specifying `ModelType` and the required name-value arguments for `Alpha1`, `Sigma1`, `Alpha2`, `Sigma2` and `Correlation` to set properties using name-value pair arguments. For example, ```LinearGaussian2FModelObj = finmodel("LinearGaussian2F",Alpha1=0.07,Sigma1=0.01,Alpha2=0.5,Sigma2=0.006,Correlation=-0.7)``` creates a `LinearGaussian2F` model object.```

### Input Arguments

expand all

Model type, specified as a string with the value of `"LinearGaussian2F"` or a character vector with the value of `'LinearGaussian2F'`.

Data Types: `char` | `string`

Name-Value Arguments

Specify required 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.

Example: ```LinearGaussian2FModelObj = finmodel("LinearGaussian2F",Alpha1=0.07,Sigma1=0.01,Alpha2=0.5,Sigma2=0.006,Correlation=-0.7)```

Positive mean reversion value for first factor, specified as `Alpha1` and a scalar numeric or timetable.

Data Types: `double` | `timetable`

Positive volatility for first factor, specified as `Sigma1` and a scalar numeric or timetable.

Data Types: `double` | `timetable`

Positive mean reversion value for the second factor, specified as `Alpha2` and a scalar numeric or timetable.

Data Types: `double` | `timetable`

Positive volatility for second factor, specified as `Sigma2` and a scalar numeric or timetable.

Data Types: `double` | `timetable`

Scalar correlation of factors, specified as `Correlation` and a scalar numeric.

Data Types: `double`

## Properties

expand all

Positive mean reversion for first factor, returned as a scalar numeric or timetable.

Data Types: `double`

Positive volatility for first factor, returned as a scalar numeric value or timetable.

Data Types: `double`

Positive mean reversion value for second factor, returned as a scalar numeric or timetable.

Data Types: `double`

Positive volatility for second factor, returned as a scalar numeric value or timetable.

Data Types: `double` | `timetable`

Scalar correlation of factors, returned as a scalar numeric value.

Data Types: `double`

## Examples

collapse all

This example shows the workflow to price a `Cap` instrument when using a `LinearGaussian2F` model and an `IRMonteCarlo` pricing method.

Create `Cap` Instrument Object

Use `fininstrument` to create a `Cap` instrument object.

`CapOpt = fininstrument("Cap",Maturity=datetime(2022,9,15),Strike=0.01,Reset=2,Name="cap_option")`
```CapOpt = Cap with properties: Strike: 0.0100 Maturity: 15-Sep-2022 ResetOffset: 0 Reset: 2 Basis: 0 Principal: 100 ProjectionCurve: [0x0 ratecurve] DaycountAdjustedCashFlow: 0 BusinessDayConvention: "actual" Holidays: NaT Name: "cap_option" ```

Create `LinearGaussian2F` Model Object

Use `finmodel` to create a `LinearGaussian2F` model object.

`LinearGaussian2FModel = finmodel("LinearGaussian2F",Alpha1=0.07,Sigma1=0.01,Alpha2=0.5,Sigma2=0.006,Correlation=-0.7)`
```LinearGaussian2FModel = LinearGaussian2F with properties: Alpha1: 0.0700 Sigma1: 0.0100 Alpha2: 0.5000 Sigma2: 0.0060 Correlation: -0.7000 ```

Create `ratecurve` Object

Create a `ratecurve` object using `ratecurve`.

```Settle = datetime(2019,1,1); Type = 'zero'; ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]'; ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]'; ZeroDates = Settle + ZeroTimes; myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)```
```myRC = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 0 Dates: [10x1 datetime] Rates: [10x1 double] Settle: 01-Jan-2019 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous" ```

Create `IRMonteCarlo` Pricer Object

Use `finpricer` to create an `IRMonteCarlo` pricer object and use the `ratecurve` object for the `'DiscountCurve'` name-value pair argument.

`outPricer = finpricer("IRMonteCarlo",Model=LinearGaussian2FModel,DiscountCurve=myRC,SimulationDates=ZeroDates)`
```outPricer = G2PPMonteCarlo with properties: NumTrials: 1000 RandomNumbers: [] DiscountCurve: [1x1 ratecurve] SimulationDates: [01-Jul-2019 01-Jan-2020 01-Jan-2021 01-Jan-2022 01-Jan-2023 01-Jan-2024 01-Jan-2026 01-Jan-2029 01-Jan-2039 01-Jan-2049] Model: [1x1 finmodel.LinearGaussian2F] ```

Price `Cap` Instrument

Use `price` to compute the price and sensitivities for the `Cap` instrument.

`[Price,outPR] = price(outPricer,CapOpt,["all"])`
```Price = 1.2156 ```
```outPR = priceresult with properties: Results: [1x4 table] PricerData: [1x1 struct] ```
`outPR.Results`
```ans=1×4 table Price Delta Gamma Vega ______ ______ _____ ________________ 1.2156 131.37 11048 126.5 -157.38 ```