Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Financial Trading in R

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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(___)
Code bewerken en uitvoeren