Aan de slagGa gratis aan de slag

Review return results of a backtest

You implemented a trend-following strategy using a simple moving average indicator. You backtested it using the Amazon stock historical price data from 2019 to 2020, and the result plot is shown on the right. Now you would like to review the return statistics from the backtest result.

The bt backtest result has been provided in bt_result and is ready to use.

Deze oefening maakt deel uit van de cursus

Financial Trading in Python

Cursus bekijken

Oefeninstructies

  • Obtain all backtest stats from bt_result and save them in resInfo.
  • Print the daily, monthly, and yearly returns from resInfo.
  • Print the compound annual growth rate (CAGR) from resInfo.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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'% ____)
Code bewerken en uitvoeren