ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Financial Trading in R

Ver curso

Instrucciones del ejercicio

  • The add.rule() command from the previous exercise has been loaded into your workspace.
  • Define your order side as long by specifying the orderside argument.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# 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")
Editar y ejecutar código