🐵
金融計算
  • 市場
    • [書]美中貿易戰, 戰什麼?:大國崛起與制度之爭
    • [書]基本分析在台灣股市應用的訣竅
      • 總體經濟分析篇
    • 固定收益證券
    • 債券(bond)
    • 費雪方程式
    • 可轉換公司債
    • 股債雙殺
    • 特別股
    • 指標
    • Howard Marks' memo
      • 2022-Q1
    • 國安基金
  • LPPL
    • 冪分佈
      • Power-Law Distributions in Empirical Data
      • Power-law distributions in binned empirical data
    • 泡沫理論與實證
    • 重整化群
    • Large financial crashes
    • LPPLS模型參數分解
    • [書]Critical Phenomena in Natural Sciences
      • Notions of Probability Theory
    • [書]Why Stock Markets Crash
      • 1. financial crashes: what, how, why, and when?
      • 2.fundamentals of financial markets
      • 3. financial crashes are “outliers”
      • 4. positive feedbacks
      • 5. modeling financial bubbles and market crashes
      • 6. hierarchies, complex fractal dimensions, and log-periodicity
      • 7. autopsy of major crashes
      • 8. bubbles, crises, and crashes in emergent markets
      • 9. prediction of bubbles, crashes, and antibubbles
      • 10. the end of the growth era?
  • 交易心理
    • [書]致富心態:關於財富、貪婪與幸福的20堂理財課
    • [書]我靠交易賺大錢:從散戶到專職操盤手的真實獲利法則
    • [書]存好股,我穩穩賺:沒有飆股的年頭,168曲線幫你賺百萬
  • 金融工程
    • 金融工程
    • 金錢的時間價值
    • chat with trader: David Sun
  • 經濟理論
    • 經濟學
      • 需求與供給
      • 獨占性競爭(monopolistic competition)
    • [書]耶魯最受歡迎的金融通識課
    • [書]經濟學-理論與實際
    • [書]政府的錢去那了
    • [書]華爾街不讓你知道的投資金律:掀開美國華爾街黑幕與聯準會祕辛, 頂尖投資專家揭露真正的價值投資策略
    • 國內生產毛額(GDP)
  • 貨幣
    • [書]看懂外匯就能掌握經濟脈動
    • [書]貨幣戰爭
    • 廉價貨幣
    • 貨幣乘數
    • 貨幣定義與起源
    • 貨幣本位制度
    • 殖利率曲線倒掛
    • 利率
    • 逆回購
    • 美元指數
    • 影子銀行
    • M1 及 M2 貨幣供給
    • 貨幣互換
    • 信用違約互換
    • 利率交換(互換、掉期)
    • 台北金融業拆款定盤利率,TAIBOR
    • 現代貨幣理論
      • MMT FAQ
      • [書]赤字迷思
  • 財務報表
    • 財務報表-資產負債表
      • 損益表
      • 現金流量表
      • 股東權益變動表
      • 會計師查核報告書
      • 常見財務比率
      • 本益比與股價淨值比
      • 減資與增資
      • 股東權益報酬率與總資產報酬率(ROE, ROA)
      • 金融股分析
    • [書]大會計師教你從財報數字看懂經營本質
    • [書]財報就像一本故事書
    • [書]不懂財報,也能輕鬆選出賺錢績優股:五大關鍵數字力
    • 假財報範例
    • Beneish M-score
    • Altman Z-score
    • Piotroski F-Score
    • 子公司
  • 資料來源
    • FRED(Federal Reserve Economic Data)
    • 台灣經濟新報(TEJ)
    • 報價訊號源
  • 選擇權
    • 權證
    • 牛熊證
    • 時間價差(time spread)
  • 金融事件
    • 2008次級房貸
Powered by GitBook
On this page
  • LPPLS模型
  • 冪律(power law)
  • 對數週期(log-periodic)
  1. LPPL

LPPLS模型參數分解

LPPLS模型

E(ln⁡p(t))=A+B(tc−t)m+C(tc−t)mcos⁡(ωln⁡(tc−t)−ϕ)\mathrm{E}(\ln p(t))=A+B(t_c-t)^m + C(t_c -t)^m\cos (\omega \ln (t_c -t)- \phi)E(lnp(t))=A+B(tc​−t)m+C(tc​−t)mcos(ωln(tc​−t)−ϕ)

  • E(ln⁡p(t))\mathrm{E}(\ln p(t))E(lnp(t))​:泡沫終止之日的預期對數價格。

  • tct_ctc​:臨界時間(泡沫終止和過渡至新制度的日期)。

  • AAA:泡沫結束時的預期對數價格,在tct_ctc​時達到峰值。

  • BBB​:冪律加速度的振幅。

  • CCC​:對數週期性振蕩的振幅。

  • mmm​:超指數增長(super exponential growth)的程度。

  • ω\omegaω​:震蕩的時間層次的縮放比例。

  • ϕ\phiϕ​:震蕩的時間尺度。

總共有7個待定的參數(tc,A,B,C,m,ω,ϕ)(t_c, A, B, C, m, \omega, \phi)(tc​,A,B,C,m,ω,ϕ)。

該模型有三個組成部分,代表一個泡沫。

  1. A+B(tc−t)mA+B(t_c-t)^mA+B(tc​−t)m​:處理雙曲冪律(power law),正向回饋(positive feedback)。對於m<1m<1m<1時,價格增長變得不可持續,而在臨界時間tct_ctc​,增長率變得無限大。

  2. C(tc−t)mC(t_c-t)^mC(tc​−t)m:控制對數週期(log-periodic)振盪的振幅,在臨界時間tct_ctc​,其值下降到零。

  3. cos⁡(ωln⁡(tc−t)−ϕ)\cos(\omega \ln(t_c -t)- \phi)cos(ωln(tc​−t)−ϕ)​:對數週期頻率中的振盪建模,在臨界時間tct_ctc​​時變得無限大。

冪律(power law)

考慮LPPLS模型中A+BtmA+Bt^mA+Btm​的部份,其中0<m<10<m<10<m<1​,此限制要求在tct_ctc​​處收斂,如果m>1m>1m>1​時,會在tct_ctc​​處發散。

# -*- coding: UTF-8 -*-
import numpy as np
import matplotlib.pyplot as plt


def power_law_component(a=2, b=3):
    t = np.linspace(1, 3, 5000)
    fig, ax = plt.subplots(2, 1, figsize=(7, 4))
    for m in np.linspace(0.01, 1. - 0.0001, 30):
        logp = a + b * t ** m
        p = np.exp(logp)
        if m > 0.8:
            ax[0].plot(t, p, label=f"m={m:.2f}")
            ax[1].plot(t, logp, label=f"m={m:.2f}")
        else:
            ax[0].plot(t, p)
            ax[1].plot(t, logp)
    for adx in range(2):
        ax[adx].legend(loc="upper left")
        ax[adx].set_xlabel("t")
        ax[0].set_title(
            r'$log(price)='
            r'{} {} {}t^m$'.format(a, "+" if b >= 0 else "", b),
            fontsize=16, color='k')

    ax[0].set_ylabel(r'price')
    ax[1].set_ylabel(r'$\log(price)$')

    plt.show()


if __name__ == '__main__':
    power_law_component(2, -3)

因為是log⁡(price)=A+Btm\log(\text{price})=A+Bt^mlog(price)=A+Btm​,可得price=eA+Btm=eA⋅meBt\text{price}=e^{A+Bt^m}=e^A \cdot me^{Bt}price=eA+Btm=eA⋅meBt。

所以m→0m\rightarrow0m→0​時,price→0\text{price} \rightarrow 0price→0​;反之m→1m \rightarrow 1m→1​時,價格越像指數函數。

這個冪徑的部分決定了大趨勢的向上指數增長,或向下加速下降。當 BBB負數時,則為指數加速下降。

對數週期(log-periodic)

這一部分決定了幅度遞減振盪。越接近於奇點(泡沫破裂點tct_ctc​ ),振盪越小,最後振盪在tct_ctc​處停止,則引發相變。 tct_ctc​相變臨界點。

對數是指xxx​軸取了log⁡(t)\log(t)log(t),而週期是指cos⁡\coscos​週期振盪,而C(tc−t)mC(t_c-t)^mC(tc​−t)m是振盪的振幅,在t→tct \rightarrow t_ct→tc​​時會逐漸減小。

# -*- coding: UTF-8 -*-
import numpy as np
import matplotlib.pyplot as plt


def log_periodic(cs=[0.5, 1, 1.5, 2], omegas=[8, 16, 24, 32],
                 phis=[100, 200, 300, 400], ms=[0.25, 0.5, 0.75, 0.90]):
    fig, ax = plt.subplots(4, 1, figsize=(7, 4))
    tc = 500
    t = np.linspace(1, tc - 0.1, tc)  # [::-1]
    for c in cs:
        omega = omegas[0]
        phi = phis[0]
        m = ms[0]
        ax[0].plot(t, c * (tc - t) ** (m) * np.cos(omega * np.log(tc - t) - phi),
                   label=f"c={c:.2f}")
        ax[0].legend(loc="lower left")
        ax[0].set_xlabel("t")
        ax[0].set_ylabel("price")
    ax[0].set_title(
        r'$\log(price)='
        r'c({tc}-t)^{m:.2f} \cos({omega} \log({tc}-t)-{phi})$, m={m:.2f}'.format(
            tc=tc, omega=omega, phi=phi, m=m),
        # fontsize=14,
        color='k')

    for omega in omegas:
        c = cs[0]
        phi = phis[0]
        m = ms[0]
        ax[1].plot(t, c * (tc - t) ** (m) * np.cos(omega * np.log(tc - t) - phi),
                   label=f"$\omega$={omega:.2f}")
        ax[1].legend(loc="lower left")
        ax[1].set_xlabel("t")
        ax[1].set_ylabel("price")
    ax[1].set_title(
        r'$\log(price)='
        r'{c}({tc}-t)^m \cos(\omega \log({tc}-t)-{phi})$, m={m:.2f}'.format(
            c=c, tc=tc, phi=phi, m=m),
        # fontsize=14,
        color='k')

    for phi in phis:
        c = cs[0]
        omega = omegas[0]
        m = ms[0]
        ax[2].plot(t, c * (tc - t) ** (m) * np.cos(omega * np.log(tc - t) - phi),
                   label=f"$\phi$={phi:.2f}")
        ax[2].legend(loc="lower left")
        ax[2].set_xlabel("t")
        ax[2].set_ylabel("price")
    ax[2].set_title(
        r'$\log(price)='
        r'{c}({tc}-t)^m \cos({omega} \log({tc}-t)-\phi)$, m={m:.2f}'.format(
            c=c, omega=omega, tc=tc, m=m),
        # fontsize=14,
        color='k')

    for m in ms:
        c = cs[0]
        omega = omegas[0]
        phi = phis[0]
        ax[3].plot(t, c * (tc - t) ** (m) * np.cos(omega * np.log(tc - t) - phi),
                   label=f"$m$={m:.2f}")
        ax[3].legend(loc="lower left")
        ax[3].set_xlabel("t")
        ax[3].set_ylabel("price")
    ax[3].set_title(
        r'$\log(price)='
        r'{c}({tc}-t)^m \cos({omega} \log({tc}-t)-{phi})$'.format(
            c=c, omega=omega, tc=tc, phi=phi),
        # fontsize=14,
        color='k')

    # plt.tight_layout()
    # wspace 和 hspace 指定子圖之間保留的空間。它們分別是軸的寬度和高度的分數。
    plt.subplots_adjust(left=0.125,
                        bottom=0.1,
                        right=0.9,
                        top=0.9,
                        wspace=0.2,
                        hspace=0.5)
    plt.show()


if __name__ == '__main__':
    log_periodic()
PreviousLarge financial crashesNext[書]Critical Phenomena in Natural Sciences

Last updated 2 years ago

對數價格在相異m值的變化速度, b>0
對數價格在相異m值的變化速度, b<0
對數週期相異參數的變化