LoslegenKostenlos loslegen

Specifying ordertype in add.rule()

To this point you've specified the signal column, signal value, and order quantity associated with your rule. Next you will specify the type of order you will execute (ordertype).

While there are multiple types of orders in quantstrat, for the scope of this course you will stick to market orders (ordertype = "market"). A market order is an order that states that you will buy or sell the asset at the prevailing price, regardless of the conditions in the market. An alternative type of orders is a limit order, which specifies that the transaction will only take place if certain price conditions are met (namely, if the price falls below a certain further threshold on the day of the order). The mechanics of limit orders are outside the scope of this course.

Diese Übung ist Teil des Kurses

Financial Trading in R

Kurs anzeigen

Anleitung zur Übung

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

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Fill in the ordertype argument in add.rule()
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "filterexit", sigval = TRUE, orderqty = "all", 
                        ordertype = "___", orderside = "long", 
                        replace = FALSE, prefer = "Open"), 
         type = "exit")
Code bearbeiten und ausführen