| Contents | Index |
[Price, SwapRate AI, RecCF, RecCFDates, PayCF, PayCFDates]
=
swapbyzero(RateSpec, LegRate, Settle, Maturity)
[Price, SwapRate AI, RecCF, RecCFDates, PayCF, PayCFDates]
=
swapbyzero(RateSpec, LegRate, Settle, Maturity,
LegReset,
Basis, Principal, LegType, EndMonthRule)
[Price, SwapRate, AI, RecCF, RecCFDates, PayCF, PayCFDates]
=
swapbyzero(RateSpec, LegRate, Settle, Maturity,
Name,
Value)
[Price, SwapRate AI, RecCF, RecCFDates, PayCF, PayCFDates] = swapbyzero(RateSpec, LegRate, Settle, Maturity) prices a swap instrument from a set of zero coupon bond rates. All inputs are either scalars or NINST-by-1 vectors unless otherwise specified. Any date can be a serial date number or date string. An optional argument can be passed as an empty matrix [].
[Price, SwapRate AI, RecCF, RecCFDates, PayCF, PayCFDates] = swapbyzero(RateSpec, LegRate, Settle, Maturity, LegReset, Basis, Principal, LegType, EndMonthRule) prices a swap instrument from a set of zero coupon bond rates with optional input arguments. All inputs are either scalars or NINST-by-1 vectors unless otherwise specified. Any date can be a serial date number or date string. An optional argument can be passed as an empty matrix [].
[Price, SwapRate, AI, RecCF, RecCFDates, PayCF, PayCFDates] = swapbyzero(RateSpec, LegRate, Settle, Maturity, Name, Value) prices a swap instrument from a set of zero coupon bond rates with additional options specified by one or more Name, Value pair arguments.
RateSpec |
Structure containing the properties of an interest-rate structure. See intenvset for information on creating RateSpec. RateSpec can be a NINST-by-2 input variable of RateSpecs, with the second input being the discount curve for the paying leg if different than the receiving leg. If only one curve is specified, than it is used to discount both legs. |
LegRate |
Number of instruments (NINST)-by-2 matrix, with each row defined as: [CouponRate Spread] or [Spread CouponRate] 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. |
Settle |
Settlement date. NINST-by-1 vector of serial date numbers or date strings representing the settlement date for each swap. Settle must be earlier than Maturity. |
Maturity |
Maturity date. NINST-by-1 vector of dates representing the maturity date for each swap. |
Enter the following optional inputs using an ordered syntax or as name-value pair arguments. You cannot mix ordered syntax with name-value pair arguments.
LegReset |
NINST-by-2 matrix representing the reset frequency per year for each swap. NINST-by-1 vector representing the frequency of payments per year. Default: [1 1] |
Basis |
Day-count basis of the instrument. A vector of integers.
For more information, see basis. Default: 0 (actual/actual) |
Principal |
NINST-by-1 vector or NINST-by-1 cell array of the notional principal amounts or principal value schedules. For the latter case, each element of the cell array is a NumDates-by-2 call array 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 |
LegType |
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: [1 0] for each instrument |
Options |
Derivatives pricing options structure created with derivset. |
EndMonthRule |
End-of-month rule. NINST-by-1 vector. This rule applies only when Maturity is an end-of-month date for a month having 30 or fewer days.
Default: 1 |
Specify optional comma-separated pairs of Name,Value arguments, where Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
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.
Price an interest-rate swap with a fixed receiving leg and a floating paying leg. Payments are made once a year, and the notional principal amount is $100. The values for the remaining arguments are:
Coupon rate for fixed leg: 0.06 (6%)
Spread for floating leg: 20 basis points
Swap settlement date: Jan. 01, 2000
Swap maturity date: Jan. 01, 2003
Based on the information above, set the required arguments and build the LegRate, LegType, and LegReset matrices:
Settle = '01-Jan-2000'; Maturity = '01-Jan-2003'; Basis = 0; Principal = 100; LegRate = [0.06 20]; % [CouponRate Spread] LegType = [1 0]; % [Fixed Float] LegReset = [1 1]; % Payments once per year
Load the file deriv.mat, which provides ZeroRateSpec, the interest-rate term structure needed to price the bond.
load deriv.mat;
Use swapbyzero to compute the price of the swap.
Price = swapbyzero(ZeroRateSpec, LegRate, Settle, Maturity,... LegReset, Basis, Principal, LegType)
Price = 3.6923
Using the previous data, calculate the swap rate, which is the coupon rate for the fixed leg, such that the swap price at time = 0 is zero.
LegRate = [NaN 20];
[Price, SwapRate] = swapbyzero(ZeroRateSpec, LegRate, Settle,...
Maturity, LegReset, Basis, Principal, LegType) Price = -1.4211e-014 SwapRate = 0.0466
Use swapbyzero with name-value pair arguments for LegRate, LegType, LatestFloatingRate, AdjustCashFlowsBasis, and BusinessDayConvention to calculate output for Price, SwapRate, AI, RecCF, RecCFDates, PayCF, and PayCFDates:
Settle = datenum('08-Jun-2010'); RateSpec = intenvset('Rates', [.005 .0075 .01 .014 .02 .025 .03]',... 'StartDates',Settle, 'EndDates',{'08-Dec-2010','08-Jun-2011',... '08-Jun-2012','08-Jun-2013','08-Jun-2015','08-Jun-2017','08-Jun-2020'}'); Maturity = datenum('15-Sep-2020'); LegRate = [.025 50]; LegType = [1 0]; % fixed/floating LatestFloatingRate = .005; [Price, SwapRate, AI, RecCF, RecCFDates, PayCF,PayCFDates] = ... swapbyzero(RateSpec, LegRate, Settle, Maturity,'LegType',LegType,... 'LatestFloatingRate',LatestFloatingRate,'AdjustCashFlowsBasis',true,... 'BusinessDayConvention','modifiedfollow')
Price =
-3.3937
SwapRate =
NaN
AI =
1.4575
RecCF =
Columns 1 through 10
-1.8219 1.2603 1.2603 1.2740 1.2671 1.2466 1.2534 1.2603 1.2603 1.2740
Columns 11 through 12
1.2671 101.2534
RecCFDates =
Columns 1 through 8
734297 734396 734761 735129 735493 735857 736222 736588
Columns 9 through 12
736953 737320 737684 738049
PayCF =
Columns 1 through 10
-0.3644 0.2521 0.7082 1.0116 1.4423 1.6380 1.9161 2.1038 2.2768 2.2766
Columns 11 through 12
2.4370 102.3432
PayCFDates =
Columns 1 through 8
734297 734396 734761 735129 735493 735857 736222 736588
Columns 9 through 12
736953 737320 737684 738049Price three swaps using two interest-rate curves.
Define data for the interest-rate term structure.
Settle = '01-Jan-2000'; Maturity = '01-Jan-2003'; Basis = 0; Principal = [100;50;100]; %three notional amounts LegRate = [0.06 20]; % [CouponRate Spread] LegType = [1 0]; % [Fixed Float] LegReset = [1 1]; % Payments once per year
Load the data in deriv.mat.
load deriv.matCreate the RateSpec.
ZeroRateSpecNew = intenvset(ZeroRateSpec, 'Rates', [ZeroRateSpec.Rates,ZeroRateSpec.Rates]);ZeroRateSpecNew =
FinObj: 'RateSpec'
Compounding: 1
Disc: [4x2 double]
Rates: [4x2 double]
EndTimes: [4x1 double]
StartTimes: [4x1 double]
EndDates: [4x1 double]
StartDates: 730486
ValuationDate: 730486
Basis: 0
EndMonthRule: 1Price three swaps using one curve.
Price = swapbyzero(ZeroRateSpec, LegRate, Settle, Maturity,... LegReset, Basis, Principal, LegType)
Price = 3.692309149501682 1.846154574750841 3.692309149501682
Price three swaps using two curves.
Price = swapbyzero(ZeroRateSpecNew, LegRate, Settle, Maturity,...
LegReset, Basis, Principal, LegType)Price = 3.692309149501682 3.692309149501682 1.846154574750841 1.846154574750841 3.692309149501682 3.692309149501682
Price an amortizing swap using the Principal input argument to define the amortization schedule.
Create the RateSpec.
Rates = 0.035; ValuationDate = '1-Jan-2011'; StartDates = ValuationDate; EndDates = '1-Jan-2017'; Compounding = 1; RateSpec = intenvset('ValuationDate', ValuationDate,'StartDates', StartDates,... 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding);
RateSpec =
FinObj: 'RateSpec'
Compounding: 1
Disc: 0.8135
Rates: 0.0350
EndTimes: 6
StartTimes: 0
EndDates: 736696
StartDates: 734504
ValuationDate: 734504
Basis: 0
EndMonthRule: 1Create the swap instrument using the following data:
Settle ='1-Jan-2011'; Maturity = '1-Jan-2017'; Period = 1; Spread = 0; LegRate = [0.04 10];
Define the swap amortizing schedule.
Principal ={{'1-Jan-2013' 100;'1-Jan-2014' 80;'1-Jan-2015' 60;'1-Jan-2016' 40; '1-Jan-2017' 20}};Compute the price of the amortizing swap.
Price = swapbyzero(RateSpec, LegRate, Settle, Maturity, 'Principal' , Principal)Price =
1.4574bondbyzero | cfbyzero | fixedbyzero | floatbyzero
View demos and recorded presentations led by industry experts.
Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |