r-使用reqExecutions从IB查询交易



我正试图使用函数reqExecutions从IB查询交易:

library(IBrokers) 
con <- twsConnect(clientId=1)
id <- reqIds(con) 
Order <- twsOrder(orderId=id, action="BUY", totalQuantity = 1, orderType="LMT", lmtPrice = 600, tif="GTC") 
placeOrder(con, twsSTK("AAPL", Order)
print(reqExecutions(con, reqId = as.character(.Last.orderId), ExecutionFilter = twsExecutionFilter(clientId="1")))

尽管交易是在IB中执行的,但它总是返回NULL。

难道不能直接使用reqOpenOrders吗?

警告:以下将执行交易。在运行此代码之前,请确保您已连接到票据交易帐户!

library(IBrokers) 
#con <- twsConnect(clientId=1)
con <- ibgConnect(clientId=1)
id <- reqIds(con) 
Order <- twsOrder(orderId=id, action="BUY", totalQuantity = 1, orderType="LMT", 
                  lmtPrice = 600, tif="GTC") 
placeOrder(con, twsSTK("AAPL"), Order)
> reqOpenOrders(twsconn=con)
TWS Message: 2 -1 2100 New account data requested. API client has been unsubscribed from account data. 
TWS Execution: orderId=1 time=2012-03-26 08:47:29 side=BOT shares=1 symbol=AAPL conId=265598 price=597.91

相关内容

  • 没有找到相关文章

最新更新