gpt4 book ai didi

java - IBrokers - 我如何向 IBrokers::.placeOrder 发送 100000?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:02:07 24 4
gpt4 key购买 nike

我正在使用 IBrokers 在 IDEALPRO 上开立澳元兑美元订单

以下语法对我卖出 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:

IBrokers:::.placeOrder(twsobj, myaud, twsOrder(myorderid,"SELL", 100000, "MKT"))

订单失败。

我在我的日志中看到了这个:

java.lang.NumberFormatException: For input string: "1e+05"

一个简单的解决方法是下 2 个 50000 的订单。

我正在寻找其他解决方法的线索。

我怀疑错误是 IBrokers 向 API 发送了 1e+05 而不是 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)

关于java - IBrokers - 我如何向 IBrokers::.placeOrder 发送 100000?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27595628/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com