.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/stochastic_volatility/jumps/plot_05_kou.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_stochastic_volatility_jumps_plot_05_kou.py: Kou's double-exponential jumps ============================== Steven Kou (2002) took the log jump sizes to be exponential, with rate :math:`\eta_1` upward (probability :math:`p`) and :math:`\eta_2` downward. The two exponential tails give the asymmetric, leptokurtic returns seen in data, and because the exponential distribution is memoryless the overshoot over a barrier is again exponential, which makes barrier and lookback options tractable. The tails also cap the moments, :math:`E[S_T^{s}] < \infty` only for :math:`-\eta_2 < s < \eta_1`. .. GENERATED FROM PYTHON SOURCE LINES 15-28 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from financialkit.stochastic_volatility import KouModel, MertonJumpModel, cos_density from financialkit.stochastic_volatility.visualizers import plot_density m = KouModel(sigma=0.16, lam=1.0, p=0.4, eta1=10.0, eta2=5.0) print(f"call S = 100, K = 98, T = 0.5, r = 5%: {m.price(100.0, 98.0, 0.5, 0.05):.5f} (Kou 2002: 9.14732)") x = m.sample_terminal(0.5, 200_000, rng=0) pay = np.exp(-0.025) * np.maximum(100 * np.exp(0.025) * np.exp(x) - 98.0, 0.0) print(f"Monte Carlo: {pay.mean():.4f} +/- {2 * pay.std() / np.sqrt(pay.size):.4f}") .. rst-class:: sphx-glr-script-out .. code-block:: none call S = 100, K = 98, T = 0.5, r = 5%: 9.14732 (Kou 2002: 9.14732) Monte Carlo: 9.1638 +/- 0.0539 .. GENERATED FROM PYTHON SOURCE LINES 29-35 Exponential against Gaussian jump tails --------------------------------------- A Merton model with the same jump intensity and the same jump mean and variance has Gaussian jump tails; on a log scale Kou's tails are straight lines, Merton's parabolas. .. GENERATED FROM PYTHON SOURCE LINES 35-47 .. code-block:: Python p, e1, e2 = m.p, m.eta1, m.eta2 mean = p / e1 - (1 - p) / e2 var = 2 * p / e1**2 + 2 * (1 - p) / e2**2 - mean**2 merton = MertonJumpModel(0.16, 1.0, mean, np.sqrt(var)) grid = np.linspace(-2.5, 1.5, 400) fig, ax = plt.subplots(figsize=(7, 4)) plot_density(grid, np.maximum(cos_density(m, grid, 1.0, N=1024), 1e-12), ax=ax, label="Kou", log=True) plot_density(grid, np.maximum(cos_density(merton, grid, 1.0, N=1024), 1e-12), ax=ax, label="Merton, matched jumps", log=True) ax.set_ylim(1e-8, 5) plt.show() .. image-sg:: /api/gallery/stochastic_volatility/jumps/images/sphx_glr_plot_05_kou_001.png :alt: plot 05 kou :srcset: /api/gallery/stochastic_volatility/jumps/images/sphx_glr_plot_05_kou_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.073 seconds) .. _sphx_glr_download_api_gallery_stochastic_volatility_jumps_plot_05_kou.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/stochastic_volatility/jumps/plot_05_kou.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_05_kou.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_05_kou.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_05_kou.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_