removeInstrument
Remove instrument from portfolio of instruments
Description
removes an instrument object (outPort = removeInstrument(inPort,inInst)inInst) from a portfolio of instruments
(inPort) previously created using finportfolio.
Examples
Use addInstrument to add instruments to an empty portfolio and then remove an instrument from the portfolio using removeInstrument.
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: [10×1 datetime]
Rates: [10×1 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: [1×1 ratecurve]
Add Instruments to finportfolio Object
Create an empty finportflio object using finportfolio and then use addInstrument to add the two FixedBond instruments to the portfolio.
f1 = finportfolio; f1 = addInstrument(f1,FixB1)
f1 =
finportfolio with properties:
Instruments: [1×1 fininstrument.FixedBond]
Pricers: [0×1 finpricer.FinPricer]
PricerIndex: NaN
Quantity: 1
f1 = addInstrument(f1,FixB2)
f1 =
finportfolio with properties:
Instruments: [2×1 fininstrument.FixedBond]
Pricers: [0×1 finpricer.FinPricer]
PricerIndex: [2×1 double]
Quantity: [2×1 double]
Remove Instrument from finportfolio Object
Use removeInstrument to remove the first FixedBond instrument from the portfolio.
f1 = removeInstrument(f1,1)
f1 =
finportfolio with properties:
Instruments: [1×1 fininstrument.FixedBond]
Pricers: [0×1 finpricer.FinPricer]
PricerIndex: NaN
Quantity: 1
Set Pricer for Portfolio
Use setPricer to set the Discount pricer for the portfolio and then use pricePortfolio to calculate the price and sensitivities for the single instrument in the portfolio.
f1 = setPricer(f1,DiscountPricer)
f1 =
finportfolio with properties:
Instruments: [1×1 fininstrument.FixedBond]
Pricers: [1×1 finpricer.Discount]
PricerIndex: 1
Quantity: 1
[PortPrice,InstPrice,PortSens,InstSens] = pricePortfolio(f1)
PortPrice = 110.0749
InstPrice = 110.0749
PortSens=1×2 table
Price DV01
______ ________
110.07 0.041629
InstSens=1×2 table
Price DV01
______ ________
fixed_bond2 110.07 0.041629
Input Arguments
finportfolio object, specified as a scalar finportfolio object.
Data Types: object
Instrument to remove from finportfolio object, specified as a
scalar instrument object, string for the instrument object 'Name'
property, or index value for the position of instrument in the
finportfolio object.
Data Types: object | double | string
Output Arguments
Updated finportfolio, returned as a 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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)