檢視回測的報酬結果
你用簡單移動平均指標實作了一個順勢策略。你以 2019 到 2020 年的 Amazon 股價歷史資料進行回測,右側顯示了結果圖。現在你想要檢視回測結果中的報酬統計。
bt 的回測結果已提供在 bt_result,可直接使用。
本練習屬於課程
Financial Trading in Python
練習說明
- 從
bt_result取得所有回測統計,並儲存到resInfo。 - 從
resInfo列印日、月、年報酬。 - 從
resInfo列印複合年成長率(CAGR)。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Obtain all backtest stats
resInfo = ____
# Get daily, monthly, and yearly returns
print('Daily return: %.4f'% ____)
print('Monthly return: %.4f'% ____)
print('Yearly return: %.4f'% ____)
# Get the compound annual growth rate
print('Compound annual growth rate: %.4f'% ____)