R IBrokers (Interactive Brokers API)

删除回忆录丶 提交于 2019-12-08 10:58:07

问题


Anyone has any idea how to use algoStrategy and algoParams in IBrokers package? I tried creating a list for algoParams but in vain.

For example:

library(IBrokers)

twsOrder(reqIds(twsconn), 
         "BUY", 
         "10", 
         "MKT", 
         transmit = TRUE, 
         algoStrategy = "VWAP",
         algoParams = list(maxPctVol = "0.2", startTime = "13:00:00 HKT", 
                           endTime = "13:30:00 HKT", allowPastEndTime = 0, 
                           noTakeLiq = 0, speedUp = 0, monetaryValue = ""))

My orders turn out to be Market Orders. Thus, I assume my input into algoStrategy and algoParams have been ignored. I will be grateful if anyone here can give a helping hand. Thank you!


回答1:


The function placeOrder in IBrokers isn't implementing algoStrategy and algoParams. If you check the code of the function :

 order <- c(order,
             "", # DEPRECATED FIELD
             Order$discretionaryAmt,
             Order$goodAfterTime,
             Order$goodTillDate,
             Order$faGroup,
             Order$faMethod,
             Order$faPercentage,
             Order$faProfile,
             Order$shortSaleSlot,
             Order$designatedLocation,
             Order$ocaType,
             Order$rule80A,
             Order$settlingFirm,
             Order$allOrNone,
             Order$minQty,
             Order$percentOffset,
             Order$eTradeOnly,
             Order$firmQuoteOnly,
             Order$nbboPriceCap,
             Order$auctionStrategy,
             Order$startingPrice,
             Order$stockRefPrice,
             Order$delta,
             Order$stockRangeLower,
             Order$stockRangeUpper,
             Order$overridePercentageConstraints,
             Order$volatility,
             Order$volatilityType,
             Order$deltaNeutralOrderType,
             Order$deltaNeutralAuxPrice,
             Order$continuousUpdate,
             Order$referencePriceType,
             Order$trailStopPrice,
             Order$scaleInitLevelSize,
             Order$scaleSubsLevelSize,
             Order$scalePriceIncrement,
             Order$clearingAccount,
             Order$clearingIntent,
             Order$notHeld,
             "0", # Order$underComp .. not yet supported by IBrokers
             "",  # Order$algoStrategy .. not yet supported by IBrokers
             Order$whatIf
             )

The end of the function has to be modified :

  order <- c(order,
             Order$clearingAccount,  
             Order$clearingIntent,  
             Order$notHeld,  
             "0", #underComp # FALSE #NEW but not using it  
             Order$algoStrategy,     
             Order$algoParams,
              Order$whatIf, # "0", 
             "" # miscOptionsStr("")
  )

And the parameters should be similar to : algoParams=c("6","maxPctVol","0.2","startTime","08:50:00 GMT","endTime","allowPastEndTime","1","noTakeLiq","1","monetaryValue","100000") where the first character is the number of parameters that are being passed to the algo strategy.



来源:https://stackoverflow.com/questions/46482300/r-ibrokers-interactive-brokers-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!