我使用代码(链接如下)在盈透证券开立订单(我使用纸质账户),但是当我尝试在 5 秒后关闭已开立的订单时,我无法这样做。我做错了什么?
library(IBrokers)
myconid = 3
twsobj = twsConnect(myconid)
myaud = twsCurrency("AUD",currency="USD",exch="IDEALPRO",primary="",strike="0.0",right="",local="",multiplier="",include_expired="0",conId=myconid)
Sys.sleep(2)
myorderid = as.integer(reqIds(twsobj))
print(myorderid)
Sys.sleep(2)
# my workaround:
options("scipen"=4)
placeOrder(twsobj, myaud, twsOrder(myorderid,"SELL", 1, "MKT"))
Sys.sleep(5)
placeOrder(twsobj, myaud, twsOrder(myorderid,"BUY", 1, "MKT"))
我使用的链接:[ IBrokers - 我如何向 IBrokers:::.placeOrder 发送 100000?
更新(按照布赖恩的回答):我使用代码(链接如下)在盈透证券中打开订单(我使用纸质账户)但是当我尝试在 5 秒后关闭打开的订单时,我无法这样做。我究竟做错了什么?
library(IBrokers)
myconid = 3
twsobj = twsConnect(myconid)
myaud = twsCurrency("AUD",currency="USD",exch="IDEALPRO",primary="",strike="0.0",right="",local="",multiplier="",include_expired="0",conId=myconid)
Sys.sleep(2)
print(myorderid)
Sys.sleep(2)
# my workaround:
options("scipen"=4)
placeOrder(twsobj, myaud, twsOrder(122,"SELL", 1, "MKT"))
Sys.sleep(5)
placeOrder(twsobj, myaud, twsOrder(123,"BUY", 1, "MKT"))