計算並檢視 Calmar 比率
延續同一個策略。根據上一個練習,你知道平均回撤大約是 11%,而平均持續期間為 22 天。現在你想更深入了解它的風險報酬特性。你打算先檢視 CAGR 與最大回撤,接著用它們計算 Calmar 比率並評估結果。
已為你提供包含所有回測統計的 resInfo DataFrame。
本練習屬於課程
Financial Trading in Python
練習說明
- 從
resInfo取得複合年成長率(CAGR)。 - 從
resInfo取得最大回撤。 - 使用
cagr與max_drawdown計算 Calmar 比率。 - 直接從
resInfo取得 Calmar 比率並加以檢視。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Get the CAGR
cagr = ____
print('Compound annual growth rate: %.4f'% cagr)
# Get the max drawdown
max_drawdown = ____
print('Maximum drawdown: %.2f'% max_drawdown)
# Calculate Calmar ratio manually
calmar_calc = ____ / ____ * (-1)
print('Calmar Ratio calculated: %.2f'% calmar_calc)
# Get the Calmar ratio
calmar = ____
print('Calmar Ratio: %.2f'% calmar)