Documentation

The option-adjusted spread (OAS) is an amount of extra interest added above (or below if negative) the reference zero curve. To compute the OAS, you must provide the zero curve as an extra input. You can specify the zero curve in any intervals and with any compounding method. (To minimize any error due to interpolation, keep the intervals as regular and frequent as possible.) You must supply a prepayment vector or specify a speed corresponding to a standard PSA prepayment vector.

One way to compute the appropriate zero curve for an agency is to look at its bond yields and bootstrap them from the shortest maturity onwards. You can do this with Financial Toolbox™ functions `zbtprice` and `zbtyield`.

The following example shows how to calculate an appropriate zero curve followed by computation of the pool's OAS. This example calculates the OAS of a 30-year fixed rate mortgage with about a 28-year weighted average maturity left, given an assumption of 0, 50, and 100 PSA prepayment speeds.

Create curve for `zerorates`.

```Bonds = [datenum('11/21/2002') 0 100 0 2 1; datenum('02/20/2003') 0 100 0 2 1; datenum('07/31/2004') 0.03 100 2 3 1; datenum('08/15/2007') 0.035 100 2 3 1; datenum('08/15/2012') 0.04875 100 2 3 1; datenum('02/15/2031') 0.05375 100 2 3 1]; Yields = [0.0162; 0.0163; 0.0211; 0.0328; 0.0420; 0.0501]; ```

Since the above is Treasury data and not selected agency data, a term structure of spread is assumed. In this example, the spread declines proportionally from a maximum of 250 basis points at the shortest maturity.

```Yields = Yields + 0.025 * (1./[1:6]'); ```

Get parameters from `Bonds` matrix.

```Settle = datenum('20-Aug-2002'); Maturity = Bonds(:,1); CouponRate = Bonds(:,2); Face = Bonds(:,3); Period = Bonds(:,4); Basis = Bonds(:,5); EndMonthRule = Bonds(:,6); [Prices, AccruedInterest] = bndprice(Yields, CouponRate, ... Settle, Maturity, Period, Basis, EndMonthRule, [], [], [], [], ... Face); ```

Use `zbtprice` to solve for zero rates.

```[ZeroRatesP, CurveDatesP] = zbtprice(Bonds, Prices, Settle); ZeroCompounding = 2*ones(size(ZeroRatesP)); ZeroMatrix = [CurveDatesP, ZeroRatesP, ZeroCompounding]; ```

Use output from `zbtprice` to calculate the OAS.

```Price = 95; Settle = datenum('20-Aug-2002'); Maturity = datenum('2-Jan-2030'); IssueDate = datenum('2-Jan-2000'); GrossRate = 0.08125; CouponRate = 0.075; Delay = 14; Interpolation = 1; PrepaySpeed = [0; 50; 100]; OAS = mbsprice2oas(ZeroMatrix, Price, Settle, Maturity, ... IssueDate, GrossRate, CouponRate, Delay, Interpolation, ... PrepaySpeed)```
```OAS = 26.0502 28.6348 31.2222 ```

This example shows that one cash flow set is being discounted and solved for its OAS, as contrasted with the `NumberOfPaths` set of cash flows as shown in Mortgage Pool Valuation. Averaging the sets of cash flows resulting from all simulations into one average cash flow vector and solving for the OAS, discounts the averaged cash flows to have a present value of today's (average) price.

While this example uses the mortgage pool price (`mbsprice2oas`) to determine the OAS, you can also use yield to resolve it (`mbsyield2oas`). Also, there are reverse OAS functions that return prices and yields given OAS (`mbsoas2price` and `mbsoas2yield`).

The example also restates earlier examples that show discount securities benefit from higher level of prepayment, keeping everything else unchanged. The relation is reversed for premium securities.