.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/fraud/schemes/plot_03_bitconnect_lending_ponzi.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_fraud_schemes_plot_03_bitconnect_lending_ponzi.py: BitConnect and lending-platform Ponzis (2018) ============================================= BitConnect took bitcoin deposits into a "lending program" and credited interest of around 1% a day, said to come from a trading bot. Nothing was traded: interest and withdrawals were paid out of new deposits, and recruiters earned commissions down several levels of the investors they brought in. Credited balances compound, so the liabilities grow as .. math:: L_t = L_{t-1}(1 + i) + D_t - W_t, \qquad (1.01)^{365} \approx 38, while the cash grows only with new deposits. Texas and North Carolina regulators ordered it to stop in January 2018, deposits dried up, and the platform closed within two weeks; the SEC later charged it with a two-billion-dollar fraud. .. GENERATED FROM PYTHON SOURCE LINES 22-27 .. code-block:: Python import matplotlib.pyplot as plt import blockchainkit as bk from blockchainkit.fraud.visualizers import plot_ponzi .. GENERATED FROM PYTHON SOURCE LINES 28-30 Deposits grow, then stop at a regulator's order ----------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 30-44 .. code-block:: Python deposits = [100 * 1.03**day for day in range(120)] + [10.0] * 60 run = bk.fraud.simulate_lending_ponzi(deposits, daily_rate=0.01, withdrawal_rate=0.02) print(f"collapsed on day {run.collapse}; raised {run.raised:,.0f}, paid out {run.repaid:,.0f}") print(f"balances credited to investors at the end: {run.owed[-1]:,.0f}") assert run.collapse is not None and 120 < run.collapse < 180 assert run.cash[-1] == 0 and run.owed[-1] > 0.5 * run.raised # Owed, with nothing left. fig, ax = plt.subplots(figsize=(9, 4)) plot_ponzi(run, ax=ax) ax.set_xlabel("day") ax.set_yscale("symlog", linthresh=100) fig.tight_layout() .. image-sg:: /api/gallery/fraud/schemes/images/sphx_glr_plot_03_bitconnect_lending_ponzi_001.png :alt: Ponzi scheme: collapsed in period 149 :srcset: /api/gallery/fraud/schemes/images/sphx_glr_plot_03_bitconnect_lending_ponzi_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none collapsed on day 149; raised 112,670, paid out 112,670 balances credited to investors at the end: 62,168 .. GENERATED FROM PYTHON SOURCE LINES 45-49 The referral pyramid -------------------- Each investor recruits two more, three levels deep, and every recruiter earns 7%, 3%, 2% and 1% on the deposits one to four levels below it. .. GENERATED FROM PYTHON SOURCE LINES 49-77 .. code-block:: Python sponsors, deposits_by = {}, {"root": 1_000.0} level = ["root"] for _ in range(4): nxt = [] for parent in level: for k in range(2): child = f"{parent}.{k}" sponsors[child] = parent deposits_by[child] = 1_000.0 nxt.append(child) level = nxt commissions = bk.fraud.referral_commissions(sponsors, deposits_by) by_depth = {} for name, earned in commissions.items(): by_depth.setdefault(name.count("."), []).append(earned) averages = [sum(v) / len(v) for _, v in sorted(by_depth.items())] print("average commission by depth:", [round(a) for a in averages]) assert averages == sorted(averages, reverse=True) # The top of the pyramid earns most. fig, ax = plt.subplots(figsize=(6, 4)) ax.bar(range(len(averages)), averages, color="#9333ea") ax.set(xlabel="depth in the referral tree", ylabel="commission earned") ax.set_title("Commissions flow to the top") fig.tight_layout() plt.show() .. image-sg:: /api/gallery/fraud/schemes/images/sphx_glr_plot_03_bitconnect_lending_ponzi_002.png :alt: Commissions flow to the top :srcset: /api/gallery/fraud/schemes/images/sphx_glr_plot_03_bitconnect_lending_ponzi_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none average commission by depth: [580, 420, 260, 140] .. GENERATED FROM PYTHON SOURCE LINES 78-83 Exercise -------- With 1% daily interest and no withdrawals, how fast must daily deposits grow for the cash to keep pace with the credited balances? Compare with the breakeven growth of Ponzi's own scheme. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.146 seconds) .. _sphx_glr_download_api_gallery_fraud_schemes_plot_03_bitconnect_lending_ponzi.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/fraud/schemes/plot_03_bitconnect_lending_ponzi.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_bitconnect_lending_ponzi.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_bitconnect_lending_ponzi.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_bitconnect_lending_ponzi.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_