Session Ready
Exercise

Understanding initialization settings - IV

Now that everything has been named, you must initialize the portfolio, the account, the orders, and the strategy to produce results.

  • The portfolio initialization initPortf() needs a portfolio string name, a vector for symbols used in the backtest, an initialization date initDate, and a currency.
  • The account initialization call initAcct() is identical to the portfolio initialization call except it takes an account string name instead of a new portfolio name, an existing portfolios name, and an initial equity initEq.
  • The orders initialization initOrders() needs a portfolio string portfolio and an initialization date initDate.
  • The strategy initialization strategy() needs a name of this new strategy and must have store set to TRUE.

The initdate and initeq objects that you created in previous exercises have been loaded for you, as well as the quantstrat and quantmod packages.

Instructions
100 XP
  • Use initPortf() to initialize the portfolio called portfolio.st with "SPY", initdate, and "USD" as the arguments.
  • Use initAcct() to initialize the account called account.st with portfolio.st, initdate, "USD", and initeq as the arguments.
  • Use initOrders() to initialize orders called portfolio.st and initdate as the arguments.
  • Use strategy() to store a strategy called strategy.st with store = TRUE as the arguments.