回撤

Financial Trading in Python

Chelsea Yang

Data Science Instructor

什麼是回撤?

回撤是資產或交易帳戶在特定期間從高點跌至低點的降幅。

回撤圖

Financial Trading in Python

最大回撤

$\text{Max Drawdown} = (V_p - V_l)/ V_l $

$V_p$:最大下跌前的高點值

$V_l$:創新高前的最低值

最大回撤範例

最大回撤

= (A 點值 − D 點值)/ A 點值 = (1700 - 800)/1700 = 53%

Financial Trading in Python

從回測統計取得回撤指標

resInfo = bt_result.stats

# Get the max drawdown max_drawdown = resInfo.loc['max_drawdown'] print('Maximum drawdown: %.2f'% max_drawdown)
# Get the average drawdown avg_drawdown = resInfo.loc['avg_drawdown'] print('Average drawdown: %.2f'% avg_drawdown)
# Get the average drawdown days avg_drawdown_days = resInfo.loc['avg_drawdown_days'] print('Average drawdown days: %.0f'% avg_drawdown_days)
Maximum drawdown: -0.59
Average drawdown: -0.11
Average drawdown days: 22
Financial Trading in Python

Calmar 比率

CALMAR:California Managed Accounts Report(加州管理帳戶報告)

 

$ Calmar = CAGR / \text{Max Drawdown} $

  • Calmar 比率越高,代表策略在風險調整後的表現越好。
  • 一般而言,Calmar 比率大於 3 被視為表現極佳。
Financial Trading in Python

手動計算 Calmar 比率

resInfo = bt_result.stats
# Get the CAGR
cagr = resInfo.loc['cagr']
# Get the max drawdown
max_drawdown = resInfo.loc['max_drawdown']

# Calculate Calmar ratio mannually calmar_calc = cagr / max_drawdown * (-1) print('Calmar Ratio calculated: %.2f'% calmar_calc)
Calmar Ratio calculated: 4.14
Financial Trading in Python

從回測統計取得 Calmar 比率

resInfo = bt_result.stats

# Get the Calmar ratio
calmar = resInfo.loc['calmar']
print('Calmar Ratio: %.2f'% calmar)
Calmar Ratio: 4.14
Financial Trading in Python

一起來練習吧!

Financial Trading in Python

Preparing Video For Download...