Lectures 1 & 2: MATLAB basics and programming
Lecture 2 Continued: More MATLAB basics and programming
Computational Finance
See Run_DailyReturn_and_Vol.m
Example: IBM Daily Returns From Data
Use an array of true/false to extract elements out of another array
v1 = [ 4, 7, 11, 23];
v2 = [ true, false, false, true];
v1(v2) outputs [4, 23]
The elements in v1 that correspond to true in v2
Useful way to extract elements of an array that match a certain condition
Recall: v1 > 10 returns [false, false, true, true]
So v1(v1 > 10) returns [11, 23]
Logical Indexing
Demo
Mortgage Amortization Schedule
Suppose you are buying a house for $513,500
You can afford a down payment up to $150,000 and expect to live in the house for approximately 5 years
You contact the bank for a 30-year fixed rate mortgage and get the following rate schedule:
LTV up to 80%: 0 points, 2.65% annual rate
LTV up to 80%: 1 point, 2.5% annual rate
LTV above 80%: 0 points, 2.9% annual rate
Terminology:
LTV (“loan to value”): loan amount / house value = 1 – down payment / house value
Point: percent of the loan amount payable as a fee when borrowing
How do you pick your down payment and loan?
How to pick a mortgage?
Choice of mortgage affects
How much you must pay today
How much you must pay every month going forward
Remaining principal balance when you sell
Payment today = down payment + fees
Monthly payment depends on the annuity formula
What is the payment that needs to be made every month for the next 30 years such that the sum of present values of all the payments discounted at the mortgage rate equals the loan amount?
What is N? r? ?
Constructing an Amortization Schedule
Choice of mortgage affects
How much you must pay today
How much you must pay every month going forward
Remaining principal balance when you sell
Remaining principal balance depends on how much principal you have already repaid through your monthly payments?
How much of your monthly payments go towards principal? How much go towards interest? Keeps changing even though monthly payment stays fixed! Need to construct an amortization schedule:
Payment PMT
Month 1
Interest component:
Principal component: reduces principal so that )
Month 2
Interest component
Principal component: reduces principal so that )
As time goes by, is the interest component getting bigger? Is principal?
Let’s build this in MATLAB
Constructing an Amortization Schedule
Oct 2018Jan 2019Apr 2019Jul 2019
100
110
120
130
140
150
160
P
r
i
c
e
(
$
)
IBM Daily Prices
Adjusted Close
High
Low
Close
Oct 2018Jan 2019Apr 2019Jul 2019
-8
-6
-4
-2
0
2
4
6
8
10
D
a
i
l
y
r
e
t
u
r
n
(
%
)
IBM Adjusted Daily Returns
/docProps/thumbnail.jpeg