irCapFloorPricer
First introduced in version: 3.00.6
Syntax
irCapFloorPricer(instrument, pricingDate, discountCurve, forwardCurve,
volSurf, [setting], [model='Bachelier'], [method='Analytic'])
Details
Prices an interest rate cap and floor option and returns its net present value (NPV).
Parameters
instrument is an INSTRUMENT scalar or vector specifying the interest rate cap and floor option to be priced. See IrCapFloor for details.
pricingDate is a DATE scalar or vector specifying the pricing date.
discountCurve is a MKTDATA scalar or vector specifying the discount curve (IrYieldCurve).
forwardCurve is a MKTDATA scalar or vector specifying the futures price curve (AssetPriceCurve).
volSurf is a MKTDATA scalar or vector specifying the volatility surface.
setting (optional) is a dictionary (<STRING, BOOL>) specifying whether to calculate option price sensitivities (Greeks). Supported keys:
| Key | Value | Description |
|---|---|---|
| calcDelta | Boolean; defaults to false | Whether to calculate Delta, the sensitivity of the option price to the underlying asset price. |
| calcGamma | Boolean; defaults to false | Whether to calculate Gamma, the sensitivity of Delta to the underlying asset price. |
| calcVega | Boolean; defaults to false | Whether to calculate Vega, the sensitivity of the option price to volatility. |
| calcTheta | Boolean; defaults to false | Whether to calculate Theta, the sensitivity of the option price to the passage of time. |
| calcRho | Boolean; defaults to false | Whether to calculate Rho, the sensitivity of the option price to the risk-free interest rate. |
model (optional) is a STRING scalar specifying the pricing model to use. It can be "Bachelier" (default) and "Black76". If set to "Bachelier", the volType of the VolatilitySurface volSurf must be "Normal". If set to "Black76", volType must be "Lognormal".
method (optional) is a STRING scalar specifying the solution method to use. It can only be "Analytic" now.
Returns
-
If setting is not specified, returns a DOUBLE scalar or vector indicating the NPV of the interest rate cap and floor option.
-
If setting is specified, returns a dictionary (<STRING, DOUBLE >) containing the NPV and the Greeks specified by setting.
Examples
Prices an interest rate cap and floor option.
// =====================================================
// I. Set Pricing Date
// =====================================================
// Pricing date for LPR 1Y Floor
lpr1yPricingDate = 2021.03.18
// =====================================================
// II. Construct LPR 1Y Floor Product Dictionary
// =====================================================
lpr1yFloorDict = {
"productType": "Option",
// Option type
"optionType": "EuropeanOption",
// Underlying asset type
"assetType": "IrCapFloor",
// Instrument ID
"instrumentId": "LPR1Y_FLOOR_SAMPLE_11",
// Notional amount
"notionalAmount": 37000000.0,
// Notional currency
"notionalCurrency": "CNY",
// Start date
"start": 2021.03.18,
// Maturity date
"maturity": 2022.03.17,
// Strike rate
"strike": 0.035,
// Last determined fixing rate
"lastFixing": 0.0340,
// Payment frequency
"frequency": "Quarterly",
// Cap/Floor type
"capFloorType": "Floor",
// Floating leg reference rate index: LPR 1Y
"iborIndex": "LPR_1Y",
// Day count convention
"dayCountConvention": "Actual360",
// Discount curve name
"discountCurve": "CNY",
// Forward curve name
"forwardCurve": "LPR_1Y"
}
// -----------------------------------------------------
// Parse the product dictionary into a financial instrument object recognized by the DDB system
// -----------------------------------------------------
lpr1yFloor = parseInstrument(lpr1yFloorDict)
// =====================================================
// III. Construct Discount Curve
// =====================================================
// Create a default flat interest rate curve as the discount curve.
lpr1yDiscountCurve = createDefaultFlatIrYieldCurve(
// Curve reference date
lpr1yPricingDate,
// Currency
"CNY",
// Interest rate
0.0280,
// Curve day count convention
"Actual365",
// Compounding frequency
"NoFrequency",
// Compounding method
"Continuous"
)
// =====================================================
// IV. Construct Forward Curve
// =====================================================
lpr1yForwardCurve = createDefaultFlatIrYieldCurve(
// Curve reference date
lpr1yPricingDate,
// Currency
"CNY",
// Interest rate
0.037,
// Curve day count convention
"Actual365",
// Compounding frequency
"NoFrequency",
// Compounding method: Continuous compounding
"Continuous"
)
// =====================================================
// V. Construct LPR 1Y Cap/Floor Volatility Surface
// =====================================================
Lpr1yCapFloorSurf = {
// Volatility surface name
"surfaceName": "CNY_LPR_1Y",
// Market data type
"mktDataType": "Surface",
// Surface type
"surfaceType": "IrCapFloorVolatilitySurface",
// Surface reference date
"referenceDate": 2021.03.18,
// Smile interpolation method
"smileMethod": "Linear",
// Term node dates
"termDates": [
2021.06.18,
2021.09.17,
2021.12.17,
2022.03.17
],
// Each termDate corresponds to a volatility smile.
// The length of volSmiles should match the length of termDates.
// Each smile contains:
// strikes: strike rate nodes;
// vols: volatilities at the corresponding strike rate nodes.
"volSmiles":[
{
"strikes": [0.0, 0.03, 0.06, 0.10],
"vols": [0.0067, 0.0064, 0.0066, 0.0071]
},
{
"strikes": [0.0, 0.03, 0.06, 0.10],
"vols": [0.0067, 0.0064, 0.0066, 0.0071]
},
{
"strikes": [0.0, 0.03, 0.06, 0.10],
"vols": [0.0067, 0.0064, 0.0066, 0.0071]
},
{
"strikes": [0.0, 0.03, 0.06, 0.10],
"vols": [0.0067, 0.0064, 0.0066, 0.0071]
}
],
// Currency
"currency": "CNY",
// Corresponding floating rate index
"iborIndex": "LPR_1Y"
}
// -----------------------------------------------------
// Parse the volatility surface dictionary into a market data object recognized by the DDB system
// -----------------------------------------------------
lpr1yVolSurf = parseMktData(Lpr1yCapFloorSurf)
// =====================================================
// VI. Call the Cap/Floor Pricer
// =====================================================
lpr1yFloorNpv = irCapFloorPricer(
lpr1yFloor,
lpr1yPricingDate,
lpr1yDiscountCurve,
lpr1yForwardCurve,
lpr1yVolSurf,
model="Bachelier"
)
// =====================================================
// VII. Output Pricing Result
// =====================================================
print("LPR1Y_FLOOR_SAMPLE_11 Bachelier NPV = " + string(lpr1yFloorNpv))
IrCapFloor
| Field | Data Type | Description | Required |
|---|---|---|---|
| productType | STRING | Must be "Option". | Yes |
| optionType | STRING | Must be "EuropeanOption". | Yes |
| assetType | STRING | Must be "IrCapFloor". | Yes |
| notionalAmount | DOUBLE | Notional principal amount | Yes |
| notionalCurrency | STRING | Notional currency | No |
| instrumentId | STRING | Contract code, standard format: Cap/Floor_Reference Rate_Option Term, e.g., "Cap_LPR1Y_6M". | No |
| iborIndex | STRING | Reference rate. It can be "LPR_1Y" or "LPR_5Y" | Yes |
| lastFixing | DOUBLE | The latest fixing rate for the reference rate. | No |
| start | DATE | Value date | Yes |
| maturity | DATE | Maturity date | Yes |
| strike | DOUBLE | Strike price | Yes |
| capFloorType | STRING |
Identifies whether the instrument is a Cap or a Floor. Available options:
|
Yes |
| frequency | STRING |
Frequency of interest payment. If not specified, the system applies the convention for the reference rate. For "LPR_1Y" and "LPR_5Y", the default is "Quarterly". It can be:
|
No |
| dayCountConvention | STRING | The day count convention. It can be: "ActualActualISDA", "ActualActualISMA"," Actual365", "Actual360" | Yes |
| discountCurve | STRING | The discount curve name, e.g., "CNY_FR_007". | No |
| forwardCurve | STRING | The forward curve name, e.g., "CNY_LPR_1Y". | No |
IrCapFloorVolatilitySurface
| Field | Data Type | Description | Required |
|---|---|---|---|
| mktDataType | STRING | Must be "Surface" | √ |
| referenceDate | DATE | Reference Date | √ |
| surfaceType | STRING | Must be "IrCapFloorVolatilitySurface" | √ |
| smileMethod | STRING |
Volatility smile method. It can be:
|
√ |
| volSmiles | A tuple of DICT(STRING, ANY) |
Volatility smiles vector. Each element is one smile . It has the following members:
|
√ |
| termDates | DATE vector | Term date corresponding to each smile in volSmiles. | √ |
| surfaceName | STRING | Surface name | × |
| currency | STRING | Currency. It can be CNY", "USD", "EUR", "GBP", "JPY", "HKD" | √ |
| iborIndex | STRING |
Reference Rate. Available options:
|
√ |
| volType | STRING |
Volatility Type. Available valuoptionses:
|
× |
Releated links: parseInstrument, parseMktData
