Principles of Financial Computing Course

Principles of Financial Computing

Time: 9:10 ~ 12:10 Wednesday (Spring Semester)
Location: Room 105 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


A single-semester course for the students of the Department of Finance and the Department of Computer Science and Information Engineering.
Required course for the Financial Engineering Track in the Department of Finance's Master's program.


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 high-level 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 self-reading. 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.


Notes [ 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 ]

  1. 2010.02.24
  2. 2010.03.03
  3. 2010.03.10
  4. 2010.03.17
  5. 2010.03.24 & 1st assignment due
  6. 2010.03.31
  7. 2010.04.07 & break & 2nd assignment due
  8. 2010.04.14
  9. 2010.04.21 & 3rd assignment due
  10. 2010.04.28
  11. 2010.05.05
  12. 2010.05.12 & 4th assignment due
  13. 2010.05.19
  14. 2010.05.26
  15. 2010.06.02 & 5th assignment due
  16. 2010.06.09
  17. 2010.06.16 & national holiday
  18. 2010.06.23 & 6th 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. 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! Do program carefully. It is much more important to get the numbers right than to get a pretty user interface running.
  1. Write a program to calculate the forward probabilities of default given the zero-coupon bond prices of a corporation and the riskless zero-coupon bond prices. All times are period-based for convenience. Consult p. 54-55 of the textbook. Note that the algorithm in Fig. 5.9 is errorneous. Inputs: longest maturity n (number of periods), n corporate zero-coupon bond prices (% of par), and n riskless zero-coupon bond prices (% of par). Output: n probabilities pi such that pi denotes the probability that the corporation will default during the i-th period given that the corporation has not defaulted earlier. For example, assume n=4, corporate bond prices are [90, 88, 82, 80], and Treasury bond prices are [95, 93, 88, 86]. The forward probabilities are [0.052632, 0.001195, 0.015238, 0.001702]. Please send your source code, executable code, and an explanation file (e.g., how to run it?) using the CEIBA system (922 U0270)/CEIBA system (723 M9500) before 24:00 AM of March 24, 2010. Compress your files into a single file and name it StudentID_HW_1 for easy reference. Example: R98723054_HW_1. Even if you need to make an appointment with 王釧茹 for demonstration because of the unusual software you use, you still have to submit the files before the deadline.
  2. Write a program to price European and American calls with a time-varying local volatility function s(t) = a0 + a1t. Also output the deltas and gammas. Inputs: S, X, t (year), a0(%), a1(%), r (%), continuous dividend yield q (%), n (number of periods between now and the maturity). For example, suppose S = 40, X = 40, t = 1 (year), s(t) = 0.3 - 0.1t (i.e., a0 = 30(%), a1 = -10(%)), r = 10 (%), and q = 10 (%). For European calls, the price is about 3.615149, the delta is about 0.497959, and the gamma is about 0.035888 (for n = 100). For American calls, the price is about 3.741256, the delta is about 0.522789 and the gamma is about 0.039501 (for n = 100). Please send your source code, executable code, and an explanation file (how to run it? what is the time complexity?) using the CEIBA system (922 U0270)/CEIBA system (723 M9500) before 01:00 AM of April 7, 2010. Compress your files into a single file and name it StudentID_HW_2 for easy reference. Example: R91723054_HW_2. Even if you need to make an appointment with 高國勛 for demonstration because of the unusual software you use, you still have to submit the files before the deadline.
  3. Write a program to price American-style arithmetic Asian puts based on the CRR binomial tree and output the delta. The payoff function is max(X - average, 0). Of course, if the holder exercises early, then average means the running average. Note that running average includes the current stock price. Inputs: S, X, t (year), s (%), r (%), n, and k (number of states per node). For example, when S = 50, X = 50, t = 0.5 (year), s = 30%, r = 10 (%), n = 40, and k = 5, the price is about 3.35244 and the delta is about -0.45572. Please send your source code, executable code, and an explanation file (e.g., how to run it? what is the programming language used? what is the time complexity?) using the CEIBA system (922 U0270)/CEIBA system (723 M9500) before 01:00 AM of April 21, 2010. Compress your files into a single file and name it StudentID_HW_3 for easy reference. Example: R98723054_HW_3. Even if you need to make an appointment with 王釧茹 for demonstration because of the unusual software you use, you still have to submit the files before the deadline.
  4. Write a CRR binomial and a trinomial tree program to price European single-barrier down-and-out calls. Inputs: S, X, barrier H, t (year), s (%), r (%), and n. Assume H < S. For example, the price is about 6.080347 by using the trinomial tree (n=120) and about 6.83853 by using the binomial tree (n=150) when S = 95, X = 100, H = 90, t = 1 (year), s = 20 (%), and r = 10 (%). Please send your source code, executable code, and an explanation file (e.g., how to run it? what is the programming language used? what is the time complexity?) using the CEIBA system (922 U0270)/CEIBA system (723 M9500) before 01:00 AM of May 12, 2010. Compress your files into a single file and name it StudentID_HW_4 for easy reference. Example: R91723054_HW_4. Even if you need to make an appointment with 高國勛 for demonstration because of the unusual software you use, you still have to submit the files before the deadline.
  5. Write a Monte Carlo Simulation program to price 2-asset single-barrier European knock-out puts. Inputs: S1, S2, X, barrier H (on S1), t (year), s1 (%), s2 (%), r (%), r (%), number of paths n, and number of time points (including today) m ( This parameter is not required if the Brownain bridge method is used). The terminal payoff is max((X- (S1 + S2)/2 , 0). Assume H > S1. The option will be knocked out if the price of the asset with the initial price S1 hits the barrier H. For example, with 95% confidence, the price is about 7.72190-7.73593 when S1 = 100, S2 = 100, X = 100, H = 140, t = 1 (year), s1 =30 (%), s2 =35 (%), r = 30 (%), and r = 5 (%). You may experiment with either variance reduction and/or the Brownian bridge method to see if results will converge faster. Please send your source code, executable code, and an explanation file (e.g., how to run it? what is the programming language used?) using the CEIBA system (922 U0270)/CEIBA system (723 M9500) before 01:00 AM of June 2, 2010. Compress your files into a single file and name it StudentID_HW_5 for easy reference. Example: R91723054_HW_5. Even if you need to make an appointment with 王釧茹 for demonstration because of the unusual software you use, you still have to submit the files before the deadline.
  6. Write a program to build a calibrated binomial interest rate tree as in the lecture notes (pp. 823-836). Inputs: the number of period n, the spot rates for period i (%) and the volatility for period s(%). Outputs: the n baseline rates. Suppose the spot rates are [ 3%, 3.4%, 3.6%, 3.7% ] and s =[ 20%, 22%, 24%, 26% ]. Then the baseline rates are about [ 3.00%, 2.98%, 2.30%, 1.60% ]. Please send your source code, executable code, and an explanation file (e.g., how to run it? what is the programming language used? what is the time complexity?) using the CEIBA system (922 U0270)/CEIBA system (723 M9500) before 01:00 AM of June 23, 2010. Compress your files into a single file and name it StudentID_HW_6 for easy reference. Example: R91723054_HW_6. Even if you need to make an appointment with 高國勛 for demonstration because of the unusual software you use, you still have to submit the files before the deadline.

Enrollments