.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/exotic_options/compound/plot_03_chooser.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_compound_plot_03_chooser.py: Rubinstein choosers =================== "Pay now, choose later": the holder of a simple chooser decides at a date :math:`t` whether the option is a call or a put, both struck at :math:`K` and expiring at :math:`T`. Mark Rubinstein (1991) used put-call parity to write the choice as a call plus a put: .. math:: \max(c, p) = c + (K e^{-r(T-t)} - S_t e^{-q(T-t)})^+ \;\Rightarrow\; V = c(S, K, T) + e^{-q(T-t)}\, p(S, K e^{-(r-q)(T-t)}, t). Choosing today is worth the better of the two options; choosing at expiry is a straddle. In between the value rises with the time left to choose. .. GENERATED FROM PYTHON SOURCE LINES 19-38 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from financialkit.exotic_options import chooser_price from financialkit.options import black_scholes_price S, T, r, sigma = 100.0, 1.0, 0.05, 0.25 print(f"Haug (2007), 4.4.1: {chooser_price(50.0, 50.0, 0.25, 0.5, 0.08, 0.25):.4f}") t = np.linspace(0.0, T, 60) fig, axes = plt.subplots(1, 2, figsize=(12, 4)) for K in (90.0, 100.0, 110.0): line = axes[0].plot(t, chooser_price(S, K, t, T, r, sigma), label=f"K = {K:g}")[0] c, p = black_scholes_price(S, K, T, r, sigma), black_scholes_price(S, K, T, r, sigma, option_type="put") axes[0].plot([0, T], [max(c, p), c + p], "o", color=line.get_color()) axes[0].set_xlabel("choice date t (dots: better option, straddle)") axes[0].set_ylabel("chooser value") axes[0].legend() .. image-sg:: /api/gallery/exotic_options/compound/images/sphx_glr_plot_03_chooser_001.png :alt: plot 03 chooser :srcset: /api/gallery/exotic_options/compound/images/sphx_glr_plot_03_chooser_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Haug (2007), 4.4.1: 6.1071 .. GENERATED FROM PYTHON SOURCE LINES 39-41 A Monte Carlo check of the decision rule ---------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 41-56 .. code-block:: Python K, tc = 100.0, 0.5 rng = np.random.default_rng(0) z = rng.standard_normal((2, 50_000)) St = S * np.exp((r - 0.5 * sigma**2) * tc + sigma * np.sqrt(tc) * z[0]) ST = St * np.exp((r - 0.5 * sigma**2) * (T - tc) + sigma * np.sqrt(T - tc) * z[1]) pick_call = black_scholes_price(St, K, T - tc, r, sigma) >= black_scholes_price(St, K, T - tc, r, sigma, option_type="put") y = np.exp(-r * T) * np.where(pick_call, np.maximum(ST - K, 0), np.maximum(K - ST, 0)) print(f"chooser {chooser_price(S, K, tc, T, r, sigma):.4f}, Monte Carlo {y.mean():.4f} +/- {y.std() / np.sqrt(y.size):.4f}") axes[1].hist(St[pick_call], bins=60, alpha=0.6, label="choose the call") axes[1].hist(St[~pick_call], bins=60, alpha=0.6, label="choose the put") axes[1].set_xlabel(f"price at the choice date t = {tc}") axes[1].legend() fig.tight_layout() plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none chooser 17.0412, Monte Carlo 17.0335 +/- 0.0811 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.085 seconds) .. _sphx_glr_download_api_gallery_exotic_options_compound_plot_03_chooser.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/compound/plot_03_chooser.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_chooser.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_chooser.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_chooser.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_