Construct swap instrument


InstSet = instswap(LegRate,Settle,Maturity)
InstSet = instswap(InstSet,LegRate,Settle,Maturity)
InstSet = instswap(InstSet,LegRate,Settle,Maturity,InstSet,LegReset,Basis,Principal,LegType,EndMonthRule)
InstSet = instswap(InstSet,LegRate,Settle,Maturity,LegReset,Basis,Principal,LegType,EndMonthRule,StartDate)
[FieldList,ClassList,TypeString] = instswap



Instrument variable. This argument is specified only when adding a swap to an existing instrument set. See instget for more information on the InstSet variable.


Leg rate, specified as a NINST-by-2 matrix, with each row defined as:

[CouponRate Spread] (fixed-float), [Spread CouponRate] (float-fixed), [CouponRate CouponRate] (fixed-fixed), or [Spread Spread] (float-float).

CouponRate is the decimal annual rate. Spread is the number of basis points over the reference rate. The first column represents the receiving leg, while the second column represents the paying leg.


Settlement date. NINST-by-1 vector of serial date numbers or date character vectors. Settle must be earlier than Maturity.


Maturity date. NINST-by-1 vector of dates representing the maturity date for each swap.


(Optional) NINST-by-2 matrix representing the reset frequency per year for each swap. Default = [1 1].


(Optional) Day-count basis representing the basis for each leg. NINST-by-1 array (or NINST-by-2 if Basis is different for each leg).

  • 0 = actual/actual (default)

  • 1 = 30/360 (SIA)

  • 2 = actual/360

  • 3 = actual/365

  • 4 = 30/360 (BMA)

  • 5 = 30/360 (ISDA)

  • 6 = 30/360 (European)

  • 7 = actual/365 (Japanese)

  • 8 = actual/actual (ICMA)

  • 9 = actual/360 (ICMA)

  • 10 = actual/365 (ICMA)

  • 11 = 30/360E (ICMA)

  • 12 = actual/365 (ISDA)

  • 13 = BUS/252

For more information, see Basis.


(Optional) Principal accepts a NINST-by-1 vector or NINST-by-1 cell array (or NINST-by-2 if Principal is different for each leg) of the notional principal amounts or principal value schedules. For schedules, each element of the cell array is a NumDates-by-2 matrix where the first column is dates and the second column is its associated notional principal value. The date indicates the last day that the principal value is valid. Default = 100.


(Optional) NINST-by-2 matrix. Each row represents an instrument. Each column indicates if the corresponding leg is fixed (1) or floating (0). This matrix defines the interpretation of the values entered in LegRate. Default is [1,0] for each instrument.


(Optional) NINST-by-1 (or NINST-by-2 if EndMonthRule is different for each leg). Default = 1.


(Optional) NINST-by-1 vector of dates when the swaps actually start. Default is Settle.

Data arguments are number of instruments (NINST)-by-1 vectors, scalar, or empty. Fill in unspecified entries vectors with NaN. Only one data argument is required to create the instrument; the others may be omitted or passed as empty matrices [].


InstSet = instswap(LegRate,Settle,Maturity) creates a new instrument set containing swap instruments.

InstSet = instswap(InstSet,LegRate,Settle,Maturity) adds swap instruments to an existing instrument set.

InstSet = instswap(InstSet,LegRate,Settle,Maturity,InstSet,LegReset,Basis,Principal,LegType,EndMonthRule) uses optional input arguments to create a new instrument set containing swap instruments or adds swap instruments to an existing instrument set.

InstSet = instswap(InstSet,LegRate,Settle,Maturity,LegReset,Basis,Principal,LegType,EndMonthRule,StartDate) to create a new forward swap instrument or to add a forward swap instrument to an existing portfolio.

[FieldList,ClassList,TypeString] = instswap displays the classes.

FieldList is a number of fields (NFIELDS-by-1) cell array of character vectors listing the name of each data field for this instrument type.

ClassList is an NFIELDS-by-1 cell array of character vectors listing the data class of each field. The class determines how arguments are parsed. Valid character vectors are 'dble', 'date', and 'char'.

TypeString is a character vector specifying the type of instrument added. For a swap instrument, TypeString = 'Swap'.


collapse all

Create a vanilla swap using market data.

Use the following market data to create a swap instrument.

LegRate = [0.065, 0]
LegRate = 1×2

    0.0650         0

Settle = 'jan-1-2007';    
Maturity = 'jan-1-2012';
LegReset = [1, 1];
Basis = 0
Basis = 0
Principal = 100    
Principal = 100
LegType = [1, 0]   
LegType = 1×2

     1     0

InstSet = instswap(LegRate, Settle, Maturity, LegReset, Basis, Principal, LegType)
InstSet = struct with fields:
        FinObj: 'Instruments'
    IndexTable: [1x1 struct]
          Type: {'Swap'}
     FieldName: {{9x1 cell}}
    FieldClass: {{9x1 cell}}
     FieldData: {{9x1 cell}}

View the swap instrument using instdisp.

Index Type LegRate    Settle         Maturity       LegReset Basis Principal LegType EndMonthRule StartDate
1     Swap [0.065  0] 01-Jan-2007    01-Jan-2012    [1  1]   0     100       [1  0]  1            NaN      

Use instswap to create a float-float swap and price the swap with intenvprice.

RateSpec = intenvset('Rates',.05,'StartDate',today,'EndDate',datemnth(today,60));
IS = instswap([40 20],today,datemnth(today,60),[], [], [], [0 0]);
ans =


Use instswap to create swaps and price the swaps with intenvprice.

RateSpec = intenvset('Rates',.05,'StartDate',today,'EndDate',datemnth(today,60));
IS = instswap([.03 .02],today,datemnth(today,60),[], [], [], [1 1]);
IS = instswap(IS,[200 300],today,datemnth(today,60),[], [], [], [0 0]);
IS = instswap(IS,[300 .07],today,datemnth(today,60),[], [], [], [0 1]);
ans = 3×1


More About

collapse all

Amortizing Swap

In an amortizing swap, the notional principal decreases periodically because it is tied to an underlying financial instrument with a declining (amortizing) principal balance, such as a mortgage.

Forward Swap

Agreement to enter into an interest-rate swap arrangement on a fixed date in future.

Introduced before R2006a