price_option_trapezoid_method module

price_option_trapezoid_method.nu_hat(omega_m, x_0, r, t_discount, sigma, alpha)[source]

Calculate the fourier transform of the normalized European option value.

The transform is available in closed form as:

\[\hat{\nu}_c(w) = \frac{e^{-r(T-t)}}{(\alpha - i \omega)(\alpha - i \omega + 1)} \hat{q}(\omega + (\alpha + 1)i)\]

With q written as:

\[\hat{q}(\omega') = e^{-i (x_0 + (r - \delta - \sigma^2 / 2) (T - t_0) ) \omega' - \frac{\sigma^2 (T - t_0)}{2} \omega' ^ 2}\]
Parameters:

omega_m : Numpy array

The discretized domain the calculate the transform over.

x_0 : double

The log of the initial stock price.

r : double

The risk free interest rate to discount at.

t_discount : double

The difference of t_T - t_0. This is the discount rate.

sigma : double

The volatility of the stock.

alpha : double

The damping parameter. If positive, it prices a call. If negative, a put.

Returns:

transform : Numpy array

The transform calculated at each omega_m.

price_option_trapezoid_method.price_option_trapezoid_method(s_0, k, r, t_0, t_T, sigma, n, h, alpha)[source]

Price a European option by the trapezoid method.

This method calculates the pricing integral obtained from an inverse fourier transform involving the fourier transform of the normalized option price.

The approximation that it calculates is

\[V_k = Re \Big\{ \frac{e^{-\alpha k}}{\pi} \sum_{m = 0}^{N} e^{i \omega_m k} \hat{\nu}(w_m) \Delta \omega_m \Big\}\]
Parameters:

s_0 : double

The initial price of the asset.

k : double

The stike price for the option.

r : double

The risk free interest rate to discount at.

t_0 : double

The initial time.

t_T : double

The terminal time.

sigma : double

The volatility of the stock.

n : int

The number of points to discretize over. Together with h, this determines the frequency domain endpoint on [0, B]. B = n * h.

h : double

The size of the discretization steps.

alpha : double

The damping parameter. If positive, it prices a call. If negative, a put.

Returns:

price: double

The price of the option.

price_option_trapezoid_method.q_hat(omega, x_0, r, sigma)[source]