ibrokers R-财务顾问-下单



我正试图使用ibrokers和R.在财务顾问账户上下OCO订单

如何下OCO订单?我怎么能在同样被取消的OCO的每一个分支中包含止损和获利?

感谢您的指导!

样本代码:

Crude <- twsFuture('CL', 'NYMEX', '201505') 
fiveMin <- strftime(Sys.Date(), "%Y%m%d") 
fiveMin <- paste(fiveMin, "09:05:00", sep=" ")
Price <- reqHistoricalData(tws, Contract=Crude, barSize = "5 mins", 
                           duration = "30 S", useRTH = 0,endDateTime=(fiveMin))
HighPriceStr <- toString(Price$CLK5.High)
MktHigh <- (as.numeric(HighPriceStr))
LowPriceStr <- toString(Price$CLK5.Low)
MktLow <- (as.numeric(LowPriceStr))
#calculate range width
range <- (MktHigh - MktLow)
#enter orders if 5 min range <= .50 cents
if (range <= .50){
#place oco lmt entry @ mkt high + .02, lmt sell @ mkt low - .02 
#sample limit order for FA account group named Futures.
#IBrokers:::.placeOrder(twsOC, Crude, twsOrder(reqIds(tws), "SELL", "8", "LMT", lmtPrice = (Stop), faGroup ="Futures", faMethod ="EqualQuantity"))
}

部分答案:

Interactive Brokers使用OCA订单,一个取消所有订单。

这是一个示例:

IBrokers:::.placeOrder(twsOC, MiniCrude, twsOrder(reqIds(tws), "BUY", "3", "LMT", lmtPrice = (BreakTarget), ocaGroup = (breakerdirection), faGroup ="MiniFutures", faMethod ="EqualQuantity")) 
IBrokers:::.placeOrder(twsOC, MiniCrude, twsOrder(reqIds(tws), "BUY", "3", "STP", auxPrice = (BreakStop), ocaGroup = (breakerdirection), faGroup ="MiniFutures", faMethod ="EqualQuantity")) 

问题的第二部分,如何在填写了限额条目后才下上述订单。

reqExecutions()

我还没有编写示例代码。

相关内容

  • 没有找到相关文章

最新更新