Exercise

Understanding initialization settings - I

Define boilerplate code

Let's get started with creating our first strategy in quantstrat. In this exercise, you will need to fill in three dates:

  1. An initialization date for your backtest.
  2. The start of your data.
  3. The end of your data.

The initialization date must always come before the start of the data, otherwise there will be serious errors in the output of your backtest.

You should also specify what time zone and currency you will be working with with the functions Sys.setenv() and currency(), respectively. An example is here:

Sys.setenv(TZ = "Europe/London")
currency("EUR")

For the rest of this course, you'll use UTC (Coordinated Universal Time) and USD (United States Dollars) for your portfolio settings.

Instructions

100 XP
  • Use the library() command to load the quantstrat package.
  • Set initdate as January 1, 1999, from as January 1, 2003, and to as December 31, 2015.
  • Set a timezone of "UTC" using Sys.setenv().
  • Set a currency of "USD" using currency().