price
Syntax
Description
[
computes the interest-rate 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. Use this syntax with the input
argument combination in the previous syntax.Price
,PriceResult
] = price(___,inpSensitivity
)
Examples
Price Fixed Bond Instrument Using Hull-White Model and IRMonteCarlo Pricer
This example shows the workflow to price a FixedBond
instrument when using a HullWhite
model and an IRMonteCarlo
pricing method.
Create FixedBond
Instrument Object
Use fininstrument
to create a FixedBond
instrument object.
FixB = fininstrument("FixedBond","Maturity",datetime(2022,9,15),"CouponRate",0.05,'Name',"fixed_bond")
FixB = FixedBond with properties: CouponRate: 0.0500 Period: 2 Basis: 0 EndMonthRule: 1 Principal: 100 DaycountAdjustedCashFlow: 0 BusinessDayConvention: "actual" Holidays: NaT IssueDate: NaT FirstCouponDate: NaT LastCouponDate: NaT StartDate: NaT Maturity: 15-Sep-2022 Name: "fixed_bond"
Create HullWhite
Model Object
Use finmodel
to create a HullWhite
model object.
HullWhiteModel = finmodel("HullWhite",'Alpha',0.32,'Sigma',0.49)
HullWhiteModel = HullWhite with properties: Alpha: 0.3200 Sigma: 0.4900
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',HullWhiteModel,'DiscountCurve',myRC,'SimulationDates',ZeroDates)
outPricer = HWMonteCarlo 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.HullWhite]
Price FixedBond
Instrument
Use price
to compute the price and sensitivities for the FixedBond
instrument.
[Price,outPR] = price(outPricer,FixB,["all"])
Price = 115.0303
outPR = priceresult with properties: Results: [1x4 table] PricerData: [1x1 struct]
outPR.Results
ans=1×4 table
Price Delta Gamma Vega
______ _______ ______ ____
115.03 -397.13 1430.4 0
Input Arguments
inpPricer
— Pricer object
IRMonteCarlo
object
Pricer object, specified as a previously created IRMonteCarlo
pricer
object. Create the pricer object using finpricer
.
Data Types: object
inpInstrument
— Instrument object
Cap
object | Floor
object | Swaption
object | Swap
object | FixedBond
object | OptionEmbeddedFixedBond
object | OptionEmbeddedFloatBond
object | FixedBondOption
object | FloatBond
object | FloatBondOption
object
Instrument object, specified as scalar or a vector of previously created instrument
objects. Create the instrument objects using fininstrument
. The following
instrument objects are supported:
Data Types: object
inpSensitivity
— List of sensitivities to compute
[ ]
(default) | string array with values dependent on pricer object | cell array of character vectors with values dependent on pricer object
(Optional) List of sensitivities to compute, specified as an
NOUT
-by-1
or
1
-by-NOUT
cell array of character vectors or
string array.
The supported sensitivities depend on the pricing method.
inpInstrument | Supported Sensitivities |
---|---|
Cap | {'delta','gamma','vega','price'}
('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo
pricer.) |
Floor | {'delta','gamma','vega','price'}
('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo
pricer.) |
Swap | {'delta','gamma','vega','price'} |
Swaption | {'delta','gamma','vega','price'} |
FixedBond | {'delta','gamma','vega','price'}
('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo
pricer.) |
OptionEmbeddedFixedBond | {'delta','gamma','vega','price'}
('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo
pricer.) |
FixedBondOption | {'delta','gamma','vega','price'}
('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo
pricer.) |
FloatBond | {'delta','gamma','vega','price'}
('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo
pricer.) |
FloatBondOption | {'delta','gamma','vega','price'}
('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo
pricer.) |
OptionEmbeddedFloatBond | {'delta','gamma','vega','price'}
('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo
pricer.) |
inpSensitivity = 'All'
or inpSensitivity =
"All"
specifies that all sensitivities for the pricing method are returned.
This is the same as specifying inpSensitivity
to include each
sensitivity.
Example: inpSensitivity =
["delta","gamma","vega","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 a PriceResult
object. The object has
the following fields:
PriceResult.Results
— Table of results that includes sensitivities (if you specifyinpSensitivity
)PriceResult.PricerData
— Structure for pricer data
Version History
Introduced in R2021b
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
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)