.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/exotic_options/asian/plot_02_turnbull_wakeman.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_exotic_options_asian_plot_02_turnbull_wakeman.py: Turnbull-Wakeman Asian approximation ==================================== Stuart Turnbull and Lee Wakeman (1991) priced the arithmetic average :math:`A` as if it were lognormal with the right first two moments: Black's formula on the forward :math:`E[A]` with volatility .. math:: \sigma_A^2 = \frac{1}{T}\ln\frac{E[A^2]}{E[A]^2}. The moments are exact (Levy's sums for discrete fixings), only the shape of the distribution is approximated. The approximation is excellent at moderate volatility and drifts as the average's distribution grows more skewed than a lognormal. .. GENERATED FROM PYTHON SOURCE LINES 18-29 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from financialkit.exotic_options import arithmetic_asian_mc, geometric_asian_price, turnbull_wakeman_price S, K, T, r, n = 100.0, 100.0, 1.0, 0.05, 12 sigmas = np.array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6]) mc = [arithmetic_asian_mc(S, K, T, r, s, n_fixings=n, n_paths=20_000, rng=3) for s in sigmas] tw = np.array([turnbull_wakeman_price(S, K, T, r, s, n_fixings=n) for s in sigmas]) geo = geometric_asian_price(S, K, T, r, sigmas, n_fixings=n) .. GENERATED FROM PYTHON SOURCE LINES 30-32 Approximation against controlled Monte Carlo -------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 32-48 .. code-block:: Python fig, axes = plt.subplots(1, 2, figsize=(12, 4)) axes[0].plot(sigmas, tw, "s-", label="Turnbull-Wakeman") axes[0].errorbar(sigmas, [m.estimate for m in mc], yerr=[2 * m.std_error for m in mc], fmt="o", label="Monte Carlo") axes[0].plot(sigmas, geo, ":", label="geometric (lower bound)") axes[0].set_xlabel(r"volatility $\sigma$") axes[0].set_ylabel("at-the-money arithmetic Asian call") axes[0].legend() rel = (tw - np.array([m.estimate for m in mc])) / np.array([m.estimate for m in mc]) axes[1].bar(sigmas, 100 * rel, width=0.06) axes[1].set_xlabel(r"volatility $\sigma$") axes[1].set_ylabel("relative error (%)") fig.tight_layout() for s, t, m in zip(sigmas, tw, mc, strict=True): print(f"sigma = {s:.1f}: TW {t:.4f}, MC {m.estimate:.4f} +/- {m.std_error:.4f}") plt.show() .. image-sg:: /api/gallery/exotic_options/asian/images/sphx_glr_plot_02_turnbull_wakeman_001.png :alt: plot 02 turnbull wakeman :srcset: /api/gallery/exotic_options/asian/images/sphx_glr_plot_02_turnbull_wakeman_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none sigma = 0.1: TW 3.9105, MC 3.9056 +/- 0.0005 sigma = 0.2: TW 6.1742, MC 6.1587 +/- 0.0017 sigma = 0.3: TW 8.5178, MC 8.4808 +/- 0.0038 sigma = 0.4: TW 10.8892, MC 10.8133 +/- 0.0069 sigma = 0.5: TW 13.2800, MC 13.1401 +/- 0.0113 sigma = 0.6: TW 15.6890, MC 15.4559 +/- 0.0171 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.173 seconds) .. _sphx_glr_download_api_gallery_exotic_options_asian_plot_02_turnbull_wakeman.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/exotic_options/asian/plot_02_turnbull_wakeman.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_turnbull_wakeman.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_turnbull_wakeman.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_turnbull_wakeman.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_