parswaprate
Description
computes a par swap rate for a outRate
= parswaprate(SwapObject
,inCurve
)Swap
instrument object.
Examples
Compute Par Swap Rate for Vanilla Swap Instrument Using ratecurve and Discount Pricer
This example shows the workflow to compute the par swap rate for a vanilla Swap
instrument when you use 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(2018,3,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-Mar-2018 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
Create Swap
Instrument Object
Use fininstrument
to create a vanilla Swap
instrument object.
Swap = fininstrument("Swap",'Maturity',datetime(2020,9,15),'LegRate',[0.022 0.019 ],'LegType',["float","fixed"],'ProjectionCurve',myRC,'Name',"swap_instrument")
Swap = Swap with properties: LegRate: [0.0220 0.0190] LegType: ["float" "fixed"] 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-Sep-2020 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 vanilla Swap
instrument.
[Price, outPR] = price(outPricer, Swap,["all"])
Price = 2.4066
outPR = priceresult with properties: Results: [1x2 table] PricerData: []
outPR.Results
ans=1×2 table
Price DV01
______ _________
2.4066 -0.024499
Compute the par swap rate using parswaprate
.
outRate = parswaprate(Swap,myRC)
outRate = 0.0287
Compute Par Swap Rate for Multiple Vanilla Swap Instruments Using ratecurve and Discount Pricer
This example shows the workflow to compute the par swap rate for multiple vanilla Swap
instruments when you use 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(2019,4,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-Apr-2019 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
Create Swap
Instrument Object
Use fininstrument
to create a vanilla Swap
instrument object for three Swap instruments.
Swap = fininstrument("Swap",'Maturity',datetime([2020,4,15 ; 2021,4,15 ; 2024,4,15]),'LegRate',[0.022 0.019 ],'LegType',["float","fixed"],'ProjectionCurve',myRC,'Name',"swap_instrument")
Swap=3×1 object
3x1 Swap array with properties:
LegRate
LegType
Reset
Basis
Notional
LatestFloatingRate
ResetOffset
DaycountAdjustedCashFlow
ProjectionCurve
BusinessDayConvention
Holidays
EndMonthRule
StartDate
Maturity
Name
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
Instruments
Use price
to compute the prices and sensitivities for the vanilla Swap
instruments.
[Price, outPR] = price(outPricer, Swap,["all"])
Price = 3×1
0.8473
1.8067
7.2322
outPR=1×3 object
1x3 priceresult array with properties:
Results
PricerData
outPR.Results
ans=1×2 table
Price DV01
_______ __________
0.84728 -0.0099228
ans=1×2 table
Price DV01
______ _________
1.8067 -0.019656
ans=1×2 table
Price DV01
______ ________
7.2322 -0.04664
Compute the par swap rate for each of the three Swap instruments using parswaprate
.
outRate = parswaprate(Swap(1),myRC)
outRate = 0.0275
outRate = parswaprate(Swap(2),myRC)
outRate = 0.0281
outRate = parswaprate(Swap(3),myRC)
outRate = 0.0338
Input Arguments
SwapObject
— Swap object
Swap
object
Swap object, specified using a previously created Swap
instrument object.
Note
If the SwapObject
is a vector of instruments, you must use
parswaprate
separately with each instrument.
Data Types: object
inCurve
— Rate curve
ratecurve
object
Rate curve, specified as a previously created ratecurve
object.
Data Types: object
Output Arguments
outRate
— Par swap rate
decimal
Par swap rate, returned as a decimal.
More About
Par Swap Rate
The par swap rate is the rate that renders a swap value equal to zero.
In other words, the par swap rate is the value of the fixed rate that gives the swap a zero present value, or the fixed rate that makes the value of both legs equal (that is, the value of the fixed leg and the value of the floating leg).
Version History
Introduced in R2020b
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
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)