CommencerCommencer gratuitement

Understanding initialization settings - III

Let's continue the setup of your strategy. First, you will set a trade size of 100,000 USD in an object called tradesize which determines the amount you wager on each trade. Second, you will set your initial equity to 100,000 USD in an object called initeq.

Quantstrat requires three different objects to work: an account, a portfolio, and a strategy. An account is comprised of portfolios, and a portfolio is comprised of strategies. For your first strategy, there will only be one account, one portfolio, and one strategy. Let's call them "firststrat" for "first strategy".

Finally, before proceeding, you must remove any existing strategies using the strategy removal command rm.strat() which takes in a string of the name of a strategy.

The quantstrat and quantmod packages have been loaded for you.

Cet exercice fait partie du cours

Financial Trading in R

Afficher le cours

Instructions

  • Define both tradesize and initeq as integer objects representing $100,000.
  • Set strategy.st, portfolio.st, and account.st to "firststrat".
  • Remove the existing strategy strategy.st using rm.strat().

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Define your trade size and initial equity
tradesize <- ___
initeq <- ___

# Define the names of your strategy, portfolio and account
strategy.st <- ___
portfolio.st <- ___
account.st <- ___

# Remove the existing strategy if it exists
rm.strat(___)
Modifier et exécuter le code