Principles of Financial Computing Course
Principles of Financial Computing
Time: 9:10 ~ 12:10 Friday (Spring Semester)
Location: Room 111 of the CSIE Building
On Wall Street, being right on the fundamentals and
wrong on the timing is the same as just being wrong.
Jonathan Cohen
Where is the risk management at J.P. Morgan Chase?
 Bloomberg News, January 16, 2002
10. Of course, I make a lot investing.
I only teach
so I can help young people.
 Top Ten Lies Finance Professors Tell Their Students
 References
 F. J. Fabozzi,
Fixed Income Mathematics: Analytical & Statistical Techniques. 4th ed. McGrawHill, 2006.
 F. J. Fabozzi and Steven V. Mann (Ed.),
The Handbook of Fixed Income Securities. 8th ed.
Irwin, 2012.

J. C. Hull,
Options, Futures, and Other Derivatives. 9th ed. PrenticeHall, 2014.
 R. Jarrow
and S. Turnbull,
Derivative Securities.
2nd ed.
SouthWestern, 1999.
 S. N. Neftci, Principles of Financial Engineering. 2nd ed.
Academic Press, 2008.
 P.
Ritchken,
Derivative Markets: Theory, Strategy, and Applications.
HarperCollins, 1996.
 S. M. Sundaresan,
Fixed Income Markets and Their Derivatives. 3rd ed.
Academic Press, 2009.
 Articles

The Financial Modelers' Manifesto

Goldman Sachs Is a Tech Company (April 12, 2015)

The Medallion Fund, an EmployeesOnly Offering for the Quants at Renaissance Technologies, Is the Blackest Box in all of Finance (November 21, 2016)

The Most Indemand Programming Languages on Wall Street (January 28, 2015)

The Top Ten Technology Skills at BAML, Barclays, Credit Suisse, Citi, Goldman Sachs, JPMorgan, Morgan Stanley and UBS (April 16, 2015)
 Internet Resources
 Teaching Assistant(s)
 Software
To Students,
You will learn a perhaps different perspective on finance,
especially as it pertains to pricing and software engineering.
Our emphasis on computation should add a new dimension and
toolbox to your existing knowledge and financial sense.
(But see Enrollments below.)
It is your
responsibility to learn to write in highlevel programming
languages. We cannot impart that skill in the class.
If the mathematics proves hard going, you are expected to
fill in the gap by selfreading. The technicalities are not
beyond a motivated graduate student's reach.
The major topics covered in the course, time permitting, are listed
below for your reference.
 Time value of money
 Bonds, mortgages, and annuities
 Duration, convexity, and
immunization
 Yield curve,
forward rate, and spot rate
 Option pricing theory
and its wideranging applications
 BlackScholes analysis
 binomial option pricing model (BOPM)
 Futures,
forwards, and other derivatives
 The combinatorics of random walks

Martingale,
Brownian motion,
stochastic calculus, and
Ito integral
 Riskneutral valuation
 Risk management
 Fixedincome securities with embedded options
and interest rate derivatives
 Mortgagebacked securities (MBS)
 Numerical methods
 Monte Carlo methods
 Variance reduction (efficiencyimproving) techniques
 Leastsquares technique
 QuasiMonte Carlo method
 Solving partial differential equations
 Yield curve fitting
 GARCH models
 Interest rate models and
calibration

2024.02.23

2024.03.01

2024.03.08

2024.03.15

2024.03.22
& 1st assignment due

2024.03.29

2025.04.05
holiday

2024.04.12

2024.04.19
& 2nd assignment due

2024.04.26

2024.05.03

2024.05.10
& 3rd assignment due

2024.05.17

2024.05.24

2024.05.31

2024.06.07
& 4th assignment due
Programming Exercises
Homework should be turned in on time. No late
homework will be accepted without legitimate reasons.
There will be four to six programming
assignments.
Treat each homework as an examination.

You are expected to write your own
codes and turn in your source code.

Do not copy or collaborate with fellow students.

Never ask your friends to write programs for you.

Never give your code to other students or publish your code because it may be copied
and you in turn may be suspected of copying other's code!
The graders will not attempt to sort out who the original coders are because we are not running a court here.

Do program carefully.
It is much more important to get the numbers right than to get a
pretty user interface running.


Write a program to generate an amortization schedule for repaying a loan.
There are two interest rates.
Inputs:
(1) L (loan amount in dollars),
(2) r_{1} (annual interest rate in percent for the first n_{1} periods, so 12 instead of 0.12),
(3) r_{2} (annual interest rate in percent for the remaining periods),
(4) n_{1} (number of periods when the interest rate is r_{1}),
(5) n (duration of the loan in years), and
(6) m (the number of payments per annum).
Output: A csv file for the amortization schedule and the total interest paid.
The schedule shall have five columns:
(1) Time (0, 1, 2, ...),
(2) The level payment amount,
(3) Interest (the interest part of each payment),
(4) Principal (the principal part of each payment), and
(5) Remaining principal.
For example, if L = 10,000,000, r_{1} = 8%, r_{2} = 3%,
n_{1} = 120, n = 20, and m = 12,
the example output file is here and the total interest is 8593339.37.
IMPORTANT notes:
(1) The Time column must be integers (no floatingpoint numbers).
(2) The Payment, Interest, Principal, and Remaining principal columns must be floatingpoint numbers up to 2 decimal points.
(3) The order of the columns must be respected.
(4) The headers of the columns must be as in the sample file.
(5) Start from Time 0 instead of Time 1. This means the value of the first row will be 0, 0, 0, 0, L.
Please send your source code, executable code, and a brief explanation file if necessary (e.g., how to run it?) using NTU COOL before 08:00 AM of March 17, 2023.
No late submissions will be accepted. Compress your files into a single file and name it StudentID_HW_1 for easy reference. Example: R91922054_HW_1.
If Python is not your programming language
please demonstrate your code to 盧與明 during the office hour or make an appointment with him to do so.
(You still have to submit the files before the deadline.)

Write a binomial tree program to price a Bermudan option.
The early exercise time points are T/4 and 3T/4 from now,
where T is the time to maturity. The payoff function is max(K  S + 1,0).
Inputs:
(1) S (stock price),
(2) K (strike price),
(3) r (annual interest rate continuously compounded),
(4) s (annual volatility),
(5) T (time to maturity in years),
(6) n (number of time steps).
Output: Option price.
For example, suppose that S = 100, K = 100, r = 5 (%), s = 30 (%), and T = 0.5 (years). The option price is about 7.8052 at n = 100 and 7.8015 at n = 200.
IMPORTANT NOTES:
(1) The interest rate and volatility should be in percent. For example, if the interest rate is 5% and volatility 30%, the inputs are 5 and 30, respectively.
(2) No need to make sure the early exercise dates are aligned with time steps of the tree.
Please send your source code, executable code, and a brief explanation file if necessary
(e.g., how to run it?) using NTU COOL before 08:00 AM
of April 14, 2022.
No late submissions will be accepted. Compress your files into a single file and name it StudentID_HW_2 for easy reference. Example: R91922054_HW_2.
If Python is not your programming language, please demonstrate your code to 盧與明 during the office hour or make an appointment with him to do so.
(You still have to submit the files before the deadline.)

Write a trinomial tree program to price a downandout barrier call.
Inputs:
(1) S (stock price),
(2) K (strike price),
(3) r (interest rate),
(4) s (annual volatility),
(5) T (time to maturity in years),
(6) H (barrier), and
(7) n (number of time steps).
Output: Option price.
For example, suppose that S = 95, K = 100, r = 10 (%), s = 25 (%), H = 90, and T = 1. The option price is about 5.9899 at n = 75 and 5.9977 at n = 400.
IMPORTANT notes:
(1) The interest rate and volatility should be in percent. For example, if the interest rate is 5% and volatility 30%, the inputs are 5 and 30, respectively.
(2) The trinomial tree must matches the barrier.
Please send your source code, executable code, and a brief explanation file if necessary
(e.g., how to run it?) using NTU COOL before 08:00 AM
of May 12, 2022.
No late submissions will be accepted. Compress your files into a single file and name it StudentID_HW_3 for easy reference. Example: R91922054_HW_3.
If Python is not your programming language, please demonstrate your code to 盧與明 during the office hour or make an appointment with him to do so.
(You still have to submit the files before the deadline.)

Implement the Least Square Monte Carlo method to price an American option. Use 1, x, x^{2}, x^{3} as the basis functions.
(1) S (stock price),
(2) K (strike price),
(3) r (interest rate),
(4) s (volatility),
(5) T (time to maturity in years),
(6) n (number of time steps),
(7) N (number of simulation paths).
Output: Option price and the standand error.
IMPORTANT notes:
(1) The interest rate and volatility should be in percent. For example, if the interest rate is 1% and volatility 10%, the inputs are 1 and 10, respectively.
Please send your source code, executable code, and a brief explanation file if necessary
(e.g., how to run it?) using NTU COOL before 08:00 AM
of June 9, 2022.
No late submissions will be accepted. Compress your files into a single file and name it StudentID_HW_4 for easy reference. Example: R91922054_HW_4.
If Python is not your programming language, please demonstrate your code to 盧與明 during the office hour or make an appointment with him to do so.
(You still have to submit the files before the deadline.)
Enrollments

Nonprogrammers will be strongly discouraged
as the probability of passing this course is slim,
if possible at all.

It is not impossible to pick up programming skills before
the first assignment.

Financial knowledge is a plus, but again it can be picked up if you are motivated.