Main Content

parswaprate

Compute par swap rate for Swap and OvernightIndexedSwap instrument

Since R2020b

Description

outRate = parswaprate(SwapObject,inCurve) computes a par swap rate for a Swap and a OvernightIndexedSwap instrument object.

example

Examples

collapse all

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

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 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 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

Since R2024a

This example shows the workflow to compute the par swap rate for a Swap instrument when you set the ProjectionCurve property and then compute the modified duration for the Swap instrument.

Create ratecurve Objects for Discount and Projection Curves

Create a ratecurve object using ratecurve for the discount and projection curves for the Swap instrument.

Settle = datetime(2023,8,23); 
Type = "zero"; 
CurveTimes = [calmonths([1 2 3 4 6]) calyears([1 2 3 5 7 10 20 30])]'; 
CurveDates = Settle + CurveTimes; 

DiscRates = [5.54 5.53 5.57 5.56 5.55 5.35 4.95 4.64 4.36 4.30 4.19 4.46 4.27]'/100;
ProjRates = DiscRates + .01; 

RC_Disc = ratecurve(Type,Settle,CurveDates,DiscRates); 
RC_Proj = ratecurve(Type,Settle,CurveDates,ProjRates); 

Create Swap Instrument Object

Use fininstrument to create a Swap instrument object.

SwapMaturity = Settle + calyears(10); 
SwapLegType = ["float","fixed"]; 
SwapLegRate = [0 0]; 
SwapLegReset = [2 2]; 
Swap = fininstrument("Swap",Maturity=SwapMaturity,LegRate=SwapLegRate,LegType=SwapLegType,ProjectionCurve=RC_Proj) 
Swap = 
  Swap with properties:

                     LegRate: [0 0]
                     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: 23-Aug-2033
                        Name: ""

Compute Par Swap Rate

Compute the par swap rate using parswaprate.

ParSwapRate = parswaprate(Swap,RC_Disc); 

Create Swap Instrument Object Using Par Swap Rate

Use fininstrument to create a Swap instrument object using the ParSwapRate for the LegRate of the Swap fixed leg.

Swap_Par = fininstrument("Swap",Maturity=SwapMaturity,LegRate=[0 ParSwapRate],LegType=SwapLegType,ProjectionCurve=RC_Proj)
Swap_Par = 
  Swap with properties:

                     LegRate: [0 0.0529]
                     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: 23-Aug-2033
                        Name: ""

Create Discount Pricer Object

Use finpricer to create a Discount pricer object and use the discount curve ratecurve object for the 'DiscountCurve' name-value argument.

Pricer_Disc = finpricer("Discount",DiscountCurve=RC_Disc) 
Pricer_Disc = 
  Discount with properties:

    DiscountCurve: [1x1 ratecurve]

Price Swap Instrument

Use price to compute the price and sensitivities for the "par" Swap instrument.

[Price,outPR] = price(Pricer_Disc,Swap_Par,"all"); 

Compute Modified Duration for Swap

Compute the modified duration for the Swap by computing for each leg and then use the relation between modified duration and DV01. Modified duration measures the percentage change in price for a given change in yield, while DV01 quantifies the dollar value change in price for a one basis point change in yield.

Swap_RecLeg = fininstrument("FloatBond",Maturity=SwapMaturity,Spread=SwapLegRate(1),ProjectionCurve=RC_Proj,Reset=SwapLegReset(1)); 
Swap_PayLeg = fininstrument("FixedBond",Maturity=SwapMaturity,CouponRate=ParSwapRate,Period=SwapLegReset(2)); 
[Price_Leg,outPR_Leg] = price(Pricer_Disc,[Swap_RecLeg;Swap_PayLeg],"all"); 
ModifiedDuration = outPR_Leg(1).Results.DV01/.01/.01/Price_Leg(1) - outPR_Leg(2).Results.DV01/.01/.01/Price_Leg(2); 

fprintf('Par Swap Rate: %f\n', ParSwapRate*100); 
Par Swap Rate: 5.286657
fprintf('Par NPV: %f\n', Price); 
Par NPV: 0.000000
fprintf('Par DV01: %f\n', outPR.Results.DV01); 
Par DV01: -0.082864
fprintf('Par MD: %f\n', ModifiedDuration); 
Par MD: -7.659812

Since R2024a

This example shows the workflow to price an OvernightIndexedSwap instrument when you use a ratecurve object and a Discount pricing method and then use parswaprate to compute the par swap rate.

Create ratecurve Object

Create a ratecurve object using ratecurve for the underlying interest-rate curve for the OvernightIndexedSwap instrument.

Settle = datetime(2019,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-2019
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Create OvernightIndexedSwap Instrument Object

Use fininstrument to create an OvernightIndexedSwap instrument object.

OvernightIndexedSwap = fininstrument("OvernightIndexedSwap",Maturity=datetime(2022,9,15),LegRate=[0.022 0.019 ],LegType=["float","fixed"],Notional=100,ProjectionCurve=myRC,Name="overnight_swap_instrument")
OvernightIndexedSwap = 
  OvernightIndexedSwap with properties:

                     LegRate: [0.0220 0.0190]
                     LegType: ["float"    "fixed"]
                       Reset: [2 2]
                       Basis: [0 0]
                    Notional: 100
            HistoricalFixing: [0x0 timetable]
                 ResetOffset: [0 0]
                PaymentDelay: 0
             ProjectionCurve: [1x1 ratecurve]
       BusinessDayConvention: ["actual"    "actual"]
                    Holidays: NaT
                EndMonthRule: [1 1]
    DaycountAdjustedCashFlow: [0 0]
                   StartDate: NaT
                    Maturity: 15-Sep-2022
                        Name: "overnight_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 OvernightIndexedSwap Instrument

Use price to compute the price and sensitivities for the OvernightIndexedSwap instrument.

[Price, outPR] = price(outPricer,OvernightIndexedSwap,"all")
Price = 
3.0797
outPR = 
  priceresult with properties:

       Results: [1x2 table]
    PricerData: []

outPR.Results
ans=1×2 table
    Price       DV01   
    ______    _________

    3.0797    -0.029334

Compute Par Swap Rate

Use parswaprate to compute the par swap rate for the OvernightIndexedSwap instrument. The par swap rate is the rate that renders a swap value equal to zero.

outRate = parswaprate(OvernightIndexedSwap,myRC)
outRate = 
0.0294

Input Arguments

collapse all

Swap object, specified using a previously created Swap or OvernightIndexedSwap instrument object.

Note

If the SwapObject is a vector of instruments, you must use parswaprate separately with each instrument.

Data Types: object

Rate curve, specified as a previously created ratecurve object.

Note

If you input a projection curve using the Swap instrument argument for ProjectionCurve, use the discount curve as the inCurve input. For more information, see Use Par Swap Rate for Swap Instrument to Calculate Modified Duration

Data Types: object

Output Arguments

collapse all

Par swap rate, returned as a decimal.

More About

collapse all

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

expand all