.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/options/trees/plot_02_crr_american_put.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_options_trees_plot_02_crr_american_put.py: Cox-Ross-Rubinstein: the American put and its exercise boundary =============================================================== The binomial tree's real advantage over a closed form is early exercise. At each node an American option is worth the larger of its continuation value and its immediate exercise value, so backward induction prices it as easily as a European option. For a put, early exercise is optimal once the stock falls below a critical price :math:`S^*(t)` that rises towards the strike as expiry approaches. .. GENERATED FROM PYTHON SOURCE LINES 14-20 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from financialkit.options import CRRTree, black_scholes_price from financialkit.options.visualizers import plot_exercise_boundary .. GENERATED FROM PYTHON SOURCE LINES 21-23 Hull's Example 21.1: five steps ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 23-29 .. code-block:: Python res = CRRTree(5).price(50.0, 50.0, 5 / 12, 0.10, 0.40, option_type="put", american=True) print(f"American put on a five-step tree: {res.price:.2f} (Hull: 4.49)") for n in (30, 50, 100, 500): print(f" {n:3d} steps: {CRRTree(n).price(50.0, 50.0, 5 / 12, 0.10, 0.40, option_type='put', american=True).price:.3f}") .. rst-class:: sphx-glr-script-out .. code-block:: none American put on a five-step tree: 4.49 (Hull: 4.49) 30 steps: 4.263 50 steps: 4.272 100 steps: 4.278 500 steps: 4.283 .. GENERATED FROM PYTHON SOURCE LINES 30-32 The early-exercise premium and boundary --------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 32-51 .. code-block:: Python K, T, r, sigma = 100.0, 1.0, 0.08, 0.25 spots = np.linspace(60, 140, 41) american = [CRRTree(200).price(s, K, T, r, sigma, option_type="put", american=True).price for s in spots] european = black_scholes_price(spots, K, T, r, sigma, option_type="put") fig, axes = plt.subplots(1, 2, figsize=(11, 4)) axes[0].plot(spots, american, label="American (CRR, 200 steps)") axes[0].plot(spots, european, "--", label="European (Black-Scholes)") axes[0].plot(spots, np.maximum(K - spots, 0), "k:", label="exercise value") axes[0].set_xlabel("spot S") axes[0].set_ylabel("put value") axes[0].legend() plot_exercise_boundary(CRRTree(400).price(100.0, K, T, r, sigma, option_type="put", american=True), ax=axes[1]) axes[1].axhline(K, color="k", lw=0.5) axes[1].set_title("exercise when the stock is below the boundary") fig.tight_layout() plt.show() .. image-sg:: /api/gallery/options/trees/images/sphx_glr_plot_02_crr_american_put_001.png :alt: exercise when the stock is below the boundary :srcset: /api/gallery/options/trees/images/sphx_glr_plot_02_crr_american_put_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.167 seconds) .. _sphx_glr_download_api_gallery_options_trees_plot_02_crr_american_put.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/options/trees/plot_02_crr_american_put.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_crr_american_put.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_crr_american_put.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_crr_american_put.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_