• 沒有找到結果。

Class Information

N/A
N/A
Protected

Academic year: 2022

Share "Class Information"

Copied!
57
0
0

加載中.... (立即查看全文)

全文

(1)

Principles of Financial Computing

Prof. Yuh-Dauh Lyuu

Dept. Computer Science & Information Engineering and

Department of Finance National Taiwan University

(2)

Introduction

(3)

You must go into finance, Amory.

— F. Scott Fitzgerald (1896–1940), This Side of Paradise (1920) The two most dangerous words in Wall Street vocabulary are “financial engineering.”

— Wilbur Ross (2007)

(4)

Class Information

• Yuh-Dauh Lyuu. Financial Engineering & Computation:

Principles, Mathematics, Algorithms. Cambridge University Press, 2002.

• Official Web page is

www.csie.ntu.edu.tw/~lyuu/finance1.html – Lecture notes will be uploaded before class.

– Homeworks and teaching assistants will also be announced there.

– Do not mistake last year’s homeworks for this year’s!

(5)

Class Information (continued)

• Check

www.csie.ntu.edu.tw/~lyuu/capitals.html for some of the software.

• Check the CBIS (Convertible Bond Information System) at

http://www.cb.idv.tw/cb/

for a convertible-bond software system.a

aThanks to Prof. Gow-Hsing King and his strong team.

(6)

Class Information (concluded)

• Please ask many questions in class.

– This is the best way for me to remember you in a large class.a

• No roll calls.

a“[A] science concentrator [...] said that in his eighth semester of [Harvard] college, there was not a single science professor who could identify him by name.” (New York Times, September 3, 2003.)

(7)

Grading

• 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.

(8)

What This Course Is About

• Financial theories in pricing.

• Mathematical backgrounds.

• Derivative securities.

• Pricing models.

• Efficient algorithms in pricing financial instruments.

• Research problems.

• Help in finding your thesis directions.

(9)

What This Course Is Not About

• How to program.a

– A software bug cost Knight Capital Group, Inc.

US$457.6 million on August 1, 2012.b

• Basic calculus, probability, combinatorics, and algebra.

• Details of the financial markets.

• How to be rich.

• How the markets will perform tomorrow.

• Professional behavior.

ahttp://www.csie.ntu.edu.tw/train/

bKirilenko and Lo (2013).

(10)

Useful Journals

• Applied Mathematical Finance.

• Communications on Pure and Applied Methematics.

• European Journal of Finance.

• European Journal of Operational Research.

• Finance and Stochastics.

• Financial Analysts Journal.

• International Journal of Finance & Economics.

• International Journal of Theoretical and Applied Finance.

(11)

Useful Journals (continued)

• Journal of Computational Finance.

• Journal of Derivatives.

• Journal of Economic Dynamics & Control.

• Journal of Finance.

• Journal of Financial Economics.

• Journal of Fixed Income.

• Journal of Futures Markets.

• Journal of Financial and Quantitative Analysis.

• Journal of Portfolio Management.

• Journal of Real Estate Finance and Economics.

(12)

Useful Journals (concluded)

• Journal of Risk and Uncertainty.

• Management Science.

• Mathematical Finance.

• Quantitative Finance.

• Review of Financial Studies.

• Review of Derivatives Research.

• Risk Magazine.

• SIAM Journal on Financial Mathematics.

• Stochastics and Stochastics Reports.

(13)

The Modelers’ Hippocratic Oath

a

• I will remember that I didn’t make the world, and it doesn’t satisfy my equations.

• Though I will use models boldly to estimate value, I will not be overly impressed by mathematics.

• I will never sacrifice reality for elegance without explaining why I have done so.

• Nor will I give the people who use my model false comfort about its accuracy. Instead, I will make explicit its

assumptions and oversights.

• I understand that my work may have enormous effects on society and the economy, many of them beyond my

comprehension.

aEmanuel Derman and Paul Wilmott, January 7, 2009.

(14)

Total Outstanding Notional Amount of OTC

Derivatives in G10 and Switzerland

(15)

Analysis of Algorithms

(16)

I can calculate the motions of the heavenly bodies, but not the madness of people.

— Isaac Newton (1642–1727)

It is unworthy of excellent men to lose hours like slaves in the labor of computation.

— Gottfried Wilhelm Leibniz (1646–1716)

(17)

Computability and Algorithms

• Algorithms are precise procedures that can be turned into computer programs.

• Uncomputable problems.

– Does this program have infinite loops?

– Is this program bug free?

• Computable problems.

– Intractable problems.

– Tractable problems.

(18)

Complexity

• A set of basic operations are assumed to take one unit of time (+,−, ×, /, log, xy, ex, . . . ).

• The total number of these operations is the total work done by an algorithm (its computational complexity).

• The space complexity is the amount of memory space used by an algorithm.

• Concentrate on the abstract complexity of an algorithm instead of its detailed implementation.

• Complexity is a good guide to an algorithm’s actual running time.

(19)

Common (Asymptotic) Complexities

• Let n stand for the “size” of the problem.

– Number of elements, number of cash flows, number of time periods, etc.

• Linear time if the complexity is O(n).

• Quadratic time if the complexity is O(n2).

• Cubic time if the complexity is O(n3).

• Superpolynomial if the complexity is higher than polynomials, say 2O(n ).a

• Exponential time if the complexity is 2O(n).

aE.g., Dai (B82506025, R86526008, D8852600) and Lyuu (2007), Lyuu and Wang (F95922018) (2011), and Chiu (R98723059) (2012).

(20)

Basic Financial Mathematics

(21)

In the fifteenth century mathematics was mainly concerned with questions of commercial arithmetic and the problems of the architect.

— Joseph Alois Schumpeter (1883–1950)

I’m more concerned about the return of my money than the return on my money.

— Will Rogers (1879–1935)

(22)

The Time Line

-

Time 0 Time 1 Time 2 Time 3 Time 4

Period 1 Period 2 Period 3 Period 4

(23)

Time Value of Money

a

FV = PV(1 + r)n, (1)

PV = FV × (1 + r)−n.

• FV (future value).

• PV (present value).

• r: interest rate.

aFibonacci (1170–1240) and Irving Fisher (1867–1947).

(24)

Periodic Compounding

• Suppose the annual interest rate r is compounded m times per annum.

• Then

1 

1 + r m

 

1 + r m

2



1 + r m

3

→ · · ·

• Hence, after n years,

FV = PV



1 + r m

nm

. (2)

(25)

Common Compounding Methods

• Annual compounding: m = 1.

• Semiannual compounding: m = 2.

• Quarterly compounding: m = 4.

• Monthly compounding: m = 12.

• Weekly compounding: m = 52.

• Daily compounding: m = 365.

(26)

Easy Translations

• An annual interest rate of r compounded m times a year is “equivalent to” an interest rate of r/m per 1/m year.

• If a loan asks for a return of 1% per month, the annual interest rate will be 12% with monthly compounding.

(27)

Example

• Annual interest rate is 10% compounded twice per annum.

• Each dollar will grow to be

[ 1 + (0.1/2) ]2 = 1.1025 one year from now.

• The rate is “equivalent to” an interest rate of 10.25%

compounded once per annum,

1 + 0.1025 = 1.1025

(28)

Continuous Compounding

a

• Let m → ∞ so that



1 + r m

m

→ er in Eq. (2) on p. 24.

• Then

FV = PV × ern, where e = 2.71828 . . . .

aJacob Bernoulli (1654–1705) in 1685.

(29)

Continuous Compounding (concluded)

• Continuous compounding is easier to work with.

• Suppose the annual interest rate is r1 for n1 years and r2 for the following n2 years.

• Then the FV of one dollar will be er1n1+r2n2 after n1 + n2 years.

(30)

Conversion between Compounding Methods

• Suppose r1 is the annual rate with continuous compounding.

• Suppose r2 is the equivalent rate compounded m times per annum.

• How are they related?

(31)

Conversion between Compounding Methods (concluded)

• Principle: Both interest rates must produce the same amount of money after one year.

• That is, 

1 + r2 m

m

= er1.

• Therefore,a

r1 = m ln



1 + r2 m

 , r2 = m



er1/m − 1 .

aAre they really equivalent? In what sense are they equivalent?

(32)

The PV Formula

• The PV of the cash flow C1, C2, . . . , Cn at times 1, 2, . . . , n is

PV = C1

1 + y + C2

(1 + y)2 + · · · + Cn

(1 + y)n . (3)

• This formula and its variations are the engine behind most of financial calculations.a

– What is y?

– What are Ci? – What is n?

• It will be justified on p. 201.

aCochrane (2005), “Asset pricing theory all stems from one simple

(33)

An Algorithm for Evaluating PV in Eq. (3)

1: x := 0;

2: for i = 1, 2, . . . , n do

3: x := x + Ci/(1 + y)i;

4: end for

5: return x;

• The algorithm takes time proportional to

n

i=1 i = O(n2).a

• Can improve it to O(n) if you apply ab = eb ln a in step 3.b

aIf only +,−, ×, and / are allowed.

bRecall that we count xy as taking one unit of time.

(34)

Another Algorithm for Evaluating PV

1: x := 0;

2: d := 1 + y;

3: for i = n, n − 1, . . . , 1 do

4: x := (x + Ci)/d;

5: end for

6: return x;

(35)

Horner’s Rule: The Idea Behind p. 34

• This idea is



· · ·

 Cn

1 + y + Cn−1

 1

1 + y + Cn−2

 1

1 + y + · · ·

 1

1 + y.

– Due to Horner (1786–1837) in 1819.

• The algorithm takes O(n) time.

• It is the most efficient possible in terms of the absolute number of arithmetic operations.a

aBorodin and Munro (1975).

(36)

Annuities

a

(Certain)

• An annuity pays out the same C dollars at the end of each year for n years.

• With a rate of r, the FV at the end of the nth year is

n−1

i=0

C(1 + r)i = C (1 + r)n − 1

r . (4)

aJan de Witt (1625–1672) in 1671 and Nicholas Bernoulli (1687–1759) in 1709.

(37)

General Annuities

• If m payments of C dollars each are received per year (the general annuity), then Eq. (4) becomes

C

1 + mr nm

− 1

mr

.

• The PV of a general annuity is PV =

nm i=1

C



1 + r m

−i

= C 1 

1 + mr −nm

mr

.

(5)

(38)

Amortization

• It is a method of repaying a loan through regular payments of interest and principal.

• The size of the loan (the original balance) is reduced by the principal part of each payment.

• The interest part of each payment pays the interest incurred on the remaining principal balance.

• As the principal gets paid down over the term of the loan, the interest part of the payment diminishes.

• From Eq. (5) on p. 37, the monthly payment equals C = loan amount × mr

1 

1 + r −nm. (6)

(39)

Example: Home Mortgage

• By paying down the principal consistently, the risk to the lender is lowered.

• When the borrower sells the house, only the remaining principal is due the lender.

• Consider the equal-payment case, i.e., fixed-rate, level-payment, fully amortized mortgages.

– They are called traditional mortgages in the U.S.

(40)

A Numerical Example

• Consider a 15-year, $250,000 loan at 8.0% interest rate.

• Solve Eq. (5) on p. 37 with PV = 250000, n = 15, m = 12, and r = 0.08.

• That is,

250000 = C 1 

1 + 0.0812 −15×12

0.0812

.

• This gives a monthly payment of C = 2389.13.

(41)

The Amortization Schedule

Month Payment Interest Principal Remaining principal 250,000.000 1 2,389.13 1,666.667 722.464 249,277.536 2 2,389.13 1,661.850 727.280 248,550.256 3 2,389.13 1,657.002 732.129 247,818.128

· · ·

178 2,389.13 47.153 2,341.980 4,730.899 179 2,389.13 31.539 2,357.591 2,373.308

180 2,389.13 15.822 2,373.308 0.000

Total 430,043.438 180,043.438 250,000.000

(42)

A Numerical Example (continued)

In every month:

• The principal and interest parts add up to $2,389.13.

• The remaining principal is reduced by the amount indicated under the Principal heading.a

• The interest is computed by multiplying the remaining balance of the previous month by 0.08/12.

aThis column varies with r. Thanks to a lively class discussion on Feb 24, 2010. In fact, every column varies with r. Contributed by Ms.

Wu, Japie (R01921056) on February 20, 2013.

(43)

A Numerical Example (concluded)

Note that:

• The Principal column adds up to $250,000.

• The Payment column adds up to $430,043.438!

• If the borrower plans to pay off the mortgage right after the 178th month’s monthly payment, he needs to pay another $4,730.899.a

aContributed by Ms. Wu, Japie (R01921056) on February 20, 2013.

(44)

Method 1 of Calculating the Remaining Principal

• A month’s principal payment = monthly payment − (previous month’s remaining principal) × (monthly interest rate).

• A month’s remaining principal = previous month’s remaining principal − principal payment calculated above.

• Generate the amortization schedule until you reach the particular month you are interested in.

(45)

Method 1 of Calculating the Remaining Principal (concluded)

• This method is relatively slow but is universal in its applicability.

• It can, for example, accommodate prepayments and variable interest rates.

(46)

Method 2 of Calculating the Remaining Principal

• Right after the kth payment, the remaining principal is the PV of the future nm − k cash flows,

nm−k

i=1

C



1 + r m

−i

= C 1 

1 + mr −nm+k

mr

. (7)

• This method is much faster.

• But it is more limited in applications because it makes more assumptions.

(47)

Yields

• The term yield denotes the return of investment.

• Two widely used yields are the bond equivalent yield (BEY) and the mortgage equivalent yield (MEY).

• Recall Eq. (2) on p. 24: FV = PV

1 + mr nm .

• BEY corresponds to the r above that equates PV with FV when m = 2.

• MEY corresponds to the r above that equates PV with FV when m = 12.

• Again, although BEY and MEY might be different, they nevertheless mean the same yield.

(48)

Internal Rate of Return (IRR)

• It is the yield y which equates an investment’s PV with its price P ,

P = C1

(1 + y) + C2

(1 + y)2 + C3

(1 + y)3 + · · · + Cn (1 + y)n .

• IRR assumes all cash flows are reinvested at the same rate as the internal rate of return because:

FV = C1(1 + y)n−1+C2(1 + y)n−2+C3(1 + y)n−3+· · ·+Cn.

• So it must be used with extreme caution.

(49)

Numerical Methods for IRRs

• Define

f (y)

n t=1

Ct

(1 + y)t − P.

– P is the market price.

• Solve f(y) = 0 for a real y ≥ −1.a

• f(y) is monotonically decreasing in y if Ct > 0 for all t.

• So a unique real-number solution exists for this f(y).

aNegative interest rates became a reality for German and Swiss bonds in 2015. In 2016, Sweden, Denmark, and Japan imposed negative interest rates on excess reserves. Even so, −100% should be a natural lower bound because why would anyone or financial institution want to have every cent confiscated by a bank?

(50)

The Bisection Method

• Start with a and b where a < b and f(a) f(b) < 0.

• Then f(ξ) must be zero for some ξ ∈ [ a, b ].

• If we evaluate f at the midpoint c ≡ (a + b)/2, either (1) f (c) = 0, (2) f (a) f (c) < 0, or (3) f (c) f (b) < 0.

• In the first case we are done, in the second case we

continue the process with the new bracket [ a, c ], and in the third case we continue with [ c, b ].

• The bracket is halved in the latter two cases.

• After n steps, we will have confined ξ within a bracket of length (b − a)/2n.

(51)

, . -

(52)

The Newton-Raphson Method

• It converges faster than the bisection method.

• Start with a first approximation x0 to a root of f (x) = 0.

• Then

xk+1 ≡ xk f (xk) f(xk).

• When computing yields, f(x) =

n t=1

tCt

(1 + x)t+1. (8)

(53)

xk xk 

x y

f x 

(54)

The Secant Method

• A variant of the Newton-Raphson method.

• Replace differentiation with difference.

• Start with two approximations x0 and x1.

• Then compute the (k + 1)st approximation with xk+1 = xk f (xk)(xk − xk−1)

f (xk) − f(xk−1) .

• Note that it is easier to calculate

[ f (xk) − f(xk−1) ]/(xk − xk−1) than the f(xk) on p. 52.

(55)

The Secant Method (concluded)

• Its convergence rate is 1.618.

• This is slightly worse than the Newton-Raphson method’s 2.

• But the secant method does not need to evaluate f(xk) needed by the Newton-Raphson method.

• This saves about 50% in computation efforts per iteration.

• The convergence rate of the bisection method is 1.

(56)

Solving Systems of Nonlinear Equations

• It is not easy to extend the bisection method to higher dimensions.

• But the Newton-Raphson method can be extended to higher dimensions.

• Let (xk, yk) be the kth approximation to the solution of the two simultaneous equations,

f (x, y) = 0, g(x, y) = 0.

(57)

Solving Systems of Nonlinear Equations (concluded)

• The (k + 1)st approximation (xk+1, yk+1) satisfies the following linear equations,

∂f (x∂xk,yk) ∂f (x∂yk,yk)

∂g(xk,yk)

∂x ∂g(xk,yk)

∂y

Δxk+1 Δyk+1

⎦ = −

f(xk, yk) g(xk, yk)

⎦ ,

where unknowns Δxk+1 ≡ xk+1 − xk and Δyk+1 ≡ yk+1 − yk.

• The above has a unique solution for (Δxk+1, Δyk+1) when the 2 × 2 matrix is invertible.

• Finally, set

xk+1 = xk + Δxk+1, yk+1 = yk + Δyk+1.

參考文獻

相關文件

Society for Industrial and Applied Mathematics E-journals.

A theoretical and reflexive study on cultivating literacy of mathematical culture by using lesson plans from humanistic mathematics.. Taiwan Journal of Mathematics Education,

In this paper, we build a new class of neural networks based on the smoothing method for NCP introduced by Haddou and Maheux [18] using some family F of smoothing functions.

Qi (2001), Solving nonlinear complementarity problems with neural networks: a reformulation method approach, Journal of Computational and Applied Mathematics, vol. Pedrycz,

Huang, A nonmonotone smoothing-type algorithm for solv- ing a system of equalities and inequalities, Journal of Computational and Applied Mathematics, vol. Hao, A new

Wallace (1989), &#34;National price levels, purchasing power parity, and cointegration: a test of four high inflation economics,&#34; Journal of International Money and Finance,

Administrative Science Quarterly Journal of Accountingand Economics Journal of Accounting Research Journal of Applied Psychology Journalof Financial Economics.. Journal of Finance

推 荐 期 刊 : Journal of Cross-cultural Psychology, Journal of International Business Studies, Management and Organization Review