本文介绍了IBrokers - 我如何向IBrokers发送100000 :::。placeOrder?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用IBrokers在IDEALPRO上打开AUD-USD的订单
I'm using IBrokers to open orders for AUD-USD on IDEALPRO
这里的语法很适合我卖出90,000:
Here is syntax which works well for me to SELL 90,000:
# myscript.r
.libPaths("rpackages")
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)
myorderid = as.integer(difftime(Sys.time(), "2014-10-30", units = "secs"))
Sys.sleep(2)
IBrokers:::.placeOrder(twsobj, myaud, twsOrder(myorderid,"SELL", 90000, "MKT"))
Sys.sleep(4)
twsDisconnect(twsobj)
接下来,我尝试通过此API调用下订单100,000:
Next, I try to place an order for 100,000 with this API call:
IBrokers:::.placeOrder(twsobj, myaud, twsOrder(myorderid,"SELL", 100000, "MKT"))
订单失败。
我在日志中看到这一点:
I see this in my log:
java.lang.NumberFormatException: For input string: "1e+05"
A简单的解决方法是为50000下2个订单。
A simple workaround is to place 2 orders for 50000.
我正在寻找其他解决方法的线索。
I'm looking for clues on other workarounds.
我怀疑这个错误是IBrokers正在向API发送1e + 05而不是100000。
I suspect that the bug is that IBrokers is sending 1e+05 to the API instead of 100000.
推荐答案
# myscript.r
.libPaths("rpackages")
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)
myorderid = as.integer(difftime(Sys.time(), "2014-10-30", units = "secs"))
Sys.sleep(2)
# my workaround:
options("scipen"=4)
IBrokers:::.placeOrder(twsobj, myaud, twsOrder(myorderid,"SELL", 190000, "MKT"))
Sys.sleep(4)
twsDisconnect(twsobj)
这篇关于IBrokers - 我如何向IBrokers发送100000 :::。placeOrder?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!