ComeçarComece de graça

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.

Este exercício faz parte do curso

Financial Trading in R

Ver curso

Instruções do exercício

  • 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().

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Load the quantstrat package


# Create initdate, from, and to strings
initdate <- ___
from <- ___
to <- ___

# Set the timezone to UTC
Sys.setenv(___)

# Set the currency to USD 
currency(___)
Editar e executar o código