# mbsprice

Mortgage-backed security price given yield

## Syntax

``[Price,AccrInt] = mbsprice(Yield,Settle,Maturity,IssueDate,GrossRate)``
``[Price,AccrInt] = mbsprice(___CouponRate,Delay,PrepaySpeed,PrepayMatrix)``

## Description

example

````[Price,AccrInt] = mbsprice(Yield,Settle,Maturity,IssueDate,GrossRate)` computes a mortgage-backed security price, given time information and mortgage yield at settlement.```

example

````[Price,AccrInt] = mbsprice(___CouponRate,Delay,PrepaySpeed,PrepayMatrix)` specifies options using one or more optional arguments in addition to the input arguments in the previous syntax. ```

## Examples

collapse all

This example shows how to determine the mortgage-backed security price given a mortgage-backed security with the following characteristics.

```Yield = 0.0725; Settle = datetime(2002,4,15); Maturity = datetime(2030,1,1); IssueDate = datetime(2000,1,1); GrossRate = 0.08125; CouponRate = 0.075; Delay = 14; Speed = 100; [Price AccrInt] = mbsprice(Yield, Settle, Maturity, IssueDate,... GrossRate, CouponRate, Delay, Speed)```
```Price = 101.3147 ```
```AccrInt = 0.2917 ```

This example shows how to determine the mortgage-backed security price, given a mortgage-backed security, and `PrePaytMatrix` with the following characteristics:

```Yield = 0.0725; Settle = datetime(2002,4,15); Maturity = datetime(2030,1,1); IssueDate = datetime(2000,1,1); GrossRate = 0.08125; PrepayMatrix = 0.005*ones(360,1); [Price AccrInt] = mbsprice(Yield, Settle, Maturity, IssueDate,... GrossRate, PrepayMatrix)```
```Price = 360×1 34.8583 34.8583 34.8583 34.8583 34.8583 34.8583 34.8583 34.8583 34.8583 34.8583 ⋮ ```
```AccrInt = 360×1 0.0194 0.0194 0.0194 0.0194 0.0194 0.0194 0.0194 0.0194 0.0194 0.0194 ⋮ ```

## Input Arguments

collapse all

Mortgage yield compounded monthly, specified as an `NMBS`-by-`1` vector using decimal values.

Data Types: `double`

Settlement date, specified as an `NMBS`-by-`1` vector using a datetime array, string array, or date character vectors. `Settle` must be earlier than `Maturity`.

To support existing code, `mbsprice` also accepts serial date numbers as inputs, but they are not recommended.

Maturity date, specified as an `NMBS`-by-`1` vector using a datetime array, string array, or date character vectors.

To support existing code, `mbsprice` also accepts serial date numbers as inputs, but they are not recommended.

Issue date, specified as an `NMBS`-by-`1` vector using a datetime array, string array, or date character vectors.

To support existing code, `mbsprice` also accepts serial date numbers as inputs, but they are not recommended.

Gross coupon rate (including fees), specified as an `NMBS`-by-`1` vector of decimal values.

Data Types: `double`

(Optional) Net coupon rate, specified as an `NMBS`-by-`1` vector of decimal values.

Data Types: `double`

(Optional) Delay (in days) between payment from homeowner and receipt by bondholder, specified as an `NMBS`-by-`1` vector.

Data Types: `double`

(Optional) Speed relative to PSA standard, specified as an `NMBS`-by-`1` vector. The PSA standard is `100`.

Note

Set the `PrepaySpeed` to `[]` if you input a customized `PrepayMatrix`.

Data Types: `double`

(Optional) Customized prepayment vector, specified as a `NaN`-padded matrix of size `max(TermRemaining)`-by-`NMBS`. Each column corresponds to each mortgage-backed security, and each row corresponds to each month after settlement.

Note

Use `PrepayMatrix` only when `PrepaySpeed` is unspecified.

Data Types: `double`

## Output Arguments

collapse all

Clean price for every \$100 face value of the securities, returned as a `NMBS`-by-`1` vector.

Accrued interest of the mortgage-backed securities, returned as a `NMBS`-by-`1` vector.

 PSA Uniform Practices, SF-49