setPricer
Description
Examples
Set Pricer for Portfolio Containing Instruments
Use finportfolio
to create a portfolio of instruments and then use setPricer
to set the pricer for the portfolio.
Create FixedBond
Instrument Objects
Use fininstrument
to create two FixedBond
instrument objects.
FixB1 = fininstrument("FixedBond",'Maturity',datetime(2022,9,15),'CouponRate',0.045,'Name',"fixed_bond1")
FixB1 = FixedBond with properties: CouponRate: 0.0450 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_bond1"
FixB2 = fininstrument("FixedBond",'Maturity',datetime(2022,9,15),'CouponRate',0.035,'Name',"fixed_bond2")
FixB2 = FixedBond with properties: CouponRate: 0.0350 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_bond2"
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 Discount
Pricer Object for FixedBond
Instruments
Use finpricer
to create a Discount
pricer object and use the ratecurve
object for the 'DiscountCurve'
name-value pair argument.
DiscountPricer = finpricer("Discount",'DiscountCurve',myRC)
DiscountPricer = Discount with properties: DiscountCurve: [1x1 ratecurve]
Add Instruments to finportfolio
Object
Create a finportflio
object using finportfolio
and use addInstrument
to put the FixedBond
instruments in the portfolio.
f1 = finportfolio; f1 = addInstrument(f1,FixB1)
f1 = finportfolio with properties: Instruments: [1x1 fininstrument.FixedBond] Pricers: [0x1 finpricer.FinPricer] PricerIndex: NaN Quantity: 1
f1 = addInstrument(f1,FixB2)
f1 = finportfolio with properties: Instruments: [2x1 fininstrument.FixedBond] Pricers: [0x1 finpricer.FinPricer] PricerIndex: [2x1 double] Quantity: [2x1 double]
Set Pricer for Portfolio
Use setPricer
to set the pricer for the portfolio and then use pricePortfolio
to calculate the price and sensitivities for the instruments in the portfolio.
f1 = setPricer(f1,DiscountPricer,[1,2])
f1 = finportfolio with properties: Instruments: [2x1 fininstrument.FixedBond] Pricers: [1x1 finpricer.Discount] PricerIndex: [2x1 double] Quantity: [2x1 double]
[PortPrice,InstPrice,PortSens,InstSens] = pricePortfolio(f1)
PortPrice = 224.0834
InstPrice = 2×1
114.0085
110.0749
PortSens=1×2 table
Price DV01
______ ________
224.08 0.084139
InstSens=2×2 table
Price DV01
______ ________
fixed_bond1 114.01 0.04251
fixed_bond2 110.07 0.041629
Input Arguments
inPort
— Portfolio
finportfolio
object
Portfolio, specified using a previously created finportfolio
object.
Data Types: object
inPricer
— Pricer object to set for an instrument in a finportfolio
object
object
Pricer object to set for an instrument in a finportfolio
object,
specified using a previously created pricer object with finpricer
.
Data Types: object
Index
— Index to instruments in finportfolio
object
numeric
Index to instruments in the finportfolio
object, specified as a
numeric value.
Data Types: double
Output Arguments
outPort
— Updated portfolio
finportfolio
object
Updated portfolio, returned as an finportfolio
object.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)