Specifying orderside in add.rule()
The next critical argument to specify in your order is orderside
, which can take two values: either long
or short
. In quantstrat, long and short side trades are siloed off separately so that quantstrat knows whether a trade is a long trade or a short trade. A long trade is one that profits by buying an asset in the hopes that the asset's price will rise. A short trade is one that sells an asset before owning it, hoping to buy it back later at a lower price.
For your strategy, you will want to take only long orders.
This exercise is part of the course
Financial Trading in R
Exercise instructions
- The
add.rule()
command from the previous exercise has been loaded into your workspace. - Define your order side as
long
by specifying theorderside
argument.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Fill in the orderside argument in add.rule()
add.rule(strategy.st, name = "ruleSignal",
arguments = list(sigcol = "filterexit", sigval = TRUE, orderqty = "all",
ordertype = "market", orderside = "___",
replace = FALSE, prefer = "Open"),
type = "exit")