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.
This exercise is part of the course
Financial Trading in R
Exercise instructions
- Define both
tradesize
andiniteq
as integer objects representing $100,000. - Set
strategy.st
,portfolio.st
, andaccount.st
to"firststrat"
. - Remove the existing strategy
strategy.st
usingrm.strat()
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample 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(___)