# price

Compute price for CurrencySwap instrument with FXDiscount pricer

Since R2024a

## Description

example

[Price,PriceResult] = price(inpPricer,inpInstrument) computes the instrument price and related pricing information based on the pricing object inpPricer and the instrument object inpInstrument.

example

[Price,PriceResult] = price(___,inpSensitivity) adds an optional argument to specify sensitivities.

## Examples

collapse all

This example shows the workflow to price a CurrencySwap instrument by using two ratecurve objects for two zero rates for different currencies and then use a FXDiscount pricing method.

Create ratecurve Objects

Create two ratecurve objects using ratecurve for the discounting cash flows for the CurrencySwap instrument. The ZeroCurve_USD zero curve is for US currency and the EUR_Zero zero curve is for Euro currency.

Settle = datetime(2023,9,15);

% US Currency
USD_Dates = datemnth(Settle,[1 3 6 12*[1 2 3 5 7 10 20 30]]');
USD_Zero = [0.03 0.06 0.08 0.13 0.36 0.76 1.63 2.29 2.88 3.64 3.89]'/100;
ZeroCurve_USD = ratecurve("zero",Settle,USD_Dates,USD_Zero,Compounding=1)
ZeroCurve_USD =
ratecurve with properties:

Type: "zero"
Compounding: 1
Basis: 0
Dates: [11×1 datetime]
Rates: [11×1 double]
Settle: 15-Sep-2023
InterpMethod: "linear"
ShortExtrapMethod: "next"
LongExtrapMethod: "previous"

% Euro currency
EUR_Dates = datemnth(Settle,[3 6 12*[1 2 3 5 7 10 20 30]]');
EUR_Zero = [0.017 0.033 0.088 .27 .512 1.056 1.573 2.183 2.898 2.797]'/100;
ZeroCurve_EUR = ratecurve("zero",Settle,EUR_Dates,EUR_Zero,Compounding=1)
ZeroCurve_EUR =
ratecurve with properties:

Type: "zero"
Compounding: 1
Basis: 0
Dates: [10×1 datetime]
Rates: [10×1 double]
Settle: 15-Sep-2023
InterpMethod: "linear"
ShortExtrapMethod: "next"
LongExtrapMethod: "previous"

Create CurrencySwap Instrument Object

Use fininstrument to create a CurrencySwap instrument object.

% Cross-Currency Swap Data
Maturity_FXSwap = Settle + calyears(10);
LegRate_FXSwap = [2.5 4]/100;
LegType_FXSwap = ["fixed" "fixed"];
LegReset_FXSwap = [2 2];
Notional_FXSwap = [100 100/1.1];

CurrencySwap = fininstrument("CurrencySwap",Maturity=Maturity_FXSwap,LegRate=LegRate_FXSwap,LegType=LegType_FXSwap,Reset=LegReset_FXSwap,Notional=Notional_FXSwap,Name="currencyswap_instrument")
CurrencySwap =
CurrencySwap with properties:

LegRate: [0.0250 0.0400]
LegType: ["fixed"    "fixed"]
Reset: [2 2]
Basis: [0 0]
Notional: [100 90.9091]
LatestFloatingRate: [NaN NaN]
ResetOffset: [0 0]
ProjectionCurve: [0×0 ratecurve]
Holidays: NaT
EndMonthRule: [1 1]
ExchangeInitialNotional: 1
ExchangeMaturityNotional: 1
StartDate: NaT
Maturity: 15-Sep-2033
Name: "currencyswap_instrument"

Create FXDiscount Pricer Object

Use finpricer to create a FXDiscount pricer object and use the two ratecurve objects for the DiscountCurve name-value argument.

FXRate = [1 1.1];
myFXPricer = finpricer("FXDiscount",DiscountCurve=[ZeroCurve_EUR ZeroCurve_USD],FXRate=FXRate)
myFXPricer =
FXDiscount with properties:

DiscountCurve: [1×2 ratecurve]
FXRate: [1 1.1000]

Price CurrencySwap Instrument

Use price to compute the price for the CurrencySwap instrument.

Price_FXSwap = price(myFXPricer,CurrencySwap,"all")
Price_FXSwap = -7.5751

## Input Arguments

collapse all

Pricer object, specified as a scalar FXDiscount pricer object. Use finpricer to create the FXDiscount pricer object.

Data Types: object

Instrument object, specified as a scalar or vector for CurrencySwap instrument objects. Use fininstrument to create the CurrencySwap instrument objects.

Data Types: object

(Optional) List of sensitivities to compute, specified as a NOUT-by-1 or a 1-by-NOUT cell array of character vectors or string array with possible values of 'Price' and 'DV01'.

inpSensitivity = {'All'} or inpSensitivity = ["All"] specifies that the output is Price and DV01. This input is the same as specifying inpSensitivity to include each sensitivity.

The sensitivities supported depend on the inpInstrument.

inpInstrumentSupported Sensitivities
CurrencySwap{'DV01','price'}

Example: inpSensitivity = {'DV01','price'}

Data Types: cell | string

## Output Arguments

collapse all

Instrument price, returned as a numeric.

Price result, returned as an object. The object has the following fields:

• PriceResult.Results — Table of results that includes sensitivities (if you specify inpSensitivity)

• PriceResult.PricerData — Structure for pricer data

## Version History

Introduced in R2024a