# intenvset

Set properties of interest-rate structure

## Syntax

```[RateSpec, RateSpecOld] = intenvset(RateSpec, 'Argument1', Value1, 'Argument2', Value2, ...)[RateSpec, RateSpecOld] = intenvsetintenvset```

## Arguments

 `RateSpec` (Optional) An existing interest-rate specification structure to be changed, probably created from a previous call to `intenvset`.

Arguments may be chosen from the following table and specified in any order.

 `Compounding` Scalar value representing the rate at which the input zero rates or forward rates were compounded when annualized. Default = `2`. This argument determines the formula for the discount factors: `Compounding` = `1`, `2`, `3`, `4`, `6`, `12````Disc = (1 + Z/F)^(-T)```, where `F` is the compounding frequency, `Z` is the zero rate, and `T` is the time in periodic units; for example, `T = F` is 1 year.`Compounding` = `365` ```Disc = (1 + Z/F)^(-T)```, where `F` is the number of days in the basis year and `T` is a number of days elapsed computed by basis.`Compounding` = `-1````Disc = exp(-T*Z)```, where `T` is time in years. `Disc` Number of points (`NPOINTS`) by number of curves (`NCURVES`) matrix of unit bond prices over investment intervals from `StartDates`, when the cash flow is valued, to `EndDates`, when the cash flow is received. `Rates` Number of points (`NPOINTS`) by number of curves (`NCURVES`) matrix of rates in decimal form. For example, 5% is `0.05` in `Rates`. `Rates` are the yields over investment intervals from `StartDates`, when the cash flow is valued, to `EndDates`, when the cash flow is received. `EndDates` `NPOINTS`-by-`1` vector or scalar of serial maturity dates ending the interval to discount over. `StartDates` `NPOINTS`-by-`1` vector or scalar of serial dates starting the interval to discount over. Default = `ValuationDate`. `StartDates` must be earlier than `EndDates`. `ValuationDate` (Optional) Scalar value in serial date number form representing the observation date of the investment horizons entered in `StartDates` and `EndDates`. Default = `min(StartDates)`. `Basis` (Optional) Day-count basis of the instrument. A scalar of integers.0 = actual/actual (default)1 = 30/360 (SIA)2 = actual/3603 = actual/3654 = 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/actual (ISDA)13 = BUS/252For more information, see basis. `EndMonthRule` (Optional) End-of-month rule. A scalar. This rule applies only when `EndDates` is an end-of-month date for a month having 30 or fewer days. `0` = ignore rule, meaning that a bond's coupon payment date is always the same numerical day of the month. `1` = set rule on (default), meaning that a bond's coupon payment date is always the last actual day of the month.

It is sufficient to type only the leading characters that uniquely identify the parameter. Case is ignored for argument names.

When creating a new `RateSpec`, the set of arguments passed to `intenvset` must include `StartDates`, `EndDates`, and either `Rates` or `Disc`.

Call `intenvset` with no input or output arguments to display a list of argument names and possible values.

## Description

```[RateSpec, RateSpecOld] = intenvset(RateSpec, 'Argument1', Value1, 'Argument2', Value2, ...)``` creates an interest term structure (`RateSpec`) in which the input argument list is specified as argument name /argument value pairs. The argument name portion of the pair must be recognized as a valid field of the output structure `RateSpec`; the argument value portion of the pair is then assigned to its paired field.

If the optional argument `RateSpec` is specified, `intenvset` modifies an existing interest term structure `RateSpec` by changing the named argument to the specified values and recalculating the arguments dependent on the new values.

`[RateSpec, RateSpecOld] = intenvset` creates an interest term structure `RateSpec` with all fields set to `[]`.

`intenvset` with no input or output arguments displays a list of argument names and possible values.

`RateSpecOld` is a structure containing the properties of an interest-rate structure before the changes introduced by the call to `intenvset`.

## Examples

collapse all

### Create a RateSpec for a Zero Curve

Use `intenvset` to create a `RateSpec` for a zero curve.

```RateSpec = intenvset('Rates', 0.05, 'StartDates',... '20-Jan-2000', 'EndDates', '20-Jan-2001') ```
```RateSpec = FinObj: 'RateSpec' Compounding: 2 Disc: 0.9518 Rates: 0.0500 EndTimes: 2 StartTimes: 0 EndDates: 730871 StartDates: 730505 ValuationDate: 730505 Basis: 0 EndMonthRule: 1 ```

Now change the `Compounding` argument to `1` (annual).

```RateSpec = intenvset(RateSpec, 'Compounding', 1) ```
```RateSpec = FinObj: 'RateSpec' Compounding: 1 Disc: 0.9518 Rates: 0.0506 EndTimes: 1 StartTimes: 0 EndDates: 730871 StartDates: 730505 ValuationDate: 730505 Basis: 0 EndMonthRule: 1 ```

Calling `intenvset` with no input or output arguments displays a list of argument names and possible values.

```intenvset ```
``` Compounding: [ 1 | {2} | 3 | 4 | 6 | 12 | 365 | -1 ] Disc: [ scalar | vector (NPOINTS x 1) ] Rates: [ scalar | vector (NPOINTS x 1) ] EndDates: [ scalar | vector (NPOINTS x 1) ] StartDates: [ scalar | vector (NPOINTS x 1) ] ValuationDate: [ scalar ] Basis: [ {0} | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 ] EndMonthRule: [ 0 | {1} ] ```

### Create a RateSpec for a Forward Curve

Use `intenvset` to create a `RateSpec` for a forward curve.

```RateSpec = intenvset('Rates', 0.05, 'StartDates',... '20-Jan-2001', 'EndDates', '20-Jan-2002', 'ValuationDate','20-Jan-2000') ```
```RateSpec = FinObj: 'RateSpec' Compounding: 2 Disc: 0.9518 Rates: 0.0500 EndTimes: 4 StartTimes: 2 EndDates: 731236 StartDates: 730871 ValuationDate: 730505 Basis: 0 EndMonthRule: 1 ```

Now change the `Compounding` argument to `1` (annual).

```RateSpec = intenvset(RateSpec, 'Compounding', 1) ```
```RateSpec = FinObj: 'RateSpec' Compounding: 1 Disc: 0.9518 Rates: 0.0506 EndTimes: 2 StartTimes: 1 EndDates: 731236 StartDates: 730871 ValuationDate: 730505 Basis: 0 EndMonthRule: 1 ```

### Create a RateSpec Using Two Curves

Define data for the interest-rate term structure and use `intenvset` to create a `RateSpec`.

```StartDates = '01-Oct-2011'; EndDates = ['01-Oct-2012'; '01-Oct-2013';'01-Oct-2014';'01-Oct-2015']; Rates = [[0.0356;0.041185;0.04489;0.047741],[0.0325;0.0423;0.0437;0.0465]]; RateSpec = intenvset('Rates', Rates, 'StartDates',StartDates,... 'EndDates', EndDates, 'Compounding', 1) ```
```RateSpec = FinObj: 'RateSpec' Compounding: 1 Disc: [4x2 double] Rates: [4x2 double] EndTimes: [4x1 double] StartTimes: [4x1 double] EndDates: [4x1 double] StartDates: 734777 ValuationDate: 734777 Basis: 0 EndMonthRule: 1 ```

To look at the `Rates` for the two interest-rate curves:

```RateSpec.Rates ```
```ans = 0.0356 0.0325 0.0412 0.0423 0.0449 0.0437 0.0477 0.0465 ```

### Create a RateSpec to Price Multi-Stepped Coupon Bonds

Price the following multi-stepped coupon bonds using the following data:

```Rates = [0.035; 0.042147; 0.047345; 0.052707]; ValuationDate = 'Jan-1-2010'; StartDates = ValuationDate; EndDates = {'Jan-1-2011'; 'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'}; Compounding = 1; % Create RateSpec using intenvset RS = intenvset('ValuationDate', ValuationDate, 'StartDates', StartDates,... 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding); % Create a portfolio of stepped coupon bonds with different maturities Settle = '01-Jan-2010'; Maturity = {'01-Jan-2011';'01-Jan-2012';'01-Jan-2013';'01-Jan-2014'}; CouponRate = {{'01-Jan-2011' .042;'01-Jan-2012' .05; '01-Jan-2013' .06; '01-Jan-2014' .07}}; % Display the instrument portfolio ISet = instbond(CouponRate, Settle, Maturity, 1); instdisp(ISet) ```
```Index Type CouponRate Settle Maturity Period Basis EndMonthRule IssueDate FirstCouponDate LastCouponDate StartDate Face 1 Bond [Cell] 01-Jan-2010 01-Jan-2011 1 0 1 NaN NaN NaN NaN 100 2 Bond [Cell] 01-Jan-2010 01-Jan-2012 1 0 1 NaN NaN NaN NaN 100 3 Bond [Cell] 01-Jan-2010 01-Jan-2013 1 0 1 NaN NaN NaN NaN 100 4 Bond [Cell] 01-Jan-2010 01-Jan-2014 1 0 1 NaN NaN NaN NaN 100 ```

Build a `BDTTree` to price the stepped coupon bonds. Assume the volatility to be 10%

```Sigma = 0.1; BDTTimeSpec = bdttimespec(ValuationDate, EndDates, Compounding); BDTVolSpec = bdtvolspec(ValuationDate, EndDates, Sigma*ones(1, length(EndDates))'); BDTT = bdttree(BDTVolSpec, RS, BDTTimeSpec); % Compute the price of the stepped coupon bonds PBDT = bdtprice(BDTT, ISet) ```
```PBDT = 100.6763 100.7368 100.9266 101.0115 ```