Documentation

## CMO Workflow

In general, the CMO workflow is:

1. Calculate underlying mortgage cash flows.

2. Define CMO tranches

3. If using a PAC or TAC CMO, calculate the principal schedule.

4. Calculate cash flows for each tranche.

5. Analyze the CMO by computing price, yield, spread of CMO cash flows.

### Calculate Underlying Mortgage Cash Flows

Underlying mortgage pool pass-through cash flows are calculated by the existing function `mbspassthrough`. The CMO cash flow functions require the principal payments (including prepayments) calculated from existing functions `mbspassthrough` or `mbscfamounts`.

```principal = 10000000; coupon = 0.06; terms = 360; psa = 150; [principal_balance, monthly_payments, sched_principal_payments,... interest_payments, prepayments] = mbspassthrough(principal,... coupon, terms, terms, psa, []); principal_payments = sched_principal_payments.' + prepayments.'; ```

After determining principal payments for the underlying mortgage collateral, you can generate cash flows for a sequential CMO, with or without a Z-bond, by using `cmoseqcf`. For a PAC or TAC CMO, the cash flows are generated using `cmoschedcf`

### Define CMO Tranches

Define CMO tranche; for example, define a CMO with two tranches:

```TranchePrincipals = [500000; 500000]; TrancheCoupons = [0.06; 0.06];```

### If Using a PAC or TAC CMO, Calculate Principal Schedule

Calculate the PAC/TAC principal balance schedule based on a band of PSA speeds. For scheduled CMOs (PAC/TAC), the CMO cash flow functions additionally take in the principal balance schedule calculated by the CMO schedule function `cmosched`.

```speed = [100 300]; [balanceSchedule, initialBalance] = cmosched(principal, coupon,... terms, terms, speed, TranchePrincipals(1));```

### Calculate Cash Flows for Each Tranche

You can reuse the output from the cash flow generation functions to further divide the cash flows into tranches. For example, the output from `cmoschedcf` for a PAC tranche can be divided into sequential tranches by passing the principal cash flows of the PAC tranche into the `cmoschedcf` function. The outputs of the CMO cash flow functions are the principal and interest cash flows, and the principal balance.

```[principal_balances, principal_cashflows, interest_cashflows] = cmoschedcf(principal_payments,... TranchePrincipals, TrancheCoupons, balanceSchedule); ```

### Analyze CMO by Computing Price, Yield, and Spread of CMO Cash Flows

The outputs from the CMO functions (`cmoseqcf` and `cmoschedcf`) are cash flows. The functions used to analyze a CMO are based on these cash flows. To that end, you can use `cfbyzero`, `cfspread`, `cfyield`, and `cfprice` to compute prices, yield, and spreads for the CMO cash flows. In addition, using the following, you can calculate a weighted average life (WAL) for each tranche in the CMO:

`$WAL=\sum _{i=1}^{n}\frac{{P}_{i}}{P}{t}_{i}$`

where:

P is the total principal.

Pi is the principal repayment of the coupon i.

$\frac{{P}_{i}}{P}$ is the fraction of the principal repaid in coupon i.

ti is the time in years from the start to coupon i.