price
Syntax
Description
[
computes the instrument price and related pricing information based on the pricing object
Price
,PriceResult
] = price(inpPricer
,inpInstrument
)inpPricer
and the instrument object
inpInstrument
.
[
adds an optional argument to specify sensitivities.Price
,PriceResult
] = price(___,inpSensitivity
)
Examples
Use Discount
Pricer and ratecurve
to Price Swap
Instrument
This example shows the workflow to price a Swap
instrument when using a ratecurve
and a Discount
pricing method.
Create ratecurve
Object
Create a ratecurve
object using ratecurve
for the underlying interest-rate curve for the Swap
instrument.
Settle = datetime(2022,1,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-Jan-2022 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
Create Swap
Instrument Object
Use fininstrument
to create a Swap
instrument object.
SwapOpt = fininstrument("Swap",'Maturity',datetime(2027,1,15),'LegRate',[0.024 0.015],'LegType',["fixed","float"],'ProjectionCurve',myRC,'Name',"swap_instrument")
SwapOpt = Swap with properties: LegRate: [0.0240 0.0150] LegType: ["fixed" "float"] Reset: [2 2] Basis: [0 0] Notional: 100 LatestFloatingRate: [NaN NaN] ResetOffset: [0 0] DaycountAdjustedCashFlow: [0 0] ProjectionCurve: [1x2 ratecurve] BusinessDayConvention: ["actual" "actual"] Holidays: NaT EndMonthRule: [1 1] StartDate: NaT Maturity: 15-Jan-2027 Name: "swap_instrument"
Create Discount
Pricer Object
Use finpricer
to create a Discount
pricer object and use the ratecurve
object for the 'DiscountCurve'
name-value pair argument.
outPricer = finpricer("Discount", 'DiscountCurve',myRC)
outPricer = Discount with properties: DiscountCurve: [1x1 ratecurve]
Price Swap
Instrument
Use price
to compute the price and sensitivities for the Swap
instrument.
[Price, outPR] = price(outPricer, SwapOpt,["all"])
Price = -1.3834
outPR = priceresult with properties: Results: [1x2 table] PricerData: []
outPR.Results
ans=1×2 table
Price DV01
_______ ________
-1.3834 0.048336
Input Arguments
inpInstrument
— Instrument object
Deposit
object | FixedBond
object | FloatBond
object | FRA
object | Swap
object | OISFuture
object | STIRFuture
object | OvernightIndexedSwap
object
Instrument object, specified as a scalar or vector for Deposit
, FixedBond
, FloatBond
, FRA
, Swap
, STIRFuture
, OISFuture
, or OvernightIndexedSwap
instrument objects. Use fininstrument
to create the
Deposit
, FixedBond
, FloatBond
, FRA
, Swap
, STIRFuture
, OISFuture
, or OvernightIndexedSwap
instrument objects.
Data Types: object
inpSensitivity
— List of sensitivities to compute
[ ]
(default) | string array of character vector with values "Price"
,
"DV01"
, and "All"
| cell array of character vectors with values 'Price'
,
'DV01'
, and 'All'
(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 is the same as specifying
inpSensitivity
to include each sensitivity.
The sensitivities supported depend on the
inpInstrument
.
inpInstrument | Supported Sensitivities |
---|---|
Deposit | {'DV01','price'} |
FixedBond | {'DV01','price'} |
FloatBond | {'DV01','price'} |
FRA | {'DV01','price'} |
Swap | {'DV01','price'} |
STIRFuture | {'DV01','price'} |
OISFuture | {'DV01','price'} |
OvernightIndexedSwap | {'DV01','price'} |
Example: inpSensitivity = {'DV01','price'}
Data Types: cell
| string
Output Arguments
Price
— Instrument price
numeric
Instrument price, returned as a numeric.
PriceResult
— Price result
PriceResult
object
Price result, returned as an object. The object has the following fields:
PriceResult.Results
— Table of results that includes sensitivities (if you specifyinpSensitivity
)PriceResult.PricerData
— Structure for pricer data
More About
DV01
A DV01 sensitivity is a measure for managing interest rate risk, as it quantifies how much the value of a bond or bond portfolio is expected to change with a slight move in interest rates.
DV01 quantifies the price change in monetary terms for a 1 basis point move in rates.
Version History
Introduced in R2020a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)