COS method

The method comes from [R1]

The original code is found at http://www.wilmott.com/messageview.cfm?catid=34&threadid=78554

References

[R1]Fang, F., & Oosterlee, C. W. (2009). A Novel Pricing Method for European Options Based on Fourier-Cosine Series Expansions. SIAM Journal on Scientific Computing, 31(2), 826. doi:10.1137/080718061 <http://ta.twi.tudelft.nl/mf/users/oosterle/oosterlee/COS.pdf>
fangoosterlee.cosmethod.cosmethod(model, moneyness=0.0, call=True, npoints=1024)[source]

COS method.

Parameters:

model : instance of specific model class

The method depends on availability of two methods:
  • charfun
  • cos_restriction

moneyness : array_like

Moneyness of the option, np.log(strike/price) - riskfree * maturity

call : bool array_like

Call/Put flag

npoints : int

Number of points on the grid. The more the better, but slower.

Returns:

array_like

Option premium normalized by asset price

Notes

charfun method (risk-neutral conditional chracteristic function) of model instance should depend on one argument only (array_like) and should return array_like of the same dimension.

cos_restriction method of model instance takes maturity and riskfree as array arguments, and returns two corresponding arrays (a, b).

Inverse of characteristic function

Read Carr & Madan (1999) for idea of derivation

fangoosterlee.cfinverse.cfinverse(psi, alim=-100000.0, blim=100000.0, points=100000.0)[source]

Discrete Fourier inverse.

Inverts characteristic function to obtain the density.

Parameters:

psi : function

Characteristic function dependent only on u

alim : float, optional

Lower limit of integration

blim : float, optional

Upper limit of integration

points : int, optional

Number of discrete points for evaluation

Returns:

grid : (points, ) array

Domain of the resulting density

density : (points, ) array

Density values