# Cap

`Cap` instrument object

## Description

Create and price a `Cap` instrument object using this workflow:

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

2. Use `finmodel` to specify a `HullWhite`, `BlackKarasinski`, `Black`, or `Normal` model for the `Cap` instrument.

3. Use `finpricer` to specify a `Normal`, `Black`, `HullWhite`, or `IRTree` pricing method for the `Cap` instrument.

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 models and pricing methods for a `Cap` instrument, see Choose Instruments, Models, and Pricers.

## Creation

### Syntax

``CapOpt = fininstrument(InstrumentType,'Strike',strike_value,'Maturity',maturity_date)``
``CapOpt = fininstrument(___,Name,Value)``

### Description

example

````CapOpt = fininstrument(InstrumentType,'Strike',strike_value,'Maturity',maturity_date)` creates a `Cap` object by specifying `InstrumentType` and sets the properties for the required name-value pair arguments `Strike` and `Maturity`.The `Cap` instrument supports vanilla and amortizing caps.```

example

````CapOpt = fininstrument(___,Name,Value)` sets optional properties using additional name-value pairs in addition to the required arguments in the previous syntax. For example, ```CapOpt = fininstrument("Cap",'Strike',0.65,'Maturity',datetime(2019,1,30),'Reset',4,'Principal',100,'ResetOffset',1,'Basis',1,'DaycountAdjustedCashFlow',true,'BusinessDayConvention',"follow",'ProjectionCurve',ratecurve_object,'Name',"cap_option")``` creates a `Cap` option with a strike of 0.65. You can specify multiple name-value pair arguments.```

### Input Arguments

expand all

Instrument type, specified as a string with the value `"Cap"` or a character vector with the value `'Cap'`.

Data Types: `char` | `string`

`Cap` Name-Value Pair Arguments

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

Example: ```CapOpt = fininstrument("Cap",'Strike',0.65,'Maturity',datetime(2019,1,30),'Reset',4,'Principal',100,'ResetOffset',1,'Basis',1,'DaycountAdjustedCashFlow',true,'BusinessDayConvention',"follow",'ProjectionCurve',ratecurve_object,'Name',"cap_option")```
Required `Cap` Name-Value Pair Arguments

expand all

Cap strike price, specified as the comma-separated pair consisting of `'Strike'` and a scalar nonnegative decimal value.

Data Types: `double`

Cap maturity date, specified as the comma-separated pair consisting of `'ExerciseDate'` and a scalar datetime, serial date number, date character vector, or date string.

If you use a date character vector or date string, the format must be recognizable by `datetime` because the `Maturity` property is stored as a datetime.

Data Types: `double` | `char` | `string` | `datetime`

Optional `Cap` Name-Value Pair Arguments

expand all

Reset frequency payments per year, specified as the comma-separated pair consisting of `'Reset'` and a scalar numeric.

Data Types: `double`

Day-count basis, specified as the comma-separated pair consisting of `'Basis'` and a scalar integer with one of the following values:

• 0 — actual/actual

• 1 — 30/360 (SIA)

• 2 — actual/360

• 3 — actual/365

• 4 — 30/360 (PSA)

• 5 — 30/360 (ISDA)

• 6 — 30/360 (European)

• 7 — actual/365 (Japanese)

• 8 — actual/actual (ICMA)

• 9 — actual/360 (ICMA)

• 10 — actual/365 (ICMA)

• 11 — 30/360E (ICMA)

• 12 — actual/365 (ISDA)

• 13 — BUS/252

Data Types: `double`

Principal amount or principal value schedule, specified as the comma-separated pair consisting of `'Principal'` and a scalar numeric or timetable.

`Principal` accepts a `timetable`, where the first column is dates and the second column is its associated principal value. The date indicates the last day that the principal value is valid.

Data Types: `double` | `timetable`

Lag in rate setting, specified as the comma-separated pair consisting of `'ResetOffset'` and a scalar numeric.

Data Types: `double`

Flag to adjust cash flows based on the actual period day count, specified as the comma-separated pair consisting of `'DaycountAdjustedCashFlow'` and a scalar with a value of `true` or `false`.

Data Types: `logical`

Business day conventions, specified as the comma-separated pair consisting of `'BusinessDayConvention'` and a scalar string or character vector for a business day convention. The selection for business day convention determines how nonbusiness days are treated. Nonbusiness days are defined as weekends plus any other date that businesses are not open (for example, statutory holidays). Values are:

• `"actual"` — Nonbusiness days are effectively ignored. Cash flows that fall on non-business days are assumed to be distributed on the actual date.

• `"follow"` — Cash flows that fall on a nonbusiness day are assumed to be distributed on the following business day.

• `"modifiedfollow"` — Cash flows that fall on a nonbusiness day are assumed to be distributed on the following business day. However if the following business day is in a different month, the previous business day is adopted instead.

• `"previous"` — Cash flows that fall on a nonbusiness day are assumed to be distributed on the previous business day.

• `"modifiedprevious"` — Cash flows that fall on a nonbusiness day are assumed to be distributed on the previous business day. However if the previous business day is in a different month, the following business day is adopted instead.

Data Types: `char` | `string`

Holidays used in computing business days, specified as the comma-separated pair consisting of `'Holidays'` and dates using datetimes, serial date numbers, cell array of date character vectors, or date string array. For example:

```H = holidays(datetime('today'),datetime(2025,12,15)); CapOpt = fininstrument("Cap",'Strike',100,'Maturity',datetime(2025,12,15),'Holidays',H)```

Data Types: `double` | `cell` | `datetime` | `string`

Rate curve used in projecting the future cash flows, specified as the comma-separated pair consisting of `'ProjectionCurve'` and a `ratecurve` object. This object must be created using `ratecurve`. Use this optional input if the forward curve is different from the discount curve.

Data Types: `object`

User-defined name for the instrument, specified as the comma-separated pair consisting of `'Name'` and a scalar string or character vector.

Data Types: `char` | `string`

## Properties

expand all

Option strike price value, returned as a scalar nonnegative value.

Data Types: `double`

Cap maturity date, returned as a datetime.

Data Types: `datetime`

Reset frequency payments per year, returned as a scalar numeric.

Data Types: `double`

Day-count basis, returned as a scalar integer.

Data Types: `double`

Principal amount or principal value schedule, returned as a scalar numeric for a principal amount or a timetable for a principal value schedule.

Data Types: `double` | `timetable`

Lag in rate setting, returned as a scalar numeric.

Data Types: `double`

Flag to adjust cash flows based on the actual period day count, returned as a logical with a value of `true` or `false`.

Data Types: `logical`

Business day conventions, returned as a string.

Data Types: `string`

Holidays used in computing business days, returned as datetimes.

Data Types: `datetime`

Rate curve used in projecting the future cash flows, returned as a `ratecurve` object.

Data Types: `object`

User-defined name for the instrument, returned as a string.

Data Types: `string`

## Examples

collapse all

This example shows the workflow to price a vanilla `Cap` instrument when using a `HullWhite` model and a `HullWhite` pricing method.

Create `Cap` Instrument Object

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

`CapOpt = fininstrument("Cap",'Strike',0.02,'Maturity',datetime(2019,1,30),'Reset',4,'Principal',100,'Basis',8,'Name',"cap_option")`
```CapOpt = Cap with properties: Strike: 0.0200 Maturity: 30-Jan-2019 ResetOffset: 0 Reset: 4 Basis: 8 Principal: 100 ProjectionCurve: [0x0 ratecurve] DaycountAdjustedCashFlow: 0 BusinessDayConvention: "actual" Holidays: NaT Name: "cap_option" ```

Create `HullWhite` Model Object

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

`HullWhiteModel = finmodel("HullWhite",'Alpha',0.62,'Sigma',0.99)`
```HullWhiteModel = HullWhite with properties: Alpha: 0.6200 Sigma: 0.9900 ```

Create `ratecurve` Object

Create a `ratecurve` object using `ratecurve`.

```Settle = datetime(2018,9,15); 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: 15-Sep-2018 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous" ```

Create `HullWhite` Pricer Object

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

`outPricer = finpricer("analytic",'Model',HullWhiteModel,'DiscountCurve',myRC)`
```outPricer = HullWhite with properties: DiscountCurve: [1x1 ratecurve] Model: [1x1 finmodel.HullWhite] ```

Price `Cap` Instrument

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

`Price = price(outPricer,CapOpt)`
```Price = 2.9366 ```

This example shows the workflow to price a vanilla `Cap` instrument when you use a `Normal` model and a `Normal` pricing method.

Create `ratecurve` Object

Create a `ratecurve` object using `ratecurve` for the underlying interest-rate curve for the `cap` instrument.

```Settle = datetime(2018,9,15); 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: 15-Sep-2018 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous" ```

Create `Cap` Instrument Object

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

`CapOpt = fininstrument("Cap",'Maturity',datetime(2022,9,15),'Strike',0.04,'ProjectionCurve',myRC)`
```CapOpt = Cap with properties: Strike: 0.0400 Maturity: 15-Sep-2022 ResetOffset: 0 Reset: 1 Basis: 0 Principal: 100 ProjectionCurve: [1x1 ratecurve] DaycountAdjustedCashFlow: 0 BusinessDayConvention: "actual" Holidays: NaT Name: "" ```

Create `Normal` Model Object

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

`NormalModel = finmodel("Normal",'Volatility',0.01)`
```NormalModel = Normal with properties: Volatility: 0.0100 ```

Create `Normal` Pricer Object

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

`outPricer = finpricer("analytic",'DiscountCurve',myRC,'Model',NormalModel)`
```outPricer = Normal with properties: DiscountCurve: [1x1 ratecurve] Shift: 0 Model: [1x1 finmodel.Normal] ```

Price `Cap` Instrument

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

`[Price, outPR] = price(outPricer, CapOpt)`
```Price = 0.0701 ```
```outPR = priceresult with properties: Results: [1x1 table] PricerData: [] ```

This example shows the workflow to price an amortizing `Cap` instrument when you use a `Black` model and a `Black` pricing method.

Create `Cap` Instrument Object

Use `fininstrument` to create an amortizing `Cap` instrument object.

```CADates = [datetime(2020,9,1) ; datetime(2023,9,1)]; CAPrincipal = [100; 85]; Principal = timetable(CADates,CAPrincipal); CapOpt = fininstrument("Cap",'Maturity',datetime(2023,9,1),'Strike',0.015,'Principal',Principal,'Name',"cap_amortizing_option")```
```CapOpt = Cap with properties: Strike: 0.0150 Maturity: 01-Sep-2023 ResetOffset: 0 Reset: 1 Basis: 0 Principal: [2x1 timetable] ProjectionCurve: [0x0 ratecurve] DaycountAdjustedCashFlow: 0 BusinessDayConvention: "actual" Holidays: NaT Name: "cap_amortizing_option" ```

Create `Black` Model Object

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

`BlackModel = finmodel("Black",'Volatility',0.2)`
```BlackModel = Black with properties: Volatility: 0.2000 Shift: 0 ```

Create `ratecurve` Object

Create a `ratecurve` object using `ratecurve`.

```Settle = datetime(2018,9,1); Type = 'zero'; ZeroTimes = [calyears([1 2 3 4 5 7 10])]'; ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168]'; ZeroDates = Settle + ZeroTimes; myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates);```

Create `Black` Pricer Object

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

`outPricer = finpricer("analytic",'Model',BlackModel,'DiscountCurve',myRC)`
```outPricer = Black with properties: Model: [1x1 finmodel.Black] DiscountCurve: [1x1 ratecurve] ```

Price `Cap` Instrument

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

`Price = price(outPricer,CapOpt)`
```Price = 0.3897 ```

This example shows the workflow to price a vanilla `Cap` instrument when using a `HullWhite` model and an `IRTree` pricing method.

Create `Cap` Instrument Object

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

`CapOpt = fininstrument("Cap",'Strike',0.02,'Maturity',datetime(2020,1,30),'Reset',4,'Principal',100,'Basis',8,'Name',"cap_option")`
```CapOpt = Cap with properties: Strike: 0.0200 Maturity: 30-Jan-2020 ResetOffset: 0 Reset: 4 Basis: 8 Principal: 100 ProjectionCurve: [0x0 ratecurve] DaycountAdjustedCashFlow: 0 BusinessDayConvention: "actual" Holidays: NaT Name: "cap_option" ```

Create `HullWhite` Model Object

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

`HullWhiteModel = finmodel("HullWhite",'Alpha',0.01,'Sigma',0.10)`
```HullWhiteModel = HullWhite with properties: Alpha: 0.0100 Sigma: 0.1000 ```

Create `ratecurve` Object

Create a `ratecurve` object using `ratecurve`.

```Settle = datetime(2018,9,15); 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: 15-Sep-2018 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous" ```

Create `IRTree` Pricer Object

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

```CFdates = cfdates(Settle, CapOpt.Maturity, CapOpt.Reset, CapOpt.Basis); outPricer = finpricer("IRTree",'Model',HullWhiteModel,'DiscountCurve',myRC,'TreeDates',CFdates')```
```outPricer = HWBKTree with properties: Tree: [1x1 struct] TreeDates: [6x1 datetime] Model: [1x1 finmodel.HullWhite] DiscountCurve: [1x1 ratecurve] ```

Price `Cap` Instrument

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

`[Price, outPR] = price(outPricer,CapOpt,["all"])`
```Price = 2.7733 ```
```outPR = priceresult with properties: Results: [1x4 table] PricerData: [1x1 struct] ```
`outPR.Results`
```ans=1×4 table Price Vega Gamma Delta ______ ______ _______ ______ 2.7733 31.655 -49.227 28.932 ```

expand all