MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Financial Trading in R

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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(___)
Edit dan Jalankan Kode