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



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, 2011, 2012, 2013, 2014, 2015 ]

  1. 2015.02.25
  2. 2015.03.04
  3. 2015.03.11 & 1st assignment due
  4. 2015.03.18
  5. 2015.03.25
  6. 2015.04.01 No class & 2nd assignment due
  7. 2015.04.08
  8. 2015.04.15
  9. 2015.04.22 & 3rd assignment due
  10. 2015.04.29
  11. 2015.05.06
  12. 2015.05.13 & 4th assignment due
  13. 2015.05.20
  14. 2015.05.27
  15. 2015.06.03 & 5th assignment due
  16. 2015.06.10
  17. 2015.06.17
  18. 2015.06.24 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.
Treat each homework as an examination.
  1. Write a program to calculate the modified duration and convexity of a cash flow. All numbers are period based for simplicity. Settlement can fall on any time between two cash flows as on p. 71 of the lecture notes. Inputs: (1) y (interest rate), (2) C (cash flow), (3) w (as defined in class). Output: (1) modified duration and (2) convexity. For example, when y = 0.05, C = [1, 2, 3, 101] and w = 0.5, the modified duration is 3.2356 and convexity 13.7300. Please send your source code, executable code, and a brief explanation file if necessary (e.g., how to run it?) using the CEIBA system (922 U0270) before 08:00 AM of March 11, 2015. Compress your files into a single file and name it StudentID_HW_1 for easy reference. Example: R91922054_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 binomial tree program to calculate the call and put prices of European and American options. Inputs: S (stock price at time = 0), X (strike price), s (annual volatility in percentage), t (maturity in years), n (the number of periods), r (interest rate in percentage). For example, suppose S = 100, X = 95, s = 25%, t = 1, n = 300, and r = 3%. For European options, the call price is about 13.9640 and the put price is about 6.1564. For American options, the call price is about 13.9640 and the put price is about 6.3440. Please send your source code, executable code, and a brief explanation file if necessary (e.g., how to run it?) using the CEIBA system (922 U0270) before 08:00 AM of April 2, 2015. No late submissions will be accepted. 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 binomial tree program to calculate the call and put prices of Bermuda options when there are (trading) holidays. For Bermuda options, exercise is possible only for a specific time interval and then only at the close of each trading day during that interval. Assume only Saturdays and Sundays are holidays for simplicity. All dates are in the yyyy-mm-dd format. Inputs: S (stock price at the starting date), X (strike price), s (annual volatility in percentage), T0 (starting date), T1 (maturity date of option), m (the number of periods per day for the tree), r (annual interest rate in percentage), T2 (starting date when option can be exercised). T3 (final date when option can be exercised). For example, suppose S = 100, X = 95, s = 35%, T0 = 2015-04-21, T1 = 2015-06-19, m = 2, r = 0%, T2 = 2015-05-21, and T3 = 2015-06-19. The call price is about 8.4471, and the put price is about 3.4471. Suppose we have the same parameters as above except that r = 10%. Then the call price is about 9.4205, and the put price is about 2.9370. Please send your source code, executable code, and a brief explanation file if necessary (e.g., how to run it?) using the CEIBA system (922 U0270) before 08:00 AM of April 22, 2015. No late submissions will be accepted. Compress your files into a single file and name it StudentID_HW_3 for easy reference. Example: R91723054_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 program to price European-style Asian single-barrier up-and-out calls based on the CRR binomial tree. Output the delta, too. The payoff at expiration date is max(average - X, 0) if the running average never touches or penetrates the barrier and 0 if otherwise. Inputs: S (stock price at time 0), X (strike price), H (barrier, which is higher than S), t (maturity in years), s (%) (annual volatility), r (%) (continuously compounded annual interest rate), n (number of periods), and k (number of states per node). For example, when S = 100, X = 80, H = 130, t = 1 (years), s = 30%, r = 10%, n = 100, and k = 300, the price is about 17.2982 and the delta is about 0.3152. Please send your source code, executable code, and a brief explanation file if necessary (e.g., how to run it?) using the CEIBA system (922 U0270) before 08:00 AM of May 13, 2015. No late submissions will be accepted. 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 2 programs for pricing European binary calls on a non-dividend-paying stock. One uses a trinomial tree, and the other the Monte Carlo method. Output its price, delta, and gamma from both. For trinomial tree, you may use the one on pp. 644-648 of the slides. (If so, the convergence may be slightly better by treating the strike price as the barrier in determining your l). For the Monte Carlo method, one time step suffices as the lecture notes show. If you use any nontrivial ideas in either the trinomial tree or Monte Carlo to improve convergence or accuracy, please write them down in your explaining notes. (Antithetic variates, e.g., will not be considered nontrivial :-) Inputs: S (stock price), X (strike price), r (annual interest rate in percentage), s (annual volatility in percentage), t (year), n (total number of periods), m (number of sample paths of simulation; so an antithetic method will produce twice that number of paths), and e (see pp. 758ff). For example, suppose S = 100, X = 90, r = 5%, s = 40%, t = 2, n = 1000, m = 1000000, and e = 0.001. For the trinomial tree, the price, delta, and gamma are about 0.47805, 0.006262, and -0.00007036, respectively. For Monte Carlo, our price is around [0.48112, 0.48158], our delta is around [0.0039934, 0.0092489], and our gamma is around [-4.796, 5.1489]. Please send your source code, executable code, and a brief explanation file if necessary (e.g., how to run it?) using the CEIBA system (922 U0270) before 08:00 AM of June 3, 2015. No late submissions will be accepted. 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 price an x-year European call option on a zero-coupon bond that matures at year y with a par value of 1 dollar. Use a binomial tree for the Ho-Lee model. Assume the market spot rate curve is r(t) = E - Fe-Gt (annualized and continuously compounded). Inputs: x (year), y (year), s (%) (constant annualized volatility of short rate), E, F, and G, n (the number of time periods of the tree), X (strike price in % of par). For example, the option price is about XXX (% of par) when x = 1, y = 2, E = 0.08, F = 0.05, G = 0.18, s = 10 (%), n = 30, and X = 90 (%). Please send your source code, executable code, and a brief explanation file if necessary (e.g., how to run it?) using the CEIBA system (922 U0270) before 08:00 AM of June 24, 2015. No late submissions will be accepted. 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