ISSN 1744-6783 INTRODUCTION TO FAST FOURIER TRANSFORM IN FINANCE A. CERNY Taaka Busiess School Discussio Papers: TBS/DP04/19 Lodo: Taaka Busiess School, 2004
Itroductio to Fast Fourier Trasform i Fiace Aleš Čerý (a.cery@imperial.ac.uk) Taaka Busiess School, Imperial College Lodo First draft: July 2003, this versio 18th Jue 2004 Typo i eq. (39) corrected 29th September 2004 Abstract. The Fourier trasform is a importat tool i Fiacial Ecoomics. It delivers real time pricig while allowig for a realistic structure of asset returs, takig ito accout excess kurtosis ad stochastic volatility. Fourier trasform is also rather abstract ad therefore o-puttig to may practitioers. The purpose of this paper is to explai the workig of the fast Fourier trasform i the familiar biomial optio pricig model. We argue that a good uderstadig of FFT requires o more tha some high school mathematics ad familiarity with roulette, bicycle wheel, or a similar circular object divided ito equally sized segmets. The returs to such a small itellectual ivestmet are overwhelmig. Keywords: fast Fourier trasform, optio pricig, biomial lattice, chirp-z trasform,gauss,matlab JEL classificatio code: C63, G12 Mathematics subject classificatio: 65T50, 91B70, 91B24 Forthcomig i Joural of Derivatives. I would like to thak David Miles ad Joatha Waiwright for suggestig importat clarificatiosiaearlydraft.iam grateful to Peter Carr, Sajiv Das ad Stephe Figlewski, who provided helpful commets ad poiters to refereces. This is a abridged ad adapted versio of of Čerý [2004, Chapter 7]. GAUSS is a trademark of Aptech Systems, Ic.; MATLAB is a registered trademark of The MathWorks, Ic.
2 A. Čerý The Fourier trasform is becomig a icreasigly popular ad importat tool i Fiacial Ecoomics because it delivers real time pricig while allowig for importat properties of asset returs, such as excess kurtosis, stochastic volatility ad leverage eects, discussed i Hesto [1993], Carr ad Mada [1999], Carr ad Wu [2004]. These impressive results come at a price i the form of a cosiderable abstractio which ca be quite o-puttig to practitioers. The aim of this paper is to explai the workig of the discrete Fourier trasform (DFT) ad its fast implemetatio (FFT) i the familiar biomial optio pricig model. The biomial model serves two purposes. It highlights, i a accessible way, the usefuless of FFT, which is a importat computatioal tool i its ow right, ad has may other applicatios i Fiace. It also motivates the passage to cotiuous time thereby providig ituitio behid fast pricig formulae i a very rich class of models used i the idustry. The paper is divided ito three parts: I Discrete Fourier trasform ad biomial optio pricig; II Eciet implemetatio of DFT by meas of fast Fourier trasform, with examples i GAUSS ad MATLAB; III Fourier trasform ad cotiuous-time optio pricig. 1. Discrete Fourier trasform ad biomial optio pricig This sectio explais how ad why optio prices i the biomial model ca be computed via discrete Fourier trasform. We assume that the reader is familiar with the cocept of risk-eutral pricig. To begi with, we itroduce complex umbers ad discuss their geometric properties, especially as they regard the uit circle; the we defie the Discrete Fourier Trasform (DFT) ad highlight some of its properties. The followig sectio itroduces a simple biomial optio pricig example ad shows how the pricig procedure ca be performed o a circle. To coclude, we demostrate how to trasform circular covolutios usig DFT ad obtai the Fourier trasform pricig formula. The resultig formula is put to practice i part II, which shows how to accelerate DFT by meas of FFT algorithm ad provides simple GAUSS ad MATLAB codes for illustratio. Real-world applicatios of the Fourier trasform pricig formula are discussed i part III. 1.1. Itroductio to complex umbers The discrete Fourier trasform is about evely spaced poits o a circle. From the mathematical poit of view, evely distributed poits o a circle are most easily described by complex umbers. This sectio
Itroductio to FFT i Fiace 3 2i 1i 2+i 0 1 2 Figure 1. reviews the geometry of those umbers, which i tur determie the properties of Fourier trasform. Complex umbers are a coveiet way of capturig vectors i a two-dimesioal space. For example, Exhibit 1 depicts a vector 2+i; it is a poit i the plae if we move two uits o the real (horizotal) axis ad oe uit o the imagiary (vertical) axis. This termiology is somewhat ufortuate; the imagiary axis is o less real tha the real axis. It would be more appropriate to talk about horizotal ad vertical umbers. The rules for additio of complex umbers are the same as with vectors, for example 2 3 5 + = 1 4 3 traslated ito complex otatio would read (2 + i) + (3 4i) = 5 3i. Likewise, multiplicatio by a scalar (a real umber) works like for vectors; 2 6 3 = 1 3 traslates ito complex umbers as 3(2+i)=6 3i.
4 A. Čerý 1.2. Complex multiplicatio Complex umbers are very good at describig the movemet aroud a uit circle. As show i Exhibit 2a, uit circle itersects the real axis at poits 1,1, ad the imagiary axis at poits i ad i. a) i b) i A cos + i si i si -1 0 1 0 cos 1 -i Figure 2. ApoitA o the uit circle is uiquely characterized by its argumet the agle betwee the real axis ad the lie OA. More specifically, Exhibit 2b shows that the poit A cabeexpressedascos +isi. O most computers the fuctios si ad cos are implemeted i such a way that the agle must be give i radias. Radias measure the distace travelled o the perimeter of the uit circle. The etire perimeter of the uit circle has legth 2 which correspods to 360. The agle correspodig to i is 90 or 2, the agle correspodig to 1 is 180 or ad so o, as show i Exhibit III. Table III. Coversio table betwee degrees ad radias. Agleidegrees 0 30 60 90 180 270 360 3 Agleiradias 0 2 6 3 2 2
Itroductio to FFT i Fiace 5 Facts: Multiplyig complex umbers o a uit circle meas addig agles. The agle of i is 90, the agle of i i will be 90 +90 = 180 which correspods to 1, see Exhibit 4a. I complex umber otatio this gives the famous formula i i=i 2 = 1. (1) With (1) i had the geeral defiitio of complex multiplicatio follows aturally (a 1 +ib 1 ) (a 2 +ib 2 ) = a 1 a 2 +i(b 1 a 2 + a 1 b 2 )+b 1 b 2 i 2 = = a 1 a 2 b 1 b 2 +i(b 1 a 2 + a 1 b 2 ). (2) It also follows that the multiplicatio is addig agles rule works quite geerally o the uit circle (cos 1 +isi 1 ) (cos 2 +isi 2 )= =cos( 1 + 2 )+isi( 1 + 2 ). (3) Oe ca express poits o the uit circle more elegatly usig the Euler formula cos +isi =e i, (4) whereby (3) becomes e i 1 e i 2 =e i( 1 + 2 ), (5) see Exhibit 4b. 1.3. Geometry of spoked wheels It is very easy to costruct a wheel with evely placed spokes usig complex umbers. Suppose we wat to place five evely spaced poits o the uit circle. Oe fifth of the full circle is characterized by the agle 2 5, hece the first spoke will be placed at ei 2 5. Let us deote this umber by z 5 (fifth root of uity) z 5 e i 2 5. Sice the multiplicatio by z 5 causes aticlockwise rotatio by oe fifth of full circle the secod spoke will be (z 5 ) 2 thethirdspokeat(z 5 ) 3 ad so o, see Exhibit 5a.
6 A. Čerý a) b) i i exp(i 1 ) /2 exp(i 2 ) 2 1 i*i = -1 0 1 1 + 2 1 exp(i( 1 + 2 )) Figure 4. a) b) i z 5-4 1 (z 5 ) 2 2-3 2/5 1 = (z 5 ) 0 = (z 5 ) 5-5 0 5 (z 5 ) 3 3-2 (z 5 ) 4-1 4 Figure 5. This provides a atural umberig of the spokes, accordig to how may elemetary rotatios are eeded to reach the particular spoke. Note that sice we are movig i a circle we will come back to the startig poit after five rotatios aticlockwise (z 5 ) 0 = (z 5 ) 5 =(z 5 ) 10 =(z 5 ) 15 =... (z 5 ) 1 = (z 5 ) 6 =(z 5 ) 11 =(z 5 ) 16 =...etc.,
ad also after five rotatios clockwise Itroductio to FFT i Fiace 7 (z 5 ) 0 = (z 5 ) 5 =(z 5 ) 10 =(z 5 ) 15 =... (z 5 ) 1 = (z 5 ) 4 =(z 5 ) 9 =(z 5 ) 14 =...etc. Thus the umberig of spokes is ambiguous; for example idices 0, 5, 5 refer to the same spoke, see Exhibit 5b. The followig box summarizes the most importat properties of evely spaced poits o the uit circle. These properties are essetial for the uderstadig of the discrete Fourier trasform. Let z be a rotatio by oe th of a full circle z e i 2. The (z ) 0 +(z ) 1 +...+(z ) 1 =0 (6) for ay. This is because the poits (z ) 0, (z ) 1,...,(z ) 1 are evely distributed o a uit circle ad thus the result of summatio must ot chage if we rotate the set of poits by oe th of a full circle. The oly vector that remais uchaged after such rotatio is zero vector. Oe ca geeralize this result further. Let k be a iteger betwee 1 ad 1. The ³ z k 0 ³ + z k 1 ³ +...+ z 1 k =0 (7) for ay. The reaso for this result is agai rotatioal symmetry of ³ poits z k 0 ³, z k 1 ³,..., z 1. k The dierece from (6) is that i the sequece (z ) 0, (z ) 1,...,(z ) 1 each spoke occurs exactly oce, ³ whereas i z k 0 ³, z k 1 ³,..., z 1 k the same spoke ca occur several times (try =4,k=2). Thecasewithk =0requires special attetio. Sice z 0 j =1for all j we have ³ z k 0 ³ + z k 1 ³ +...+ z 1 k =. To summarize, ³ z k 0 ³ + z k 1 ³ +...+ z 1 k = for k =0, ±, ±2,...(8) ³ z k 0 ³ + z k 1 ³ +...+ z 1 k = 0 for k 6= 0, ±, ±2,...(9)
8 A. Čerý 1.4. Reverse order o a circle Give a sequece of umbers a =[a 0,a 1,...,a 1 ] we ca say that rev(a) [a 0,a 1,...,a 1 ] is a i reverse order. Ifa is writte aroud a circle i aticlockwise directio the rev(a) is foud by readig from a 0 i clockwise directio, see Exhibit 6. Note that rev(a) is ot equal to [a 1,...,a 1,a 0 ]. a 2 a 1 a 0 a -1 a -2 a rev(a ) Figure 6. ³ For ay k the sequece ³ 0 ³ 1 ³,,..., z k rev z k µ ³ z k 0 ³, ³ This is because z k z k z k z k 1,..., ³ 0 ³, z k 1 ³,..., z 1 k isthesameasthesequece 1 take i the reverse order: z k 1 j = z k+kj 1.5. Discrete Fourier Trasform (DFT) = ³ z k 0 ³, z k 1 ³,..., z 1 k. (10) ³ = z kj = z j k for ay j. As i the previous sectio take z e i 2 (this umber is called the th root of uity ). Let a 0,a 1,...,a 1 be a sequece of (i geeral complex) umbers. The discrete Fourier trasform of a 0,a 1,...,a 1 is the sequece b 0,b 1,...,b 1 such that ³ b k = a 0 z k 0 ³ + a1 z k 1 ³ +...+ a1 z k 1 = (11) = 1 1 X a j z jk = 1 1 X a j e i 2 jk j=0 j=0
Itroductio to FFT i Fiace 9 We write F (a) =b. Equatio (11) represets the forward trasform. The iverse trasform is b0 ³z l 0 ³ + b1 z l 1 ³ +...+ b1 z l 1 ã l = = (12) ad we write Facts: = 1 1 X bk z kl = 1 1 X bk e i 2 kl, k=0 k=0 1 ã = F ³ b. The iverse discrete Fourier trasform of sequece b 0, b 1,..., b 1 is the same as the forward trasform of the same sequece i reversed order ³ 1 F ³ b = F rev ³ b, (13) ad vice versa ³ F 1 rev ³ b = F ³ b. (14) This is a direct cosequece of (10). F 1 is ideed a iverse trasformatio to F, thatis ³ F 1 (F (a)) = F F 1 (a) = a. (15) This result relies o (8) ad (9); for a proof see Appedix. 1.6. Biomial optio pricig Cosider a mothly distributio of FTSE 100 retur calibrated to reflect market volatility of 4.4% a moth ad expected rate of retur 0.9% a moth: pr u +(1 p)r d = 1.009 pru 2 +(1 p)rd 2 = 0.044 2 +1.009 2. Choosig the objective probability to be p = 1 2 we solve for R u ad R d R u = 1. 053 with p u = 1 2 (16) R d = 0. 965 with p d = 1 2. (17)
10 A. Čerý Assumig that the iitial value of FTSE Idex is 5100.00 poits, the evolutio of the idex i the three moths ahead is give by the lattice i Exhibit VII. Table VII. Biomial stock price lattice. umber of low returs S(0) S(1) S(2) S(3) 0 5100.00 5370.30 5654.93 5954.64 1 4921.50 5182.34 5457.00 2 4749.25 5000.96 3 4583.02 Suppose we wish to price a call optio struck at K =5355(5% out of the moey), maturig 3 moths from ow. The itrisic value of the optio at maturity is C(3) = []. (18) Asset pricig theory tells us that the o-arbitrage price of the pay-o Cu is give as the risk-eutral expectatio of the discouted pay-o C d o-arbitrage value(c) = q uc u + q d C d, (19) R f where the risk-eutral probabilities q u ad q d are chose such that the risk-eutrally expected retur of all basis assets is equal to the risk-free retur q u + q d = 1 q u R u + q d R d = R f. The values q u /R f ad q d /R f are kow as state prices. Assumig a risk-free rate equivalet to 4% per aum the mothly risk-free retur is R f =1.04 1/12 =1.0033. This gives coditioal risk-eutral probabilities of q u = R f R d 1.0033 0.965 = =0.43523, (20) R u R d 1.053 0.965 q d = R u R f R u R d = 1.053 1.0033 1.053 0.965 =0.56477, (21)
ad the valuatio formula: Itroductio to FFT i Fiace 11 o-arbitrage value(c) = 0.43523C u +0.56477C d. (22) 1.0033 Recursive applicatio of (22) with termial value (18) leads to optio prices i Exhibit VIII. Table VIII. Optio prices i a biomial lattice. umber of low returs C(0) C(1) C(2) C(3) 0 81.36 162.66 317.54 599.64 1 19.19 44.25 102.00 2 0.00 0.00 3 0.00 1.7. Optio pricig o a circle For ay two -dimesioal vectors a =[a 0,a 1,...,a 1 ],b=[b 0,b 1,...,b 1 ] we defie circular (cyclic) covolutio of a ad b to be a ew vector c, such that c j = c = a ~ b, 1 X k=0 a jk b k. (23) Oe will immediately ote that the idex j k ca be egative. If this occurs,wewillsimplyadd to get the result betwee 0 ad 1; this practice is cosistet with the spoke umberig itroduced i Sectio 1.3, ad it merely reflects movemet i a circle. Graphically oe ca evaluate the circular covolutio as follows: 1. Set up two cocetric circles divided ito equal segmets. Write a aroud the ier circle clockwise ad b aroud the outer circle aticlockwise. Exhibit 9 shows this for =4. 2. Perform a scalar multiplicatio betwee the two circles. I Exhibit 9 this would give The result is c 0. a 0 b 0 + a 3 b 1 + a 2 b 2 + a 1 b 3.
12 A. Čerý b 1 a 3 b 2 a 2 a 0 b 0 a 1 b 3 Figure 9. 3. Tur the ier circle aticlockwise by 1 th of a full circle. Repeat the scalar multiplicatio betwee the circles. The result is c 1. I Exhibit 10 c 1 = a 1 b 0 + a 0 b 1 + a 3 b 2 + a 2 b 3. b 1 a 0 b 2 a 3 a 1 b 0 a 2 b 3 Figure 10. 4. Repeat this procedure to compute c 2,...,c 1, each time givig the ier circle 1 th tur aticlockwise. How ca oe use the circular covolutio for optio pricig? If we write both the optio pay-o ad the pricig kerel i the clockwise
Itroductio to FFT i Fiace 13 directio ad the rotate the optio pay-o i the aticlockwise directio, we will obtai optio prices i the atural order from highest to lowest. To be specific, let us go back to the biomial optio pricig model. At maturity the optio ca have four dieret values: C(3) = 599.64 102.00 0.00 0.00. Let vector q cotai the coditioal oe-period risk-eutral probabilities q u =0.43523, q d =0.56477. Sice there are just two states over oe period the remaiig etries will be padded by zeros: q = q u q d 0.00 0.00. Fially, recall that the risk-free retur is R f =1.0033. Thus to compute optio prices at time t =2we eed to evaluate c = C(3) ~ rev(q/r f ). This operatio is depicted graphically i Exhibit 11, where the optio pay-os C(3) are o the ier circle ad the state prices q/r f are o the outer circle, both writte i clockwise directio. Numerically we obtai C(3) ~ rev(q/r f )= 317. 54 44.25 0 337.54. (24) Note that we oly eed the first three prices i (24). The last etry is meaigless it correspods to the o-arbitrage price of the pay-o [0 599.64]. Optio pricig o a circle. Cosider a biomial model where C(j) is the vector of optio prices at date j =0, 1,..., N.Deote by q the vector cotaiig the risk-eutral probabilities q u ad q d, padded by zeros to have the same dimesio as C(N). By backward substitutio, C(N 1) = C(N) ~ rev(q)/r f, C(N 2) = C(N) ~ rev(q) ~ rev(q)/rf 2, (Nj) times z } { C(j) = C(N) ~ rev(q) ~ rev(q) ~...~ rev(q) /R j f, (25) The vectors C(j) computed i this maer have more etries tha eeded, the useful j +1etries are at the top ed of each vector. Numerical results are reported i Exhibit XII, the relevat etries are highlighted ad should be compared with those i Exhibit VIII.
14 A. Čerý a) 0 b) 0 0 599.64 599.64 0.4338 102.0 0 0.4338 102.0 0 0.5629 0.5629 c) 0 d) 0 102.0 0 599.64 0.4338 102.0 0 0.4338 599.64 0.5629 0.5629 Figure 11. Table XII. Optio prices obtaied from circular pricig formula (25). The useful etries are i bold. umber of low returs C(0) C(1) C(2) C(3) 0 81.36 162.66 317.54 599.64 1 115.28 19.19 44.25 102.00 2 265.47 190.01 0.00 0.00 3 232.62 325.17 337.54 0.00 1.8. Circular pricig via discrete Fourier trasform I this sectio we will reformulate the circular pricig formula (25) usig the discrete Fourier trasform. Although we derive the Fourier pricig formula mechaically, i part III we will spell out its more ituitive probabilistic itepretatio.
Itroductio to FFT i Fiace 15 The discrete Fourier trasform has oe very useful property it turs circular covolutios ito products: F (a ~ b) = F (a) F (b), (26) F 1 (a ~ b) = F 1 (a) F 1 (b), (27) = dimesio of a; (28) see Appedix for a proof. This ca be used to a great advatage i pricig. Recall from the precedig sectio that N times z } { C 0 = C N ~ rev(q) ~ rev(q) ~...~ rev(q) /Rf N, where N is the umber of time periods to maturity. Now apply the iverse trasform F 1 to both sides, usig property (27) o the right had side F 1 (C 0 )=F 1 (C N ) ³p dimesio of CN F 1 (rev(q)) /R f N. (29) I a biomial model the dimesio of C N is N +1. Furthermore, recall from (14) that F 1 (rev(q)) = F (q) ad substitute this ito (29) F 1 (C 0 )=F 1 (C N ) ³ N +1F (q) /Rf N. Fially, apply the forward trasform to both sides agai ad use (15) o the left had side: µ ³ C 0 = F F 1 (C N ) N +1F (q) /Rf N. Optio pricig via discrete Fourier trasform. Cosider a model with IID stock returs ad costat iterest rate, represeted by a recombiig biomial tree with N periods ad N +1 tradig dates. Let the (N +1)-dimesioal vector C N be the pay-o of the optio at expiry. Let q cotai the oe-step risk-eutral probabilities as the first two etries, with the remaiig N 1 etries beig zeros. The the first elemet of (N +1)-dimesioal vector C 0, µ ³ C 0 = F F 1 (C N ) N +1F (q) /Rf N, (30) is the o-arbitrage price of the optio at time 0. The role of the forward ad iverse trasforms is symmetrical, that is we also have ³ C 0 = F µf 1 (C N ) N +1F 1 (q) /R f N. (31)
16 A. Čerý 2. Fast Fourier Trasform (FFT) This sectio deals with the implemetatio of the pricig formula (30) o a computer usig fast DFT routies, kow as FFTs. It is highly ulikely that the reader will wat to write his or her ow DFT code, for this would be couterproductive give the wealth ad the level of specializatio of ready-made algorithms. The use of prepackaged algorithms saves time, but with little documetatio at had implemetig otherwise soud mathematical formula may ot prove straightforward. This sectio provides guidelies that esure a trouble-free trasitio betwee the theoretical pricig formula (30) ad a computer code usig a DFT routie of reader s choice, with specific examples give i GAUSS ad MATLAB. Two mai issues arise i the use of (fast) DFT routies: 1) fidig out the mathematical defiitio of a specific DFT routie,ad 2) choosig the right iput legth to make the computatio fast. We ow address these two issues i tur. 1. Every textbook, ad ideed every computer laguage, defies the forward ad iverse trasforms slightly dieretly. Thus the first task of ay user is to fid out how a give computer routie, call it dft, is related to the theoretical trasforms F ad F 1 defied i (11) ad (12). To do so, oe proceeds i two simple steps: a) I the first step oe determies the ormalizatio factor. Defie a =[1000]ad compute ã = dft (a). Ifã 0 =0.25 the either dft = F/ or dft = F 1 / ; else if ã 0 =0.5 the either dft = F or dft = F 1 ; ad if ã 0 =1the either dft = F or dft = F 1. b) To ascertai whether oe is dealig with a forward or a iverse trasform, oe defies b =[0100]ad evaluates b = dft (b). If the imagiary part of b 1 is positive the dft is proportioal to F, otherwise it is proportioal to F 1.Ithecaseofthe lattice pricig formulae (30) ad (31) oe will use two routies, say dft ad dfti, which are iverse to each other. I this istace it does ot really matter which of the two trasforms is forward ad which is iverse. But there are other applicatios (see Sectio 3), where it is absolutely crucial to kow whether a give routie is proportioal to F or F 1.
Itroductio to FFT i Fiace 17 EXAMPLE 1. I GAUSS the two DFT trasforms are called dfft ad dffti, respectively, ad they are related to F ad F 1 as follows: dfft(a) F 1 (a), dffti(a) F (a), where is the dimesio of vector a. Equatio (30) therefore becomes C 0 = dffti ³dfft (C N ) (dffti (b)) N. (32) Suppose the vectors C_ N ad b have already bee defied i GAUSS. To compute the optio price at t =0we would use the followig code: C_0 = dffti( dfft(c_n).*(dfft(b)^n) ); (33) prit o-arbitrage price at t=0 is C_0[1]; The. commad stads for elemet-by-elemet multiplicatio. The DFT algorithm is approximately three times faster tha the backward recursio i biomial model; the computatioal time for both algorithms grows quadratically with the umber of periods 1, see Exhibit XIII. Table XIII. Compariso of pricig speed i a biomial lattice betwee backward recursio ad discrete Fourier trasform formula (30). tradig iterval umber of executio time i secods i miutes periods DFT backward recursio 60 504 0.15 0.4 30 1008 0.6 1.6 15 2016 2.3 6.4 5 6048 20.8 61.6 Petium III 750MHz, 128Mb RAM, GAUSS 2. A aive implemetatio of DFT algorithm with -dimesioal iput requires 2 complex multiplicatios (see example above). A 1 GAUSS programes Biomial.gss ad DFT.gss available from my website.
18 A. Čerý eciet implemetatio of DFT, kow as the fast Fourier trasform (FFT), will oly require Kl operatios 2, but oe still has to choose carefully because the costat K ca be very large for some choices of. Some FFT implemetatios automatically restrict the trasform legth to the most suitable values of (typically =2 p or =2 p 3 q 5 r ), which is the case i GAUSS. Others, such as MATLAB, will compute FFT of ay legth; here it is particularly importat for the user to choose sesibly, otherwise the FFT algorithm may tur out to be very slow ideed. EXAMPLE 2. The forward ad iverse FFT i MATLAB are called fft ad ifft, respectively: fft(a) F 1 (a) (34) ifft(a) F (a), (35) where is the dimesio of vector a. The optio pricig equatio (30) therefore becomes C 0 = ifft ³fft (C N ) ((N +1) ifft (b)) N, which i terms of MATLAB code reads C_0 = ifft( fft(c_n).*(((n+1)*ifft(b)).^n) ); (36) spritf o-arbitrage price at t=0 is %0.2f C_0(1); The commads.* ad.^ stad for elemet-by-elemet multiplicatio ad expoetiatio, respectively. There are may istaces whe FFT of legth 1 is faster tha FFT of legth 2 eve though 1 > 2. This somewhat couterituitive pheomeo is illustrated i Exhibit XIV. To uderstad why some trasform legths are more suitable tha others we eed oe piece of termiology ad oe fact: i) FFT algorithm for legth =2 p is called radix-2 algorithm; ii) the higher 2 The fast Fourier trasform does ot appear i udergraduate textbooks o umerical mathematics ad the most useful refereces o the itroductory level are web based, see http://www.fftw.org/liks.html, ad i particular the olie maual Hey [1999]. A eciet implemetatio of FFT for all trasform legths is suggested i Frigo ad Johso [1998]; it is used i Matlab. Eciet implemetatio of mixed 2, 3, 5-radix algorithm is due to Temperto [1992]; it is used i GAUSS. Duhamel ad Vetterli [1990] is a excellet survey of FFT algorithms.
Itroductio to FFT i Fiace 19 Table XIV. Executio time of FFT algorithm for dieret iput legths. factorizatio executio time i secods 499 979 499 979 27.2 1048 575 3 5 2 11 31 41 5.2 1048 576 2 20 0.93 1080 000 2 6 3 3 5 4 0.11 Petium III 750MHz, 128Mb RAM, MATLAB the b the slower the radix-b algorithm per output legth. There is oe otable exceptio: radix-4 is faster tha radix-2 by about 25%. I practice, oe uses trasforms of size =2 p 3 q 5 r. If the origial vector size is ot of this form, the a suciet umber of zeros is added. Ideally, q ad r should be small compared to p because of the fact ii) above. The advatage of usig mixed-radix algorithms is twofold: a) more trasform legths are available, which meas oe eed ot pad the iput with too may zeros; b) oe ca use the operatio-savig prime factor algorithm 3. To illustrate the item a), with vector size 2 10 + 1 = 1025 the ext available size for radix-2 algorithm is = 2048 = 2 11 but with mixed 2,3,5-radix algorithm oe could use legth =1080=2 3 3 3 5 which is early twice as small ad cosequetly the Fourier trasform evaluatio is twice as fast compared to radix-2 algorithm. To illustrate property b), oe should otice that highly composite legths such as 1080000 = 2 6 3 3 5 4 evaluate faster tha simple powers of similar legth such as 2 20 = 1048 576, see Exhibit XIV. Trasforms which are ot of the legth =2 p 3 q 5 r ca take very log to compute, especially if is a large prime, agai see Exhibit XIV. EXAMPLE 3. MATLAB will allow the user to perform FFT of ay legth; this is doe usig commads (34) ad (35). However, as we have oted above, it is emietly sesible to restrict trasform legths to =2 p 3 q 5 r with q ad r small relative to p to obtai the best performace. MATLAB provides fuctio extpow2 givig the ext bigger power of 2. I additio, MATLAB allows the user to 3 The prime factor algorithm (PFA) works faster because the factors 2, 3 ad 5 have o commo divisors, see Temperto [1992].
20 A. Čerý specify the trasform legth by icludig it as a secod optioal argumet of fft ad ifft. Hece a fast implemetatio of (36) i MATLAB would read: legth = 2^extpow2(N+1); C_0 = ifft( fft(c_n,legth).*((legth*ifft(b,legth)).^n) ); The paddig of the origial iput C_N by zeros to the dimesio legth is doe automatically. To fid the earest trasform legth of the form =2 p 3 q 5 r oe ca use the followig code: legth = N+1; while max(factor(legth)) > 5; legth = legth+1; ed; EXAMPLE 4. I GAUSS the fast Fourier forward ad iverse trasforms are performed by fuctios fft ad ffti. Thesefuc- tios use Temperto s [1992] mixed 2,3,5-radix algorithm, ad the paddig of iput vector by zeros to the earest available legth =2 p 3 q 5 r is doe automatically. If is the iput dimesio the output dimesio from fft ad ffti will be ext(). Iterms of GAUSS code oe writes similarly as i (33): C_0 = ffti( fft(c_n).*(ffti(b)^n) ); Oe ca icrease the speed further by choosig a composite legth =2 p 3 q 5 r where q ad r are o-zero but small relative to p. The optimal legth is give by GAUSS fuctio opt (N +1), ad the paddig by zeros to this dimesio must be performed by the user. The FFT implemetatio of biomial pricig algorithm 4 has a blisterig speed compared to the DFT, see Exhibit XV. Because it is so fast oe ca explore higher tradig frequecies ad see that the Black Scholes formula really does describe the limitig value, see Exhibit XVI. Note that the Black Scholes formula itself is still about 10 000 times faster tha the FFT algorithm. 4 GAUSS code FFT.gss available from my website.
Itroductio to FFT i Fiace 21 Table XV. Speed of biomial pricig usig DFT ad FFT algorithms. tradig iterval umber of executio time i secods i miutes periods DFT FFT 30 1008 0.6 0.003 15 2016 2.3 0.006 5 6048 20.8 0.022 1 30240 510 0.27 Petium III 750MHz, 128Mb RAM, GAUSS Table XVI. Optio price ad optio delta i cotiuous-time limit ad its biomial approximatio. Black Scholes 4t (secods) 60 10 1 0 Optio price 75.93398 75.93284 75.93286 75.93288 Optio delta 0.31668534 0.31668346 0.31668334 0.31668331 3. Further applicatios of FFT i fiace Practical applicatios of DFT (FFT) i moder fiace go beyod the biomial model, but the essetial structure of the pricig formulae is that of equatio (30). To motivate the passage to cotiuous time, let us rewrite the DFT pricig equatio (30) to take explicit accout of the maturity date T ad the rebalacig frequecy 4t, with N 4t = T/4t tradig periods ad istataeous risk-free rate r: µ C 0 = F F 1 (C T,4t ) ³qN 4t +1F (q 4t )e r4t N 4t µ ³q = e rt F F 1 N4t (C T,4t ) N 4t +1F (q 4t ). (37) The quatity p N 4t +1F (q 4t ) N 4t is kow as the (risk-eutral) characteristic fuctio of log stock price, ad i practice oe is maily iterested i models where the cotiuous-time limit of (37) is available i closed form. This is the case i the class of expoetial Lévy models with ae stochastic volatility process, discussed i Carr ad Wu [2004]. This class cotais a large umber of popular models al-
22 A. Čerý lowig for excess kurtosis, stochastic volatility ad leverage eects. It icludes, amog others, the stochastic volatility models of Hesto [1993], Due et al. [2000] ad all expoetial Lévy models (see, for example, Mada ad Seeta [1990] ad Eberlei et al. [1998]). For a exhaustive characterizatio of ae processes see Due et al. [2003]. I the cotiuous-time limit the discrete Fourier trasform is replaced by the (cotiuous) Fourier trasform: that is we wish to fid coeciets (v) such that C T (l S T )= Z +i i (v)e iv l S T dv (38) for some real costat 5. The recipe for obtaiig the coeciets (v) is kow it is give by the iverse Fourier trasform 6 : (v) = 1 Z +i C T (l S T )e iv l S T dv. (39) 2 i For example, a simple calculatio i Carr ad Mada [1999] shows that coeciets of a call optio with strike price e k take the form (v) = e(v1)k for Re v>1. 2v(v 1) Substitutig for C T from (38) the risk-eutral pricig formula reads C 0 (l S 0 ) = e rt E Q [C T (l S T )] " Z # +i = e rt E Q (v)e iv l S T dv i i Z +i h i = e rt (v)e Q e iv l S T dv, (40) where E Q [e iv l S T ] is the risk-eutral characteristic fuctio of log stock price. It is ow clear that the cotiuous-time pricig formula (40) is a direct aalogy of its discrete-time couterpart (37), whereby istead of the discrete characteristic fuctio p N 4t +1F (q 4t ) N 4t we use h i the cotiuous characteristic fuctio E Q e iv l S T ; istead of discrete Fourier coeciets F 1 (C T,4t ) we use the cotiuous coeciets, ad istead of summatio we use itegratio. 5 For the Fourier trasform to work C T (l S T )S T must be itegrable as a fuctio of l S T. There are derivative securities, such as call ad put optios, where oe eedstotake 6= 0to isure itegrability ( > 1 for the call, > 0 for the put). 6 Some urestrictive techical coditios must hold to make sure that for give i (39) equatio (38) holds for all values of l S T, see Chadrasekhara [1989].
Itroductio to FFT i Fiace 23 There is, evertheless, oe major dierece betwee (37) ad (40): whereas the former speds sigificat amout of time computig the characteristic fuctio of log returs ad Fourier coeciets of the optio, the latter has both quatities available i closed form. This makes the cotiuous-time pricig formula (40) eve faster tha the accelerated biomial formula (30). EXAMPLE 5. I the celebrated Hesto [1993] model, we have d 2 t = (a b 2 t )dt + t db Q 1 Ã! dls t = r 2 t dt + t db Q 2 2, h i Q (iv) = E Q e v l(s T /S 0 ) =e (v)+(v)2 0, (v) = rtv + ã Ã 1 c2 (v)e Ãb c!! 1(v)T 2 v 2l, 1 c 2 (v) (v) = (b v + c 1(v)) ³1 e c 1(v)T 2 1 c 2 (v)e c 1(v)T, q c 1 (v) = (b v) 2 2 (v + v 2 ), c 2 (v) = b v + c 1(v) b v c 1 (v), where = Corr(dB Q 1, dbq 2 ). Optio pricig therefore boils dow to evaluatio of itegrals of the type e (v1)(l S 0k) Z +i C 0 (l S 0 ) = S 0 e rt i 2v(v 1) Q (iv)dv Z Ã! +i e = 2S 0 e rt (v1)(l S 0 k) Re 2v(v 1) Q (iv) dv, (41) +i0 where both (v) ad Q (v) are kow. To evaluate (41) oe trucates the itegral at a high value of Im v ad the uses a umerical quadrature to approximate it by a sum, see Lee [2004] for a detailed expositio. This yields a expressio of the type 1 C 0 (l S 0 ) 2ReS 0 e rt X e (v j1)(l S 0 k) w j 2v j (v j 1) Q (iv j ), (42) j=0
24 A. Čerý where the itegratio weights w j ad abscissas v j deped o the quadrature rule. It is particularly coveiet to use Newto-Cotes rules, which employ equidistatly spaced abscissas. For example, a trapezoidal rule yields v j = +ij4v, (43) Im v max = ( 1)4v, w 0 = w = 1 2 4v, w 1 = w 2 =... = w 1 = 4v. I coclusio, if the characteristic fuctio of log returs is kow, oe eeds to evaluate a sigle sum (42) to fid the optio price. Cosequetly, there is o eed tousefftifoewishestoevaluatethe optio price for oe fixed log strike k. 3.1. FFT optio pricig with multiple strikes The situatio is very dieret if we wat to evaluate the optio price (42) for may dieret strikes simultaeously. Let us cosider m = 121 values of moeyess l =ls 0 k l ragig from 30% to 30% with icremet 4 =0.5% l = max l4, (44) max = 0.30, l=0,...,m 1. (45) The idea of usig FFT i this cotext is due to Carr ad Mada [1999], ad it has recetly bee improved upo by usig so-called z-trasform, see Chourdakis [2004]: DEFINITION 6. The umber a 0 z 0 + a 1 z 1 +...+ a 1 z (1) is called the z-trasform of sequece a. The discrete Fourier trasform of sequece a is obtaied as a special case of z-trasform with specific values of z: z l =e i 2 l, l =0, 1,..., 1. Carr ad Mada have oted that with equidistatly spaced abscissas (43) oe ca write the optio pricig equatio (42) for dieret strike values (44, 45) as a z-trasform with z l =e i4v4l : C 0l 1 = 2S 0 e (1)lrT X Re e i4v4kl a j, (46) k=0 e ij4v max Q (iv j ) a j = w j. 2v j (v j 1)
Itroductio to FFT i Fiace 25 Settig 4v4 = 2 (47) Carr ad Mada obtai a discrete Fourier trasform i (46). Chourdakis [2004] poits out that there is a fast algorithm for the z-trasform which works eve whe 4v4 6= 2 ad m 6= : Chirp-z trasform Chirp-z trasform is a eciet algorithm for evaluatig the z-trasform for m dieret poits z of the form z k = Aw k,k=0, 1,...,m 1, where A ad w are arbitrary complex umbers. The chirp-z trasform works by rephrasig the origial z-trasform as a circular covolutio ad the computig this covolutio by meas of three FFTs as show i Part I, Sectio Circular pricig via DFT. For more details see Bluestei [1968], Rabier et al. [1969], ad Bailey ad Swartztrauber [1991]. Compared to the stadard -log FFT the chirp-z algorithm is approximately 6(l m+1)/ l times slower, for m. The MATLAB commad for chirp-z trasform of -log iput sequece a reads czt(a, m, w, A). A GAUSS procedure czt.gss is available from my website. The decisio whether to use the simple summatio (42) m times, or whether to apply the chirp-z trasform (46) depeds o the desired umber of strikes m. The speed of the former relative to the latter is roughly m/6/(log 2 m +1)times higher. As a rough guide, for m 36 the simple summatio (42) is as fast as the chirp-z formula (46), for m =8it is three times faster, ad for m = 150 it is three times slower. Oe also has to decide whether to force the FFT spacig of strike values (47); this is doe by boostig while keepig 4v fixed. Suppose that v max is chose sucietly high to achieve desired accuracy for a 2 Im v max sigle strike. As a rule of thumb, if the iitial spacig is six times coarser that the desired spacig of log strikes 4 oe should use the chirp-z trasform, otherwise it will be faster to icrease to satisfy (47) ad use the short FFT algorithm described i Bailey ad Schwarztrauber [2004, pp. 392-393]. The value of Im v max teds to be higher for short maturities, ad for parametric distributios with heavy tails, such as variace gamma or geeralized hyperbolic. I such circumstaces FFT formula (46)-(47) is preferable. No-parametric empirical equity retur distributios have
26 A. Čerý characterisitic fuctios that decay faster, leadig to lower values of Im v max, leavig the chirp-z trasform as the best optio. 4. Coclusios The preset paper makes three cotributios. It explais the workig of the discrete Fourier trasform i a o-techical laguage i the familiar biomial optio pricig model. Secodly, it highlights the commo perils i the computer implemetatio of fast DFT algorithms. Thirdly, it explais how the biomial pricig formula relates to more complex cotiuous-time models which allow for excess kurtosis, stochastic volatility ad leverage eects ad which are used routiely i the fiace idustry. The preset paper does ot give a exhaustive accout of DFT i Fiace. Oe ca quite easily exted the Fourier pricig formula from biomial lattice of Part I to multiomial lattices, see Čerý [2004, Chapter 12]. Further applicatios of FFT appear i Albaese et al [2004], Adreas et al. [2002], Behamou [2002], Chiarella ad El-Hassa [1997], Dempster ad Hog [2002], ad Reboato ad Cooper [1998]. For the most up-to-date developmets i optio pricig usig (cotiuous) Fourier trasform see Carr ad Wu [2004], ad for evalutio of hedgig errors refer to Čerý [2003] ad Hubalek et al [2004]. 5. Appedix 5.1. IverseDiscreteFourierTrasform To show F 1 (F (a)) = a we eed to prove that for b = F (a) defied i (11) we have F 1 (b) =a. Deote ã = F 1 (b) ad express ã from defiitio (12) ã l = 1 1 X k=0 Now substitute for b k from (11) ã l = 1 1 X 1 X k=0 j=0 b k z kl. a j z jk z kl, move z kl iside the ier summatio ã l = 1 1 X 1 X a j z k(jl), k=0 j=0
chage the order of summatio Itroductio to FFT i Fiace 27 ã l = 1 1 X j=0 Ã 1 X k=0 a j z k(jl) ad take a j i frot of the ier sum (it does ot deped o k) ã l = 1 1 X j=0 Ã 1 X a j k=0 ³ z jl!,! k. By virtue of (8)-(9) the ier sum P ³ 1 k=0 z jl k equals 0 for j 6= l ad for j = l it equals. Cosequetly ã l = 1 1 X j=0 Ã 1 X a j k=0 ³ z jl for all l which proves that F 1 (F (a)) = a.! k = a l 5.2. Discrete Fourier Trasform of Covolutios We wish to show F(a ~ b) = F(a)F(b). Let us begi by computig c = a ~ b. From the defiitio (23) c j = 1 X k=0 a jk b k. (48) By d deote the Fourier trasform of c, d = F(a ~ b) ad use the defiitio (11) to evaluate d l Now substitute for c j from (48), d l = 1 1 X c j z jl. j=0 d l = 1 Ã 1 X 1 X j=0 k=0 a jk b k! z jl, move z jl iside the ier bracket, writig it as a product z jl = z (jk)l z kl, d l = 1 1 X 1 X j=0 k=0 a jk z (jk)l b k z kl,
28 A. Čerý chage the order of summatio, d l = 1 1 X 1 X k=0 j=0 a jk z (jk)l b k z kl, ad take b k z kl i frot of the ier summatio (it does ot deped o j), d l = 1 1 X 1 b k z kl X a jk z (jk)l. (49) k=0 It is easy to realize that the ier sum does ot deped o k, becauseit always adds the same elemets; oly the order i which these elemets are added depeds o k (we are completig oe full tur aroud the circle, startig at kth spoke). Hece we have: 1 X j=0 a jk z (jk)l = j=0 1 X j=0 a j z jl for all k, ad substitutig this ito (49) we fially obtai d l = Ã! 1 1 X b k z kl 1 1 X a j z jl. k=0 j=0 {z } {z } bl ã l From the defiitio of the forward trasform (11) ã = F(a) ad b = F(b), which completes the proof. Refereces Albaese, C., K. Jackso, ad P. Wiberg (2004). A ew Fourier trasform algorithm for value at risk. Quatitative Fiace 4, 328 338. Adreas, A., B. Egelma, P. Schweder, ad U. Wystup (2002). Fast Fourier method for the valuatio of optios o several correlated currecies. I J. Hakala ad U. Wystup (Eds.), Foreig Exchage Risk. Risk Publicatios. Bailey, D. H. ad P. N. Swartztrauber (1991). The fractioal Fourier trasform ad applicatios. SIAM Review 33 (3), 389 404. Behamou, E. (2002). Fast Fourier trasform for discrete Asia optios. Joural of Computatioal Fiace 6 (1).
Itroductio to FFT i Fiace 29 Bluestei, L. I. (1968). A liear filterig approach to the computatio of the discrete Fourier trasform. IEEE Northeast Electroics Research ad Egieerig Meetig 10, 218 219. Carr, P. ad D. B. Mada (1999). Optio valuatio usig the fast Fourier trasform. Joural of Computatioal Fiace 2, 61 73. Carr, P. ad L. Wu (2004). Time-chaged Lévy processes ad optio pricig. Joural of Fiacial Ecoomics 71 (1), 113 141. Čerý, A. (2003). The risk of optimal, cotiuously rebalaced hedgig strategies ad its eciet evaluatio via Fourier trasform. Techical report, The Busiess School, Imperial College Lodo. Čerý, A. (2004). Mathematical Techiques i Fiace: Tools for Icomplete Markets. Priceto Uiversity Press. Chadrasekhara, K. (1989). Classical Fourier Trasforms. Spriger. Chiarella, C. ad N. El-Hassa (1997). Evaluatio of derivative security prices i the heath-jarrow-morto framework as path itegrals usig fast Fourier trasform techiques. Joural of Fiacial Egieerig 6 (2), 121 147. Chourdakis, K. (2004). Optio pricig usig the fractioal FFT. Workig paper available from www.thepoytail.et. Dempster, M. A. H. ad S. S. G. Hog (2002). Spread optio valuatioadthefastfouriertrasform.ih.gema,d.mada, S. R. Pliska, ad T. Vorst (Eds.), Mathematical Fiace Bachelier Cogress 2000, pp. 203 220. Spriger. Due, D., D. Filipović, ad W. Schachermayer (2003). Ae processes ad applicatios i fiace. The Aals of Applied Probability 13 (3), 984 1053. Due, D., J. Pa, ad K. Sigleto (2000). Trasform aalysis ad asset pricig for ae jump diusios. Ecoometrica 68, 1343 1376. Duhamel, P. ad M. Vetterli (1990). Fast Fourier trasforms: A tutorial review ad a state of the art. Sigal Processig 19, 259 299. Eberlei, E., U. Keller, ad K. Prause (1998). New isights ito smile, mispricig ad value at risk: The hyperbolic model. Joural of Busiess 71 (3), 371 405. Frigo, M. ad S. G. Johso (1998). FFTW: A adaptive software architecture for the FFT. I Proc. IEEE Itl. Cof. O Acoustics, Speech, ad Sigal Processig, Volume 3, Seattle, WA, pp. 1381 1384.
30 A. Čerý Hesto, S. (1993). A closed-form solutio for optios with stochastic volatility with applicatios to bod ad currecy optios. Review of Fiacial Studies 6, 327 344. Hey, A. (1999). FFT Demystified. http://www.eptools.com/t/t0001/index.htm. Hubalek, F., J. Kallse, ad L. Krawczyk (2004). Variace-optimal hedgig ad Markowitz-eciet portfolios for processes with statioary idepedet icremets. Workig paper. Lee, R. W. (2004). Optio pricig by trasform methods: Extesios, uificatio ad error cotrol. Joural of Computatioal Fiace 7 (3). Mada, D. ad E. Seeta (1990). The variace gamma model for stock market returs. Joural of Busiess 63 (4), 511 524. Rabier, L. R., R. W. Schafer, ad C. M. Rader (1969). The chirp z-trasform algorithm ad its applicatio. Bell Systems Techical Joural 48 (5), 1249 1292. Reboato, R. ad I. Cooper (1998). Couplig backward iductio with mote carlo simulatios: A fast Fourier trasform (FFT) approach. Applied Mathematical Fiace 5 (2), 131 141. Temperto, C. (1992). A geeralized prime factor FFT algorithm for ay =2 p 3 q 5 s. SIAM Joural o Scietific adstatistical Computig 13, 676 686.