.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/time_value/annuities/plot_03_price_sinking_fund.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_time_value_annuities_plot_03_price_sinking_fund.py: Price's sinking fund ==================== In *An Appeal to the Public on the Subject of the National Debt* (1772) Richard Price showed what compound interest could do for a nation in debt: a fixed sum set aside every year and left to accumulate at interest would grow to repay the debt. The level deposit that reaches a target :math:`F` in :math:`n` periods is :math:`F / s_{\overline{n}|}`. Pitt's sinking fund of 1786 put the idea into practice. .. GENERATED FROM PYTHON SOURCE LINES 14-19 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from financialkit.time_value import sinking_fund_payment, sinking_fund_schedule .. GENERATED FROM PYTHON SOURCE LINES 20-22 Repaying a debt of 1,000,000 in 30 years at 5% ---------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 22-27 .. code-block:: Python s = sinking_fund_schedule(1_000_000.0, 0.05, 30) print(f"annual deposit: {s.deposit:,.0f}") print(f"total deposited: {30 * s.deposit:,.0f}; interest earned: {s.interest.sum():,.0f}") .. rst-class:: sphx-glr-script-out .. code-block:: none annual deposit: 15,051 total deposited: 451,543; interest earned: 548,457 .. GENERATED FROM PYTHON SOURCE LINES 28-30 How interest does the work -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 30-49 .. code-block:: Python fig, axes = plt.subplots(1, 2, figsize=(11, 4)) deposits = np.full(30, s.deposit) axes[0].bar(s.periods, deposits, label="deposit") axes[0].bar(s.periods, s.interest, bottom=deposits, label="interest earned") axes[0].plot(s.periods, s.balance / 10, "k", label="fund balance / 10") axes[0].set_xlabel("year") axes[0].legend() n = np.arange(5, 61) for r in (0.03, 0.05, 0.07): axes[1].plot(n, sinking_fund_payment(1_000_000.0, r, n) * n / 1e6, label=f"{r:.0%}") axes[1].set_xlabel("years to repay") axes[1].set_ylabel("total deposits per unit of debt") axes[1].set_title("Longer horizons let interest pay more of the debt") axes[1].legend() fig.tight_layout() plt.show() .. image-sg:: /api/gallery/time_value/annuities/images/sphx_glr_plot_03_price_sinking_fund_001.png :alt: Longer horizons let interest pay more of the debt :srcset: /api/gallery/time_value/annuities/images/sphx_glr_plot_03_price_sinking_fund_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.074 seconds) .. _sphx_glr_download_api_gallery_time_value_annuities_plot_03_price_sinking_fund.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/time_value/annuities/plot_03_price_sinking_fund.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_price_sinking_fund.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_price_sinking_fund.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_price_sinking_fund.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_