Path: blob/master/1.3 Fourier transform methods.ipynb
1675 views
Fourier transform methods
In this notebook I want to show how the characteristic function can be used to price derivatives. Sometimes it will be convenient to use this method, because for some stochastic processes the probability density function is not always known, or can have a quite complicated formula, while the characteristic function is frequently available. For Lévy processes, in particular, the characteristic function is always known, and is given by the Lévy-Kintchkine representation (see A3).
I will present some examples in which I'm going to price European call options using the Normal, the Merton and the Variance Gamma characteristic functions. For a complete presentation of Fourier methods, I suggest to have a look at [1].
Contents
Let us recall the definition of the characteristic function of the random variable :
where is the density of . The characteristic function is nothing but the Fourier transform of . Let us review some properties:
always exists. This is because . Recall that and .
.
, where means complex conjugate.
The density function can be obtained by taking the inverse Fourier transform:
Inversion theorem
Let us consider the following representation of the cumulative density function:
By taking the derivative of , you can check that it gives the expression for .
But.... How to obtain this formula?
I think this is a quite interesting topic, so... I present the proof. (for more information have a look at [2])
Proof - step 1
Let us consider the sign function wiki,
The step function has Fourier transform equal to (intended as the Cauchy principal value ).
In order to prove it, let us consider the function
with . When , the function converges to .
The Fourier transform of can be computed easily by splitting the integral in two (if you are lazy, have a look at the table here):
We can send and obtain the relation we were looking for.
Proof - step 2
The convolution of the density function with the sign function is given by:
Proof - step 3
By the convolution theorem wiki we know that:
Therefore we have that
Proof - conclusion
We can put together the steps 2 and 3:
Rearranging the terms, we can conclude the proof:
Gil Pelaez formulas
Recall that for a complex number z,
Starting from the inversion formula, Gil Pelaez [5] obtained the following expression:
This formula can also be written as:
We obtain the expression for the density by taking the derivative:
Pricing formula by Fourier inversion
In the notebook 1.1 we found that the pricing formula for a call option with stike K and maturity T is:
where is the probability under the stock numeraire and is the probability under the money market numeraire.
This formula is model independent!
When the stock follows a geometric Brownian motion, this formula corresponds to the Black-Scholes formula.
Now let us express and in terms of the characteristic function using the Gil Pelaez formula. Let us call and
For we can write:
In the same way, for , we can write:
where
(see the notebook 1.1 for a discussion about this change of measure).
Let us consider the following characteristic functions:
Normal:
, .
Gamma (shape-scale parameterization)
, .
Poisson
, .
I want to check if the Gil Pelaez formula works:
Normal
Gamma
Comments:
If you try to increase the value of lim_ab = 24
, you will see that python will raise:
IntegrationWarning: The maximum number of subdivisions (50) has been achieved.
When we solve this kind of problems we have to be careful, and analyze them case by case.
For and , we could set lim_cd = np.inf
because the integrand has a good behavior.
But for and the integrand is not so nice. There are many oscillations (originated by the term ) that create the problem.
Let's have a look at the plot of the integrands: (at the point x=3)
Poisson
Comments:
In this case, we considered only the integration in the region .
As you can see in the plots below, the integrand is an even periodic function. Therefore, if we had integrated on the integral would have been infinite.
The two plots below consider the characteristic function with .
The integrands inside the Gil_Pelaez_pdf
function are functions of with fixed values of . For this exaple I chose x=1 and x=10 ( corresponds to in the plots above).
The characteristic function of a Poisson random variable does not have a damping factor. It is a pure periodic function. For this reason it is helpful to define it only on .
The integrand of the Gil Pelaez function simply inherits these features.
Option pricing
Let us apply the pricing formula introduced above using the following processes:
Geometric Brownian motion
Merton process
Variance Gamma process
These processes will be described better in the next notebooks. If you are not familiar with these concepts, have a look at the Appendix A3. Otherwise you can skip this part, for now. And come back again after having read the relevant notebooks.
First, I have to implement and :
In the following, I present European call option values, with the following parameters:
Geometric Brownian motion
Merton process
Variance Gamma
The closed formula for the VG price is also available, but it is not very reliable (it has a negative bias). See also the comments in the notebook 3.2. For this reason I prefer to compare the Fourier inversion price with the Monte Carlo price!
Warning: infinite oscillatory integrals!
The naive implementation of and in the functions Q1
and Q2
uses the scipy method quad
which is not very appropriate for infinite oscillatory integrals.
A possible solution could be to set the parameters weight
and wvar
in quad appropriately, or use a more advanced algorithm. However, these integrals must be treated on a case-by-case basis.
For more information about oscillatory integrals have a look at this link.
Example:
As for the pricing problem we are considering, the naive approach above works quite well for a large time to maturity.
For a short time to maturity, OTM and ITM options have problems.
In the following plot we can see that the integrand function has different shapes for different moneyness.
In this example, the quad
method produces a negative price for the call with K=120.
Lewis method
Fourier inversion methods in option pricing allow the use of semi-closed valuation formulas for European options whenever the characteristic function of the log-price is known. There is a large body of literature dealing with Fourier-based pricing methods. Among the most important there are the methods of Carr and Madan (1999) [3] and Lewis (2001) [4].
The Gil-Pelaez approach described above, consists in expressing the "in the money" risk neutral probabilities as the integral of an expression containing the characteristic function of the log-process. Here I present the method of Lewis which instead provides an integral expression for the option price itself. The paper of Lewis can be found here http://optioncity.net/pubs/ExpLevy.pdf.
Tecnical comment (irrelevant to the understanding of the derivation): The functional space is not a subset of (see Lp space), and the definition of the Fourier transform is therefore not directly applicable to every function. The definition does apply, however, if a function is in , and it turns out that the , and (see Placherel and Parseval theorem). This isometry of into can be extended to an isometry of onto , and this extension defines the Fourier transform of every function in .
Derivation of Lewis formula:
The Lewis approach makes use of the Parseval formula, i.e. the Fourier transform preserves the inner product. If we consider the log-price and , the CALL option price is defined as
Since the function is not integrable, the idea is to consider the Generalized Fourier Transform i.e. replace the real variable with a complex variable :
The integral above exists only for some . Using the translation property and the property of the complex conjugation of the characteristic function, we can write
The pricing function becomes:
where we introduced the log-moneyness . At this point, Lewis uses the Residue theorem in order to write this expression in a different form, where the integral is on the orizontal line with imaginary level . The integration is made on a rectangular region containing the pole at . The integral is split on each side of the rectangle:
where the terms and are zero because the integrand is zero at . The residual is
where we recall that . Rearranging the terms we get the alternative expression:
For , we can replance and obtain the final form:
FFT method
Above we have numerically calculated the integral of the Lewis expression. However, when we want to compute the price of a large number of options with the same maturity, the previous method is no more efficient. A solution is to take advantage of the FFT (Fast Fourier Transform) algorithm to reduce the computational cost.
Let us recall that the real part of a complex number is linear, i.e. for we have , and the real part of an integral is the integral of the real part. Thanks to this property, the integral pricing formula can be written in the following form:
At this point we can discretize the integral. Following [3], we use the Simpson rule. The domain of integration is truncated in , and divided in steps of size . We have that and , for . The integral is evaluated in points . The Simpson rule is a 3 points rule that approximates the integral as:
if we sum over the integration domain we get
with for and , and for odd, and for even. Notice that we are not considering the last point!
Let us define a set of values , such that , for . We define the step as
such that we can obtain the value . The integral in the pricing function is:
The scipy function fft returns the following: y(j) = (x * exp(-2*pi*sqrt(-1)*j*np.arange(n)/n)).sum()
.
The scipy function ifft returns: y(j) = (x * exp(2*pi*sqrt(-1)*j*np.arange(n)/n)).mean()
.
Therefore we can use ifft
and then multiply the output by N.
Let us select a set of strikes:
We run the fft_Lewis
function for the three models used in this notebook.
After that, we compute the error (L1 norm) which is considered as the sum of absolute differences between option prices computed by closed formula and FFT. This error is mainly due to the interpolation method used. One property of the FFT method is that the resulting values are on an equally spaced log-moneyness array. But most of the time, the desired values are not on this equidistant array, and therefore we are forced to use interpolation methods to find the intermediate values.
We can see that linear interpolation does not work very well, while cubic spline provides the desired results.
Black Scholes
Merton
Variance Gamma
Performances:
When we want to price several options with same maturity (let's say, more than 10) the FFT method is the best.
References
[1] Martin Schmelze (2010), Option Pricing Formulae using Fourier Transform: Theory and Application.
[2] N.G. Shephard (1991), "From characteristic function to distribution function, a simple framework for the theory", Econometric Theory, 7, 519-529.
[3] Carr, P. and D. Madan (1999). "Option valuation using the fast Fourier transform", Journal of Computational Finance 2(4), 61–73.
[4] Lewis, A. (2001) "A Simple Option Formula for General Jump-Diffusion and other Exponential Lévy Processes", Envision Financial Systems and OptionCity.net, California.
[5] Gil-Pelaez, J. (1951) "Note on the inversion theorem", Biometrika 38(3–4), 481–482.