Share with your network!

This blog is an extension of our blog on #CFA Fixed Income: Mortgage Backed Securities: Part 2

Consider a freshly issued MBS with C coupon and that has mortgage loans of 30-year maturity. To value this security, we would perform the following steps:

1. Generate an interest rate path using Hull-White

In the area of financial mathematics, the Hull-White model endeavors to predict future interest rates. It can be of great help in valuing interest rate derivatives or bonds in an open market.

2. Calculate expected principal and interest payment for a given month

3. Using interest rate projections and prepayment model, project cash-flow due to prepayments for the same month

4. Get the total cashflow for the month

5. Similarly, project monthly cash flows for all the 30 years

6. Discount the cashflow to get the present value

7. This value is actually value of the MBS on a given path

Repeat steps 1-7 several times and average the value of MBS to get final value of MBS

 

Let us write a code in R language to value MBS through Two Factor Hull-White Model:

Let’s create a function with two inputs

#WAC – Weighted Average Coupon

MBS_pricing_withPP = function (WAC,r0) {

SYset=c(0.94, 0.76, 0.74, 0.95, 0.98, 0.92, 0.98, 1.1, 1.18, 1.22, 1.23, 0.98);

#Seasonality: Generally, monthly seasonality affects prepayments.

borrow=100;

sigma=0.02;kappa=0.2;rbar=0.06;T=30;#These are CIR model specification

N=200;#We are going to generate 200 simulation paths

n=T*12;#There are in total 12 months in year, each month is a time step

dt=1/12;#Time step is equal to a month

sqrtdt=sqrt(dt);

dz=matrix(rnorm(N*n,0,1),N);

r=matrix(0, N,n);

PV=r;RI=r;BM=r;CPR=r;MP=r;IP=r;SP=r;PP=r;C=r;PVcashflow=r;

Age=array(0,dim=n);

SY=Age;

for (t in 1:n) { # months

if (t>1)

{

r[,t]=r[,t-1]+kappa*(rbar-r[,t-1])*dt+sigma*sqrt(r[,t-1])*dz[,t]*sqrtdt;#CIR r(t)=r(t-1)+dr

}

else

{

r[,1]=r0;#for all paths initial r is set to r0

PV[,1]=borrow;

}

#prepayment part

RI[,t]=0.28+ 0.14*atan(-8.57+430*(WAC-r[,t]));#refinancing Incentive

BM[,t]=0.3+0.7*PV[,t]/borrow;# Burnout Multiplier

Age[t]=min(1,t/30);#Age

if (t%%12==0) { month=12; } else { month=t%%12;}

SY[t]=SYset[month];#Seasonality

CPR[,t]=RI[,t]*BM[,t]*Age[t]*SY[t];#conditional prepayment rate

MP[,t]=PV[,t]*WAC/12/(1-1/(1+WAC/12)^(n-t)); #monthly payment part

IP[,t]=PV[,t]*WAC/12;#Interest Payment

SP[,t]=MP[,t]-IP[,t];#Scheduled Principal payment

PP[,t]=(1-(1-CPR[,t])^(1/12))*(PV[,t]-SP[,t]);# prepayment part

C[,t]=IP[,t]+SP[,t]+PP[,t]; #monthly cash flow

if (t==1) {PVcashflow[,t]=exp(-sum(r[,1:t])*dt)*C[,t];} else {PVcashflow[,t]=exp(-rowSums(r[,1:t])*dt)*C[,t];}

if(t<n) {PV[,t+1]=PV[,t]-(SP[,t]+PP[,t]);}#outstanding balance

}

cashflow_perpath=rowSums(PVcashflow[,1:n-1]);

# outputs

price=mean(cashflow_perpath);

meanCPR=colMeans(CPR[,1:240]);

meanCash=colMeans(PVcashflow[,1:240]);

return(list(price=price, cpr=meanCPR,cash=meanCash));

}

p = MBS_pricing_withPP(0.06,0.04);

print(p$price);

print(p$cpr);

print(p$cash);

Last three steps are for the output and following are the results:

We got the price of the MBS as $105.4626

CPR: Conditional Prepayment Rate