Financial Trading in Python
Chelsea Yang
Data Science Instructor
回撤是資產或交易帳戶在特定期間從高點跌至低點的降幅。

$\text{Max Drawdown} = (V_p - V_l)/ V_l $
$V_p$:最大下跌前的高點值
$V_l$:創新高前的最低值

最大回撤
= (A 點值 − D 點值)/ A 點值 = (1700 - 800)/1700 = 53%
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
CALMAR:California Managed Accounts Report(加州管理帳戶報告)
$ Calmar = CAGR / \text{Max Drawdown} $
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
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