BaşlayınÜcretsiz Başlayın

Specifying orderqty in add.rule()

Now that you have a grasp of the first set of arguments in the add.rule() function, it's time to move on to the more important arguments: the actual order being bought or sold! The orderqty argument in the ruleSignal specifies exactly how much of an asset you want to buy or sell, in numbers of shares.

However, one salient feature of the exit rule type is that you can reduce your position to zero instantly with the all argument (hence, exiting). This is the mechanism we will implement in this exercise.

Bu egzersiz

Financial Trading in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • The add.rule() command from the previous exercise has been loaded into your workspace.
  • Specify that you'd like to reduce your position to zero by filling in the orderqty argument.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Fill in the orderqty argument in add.rule()
add.rule(strategy.st, name = "ruleSignal", 
         arguments = list(sigcol = "filterexit", sigval = TRUE, orderqty = "___", 
                        ordertype = "market", orderside = "long", 
                        replace = FALSE, prefer = "Open"), 
         type = "exit")
Kodu Düzenle ve Çalıştır