IBrokers - How do I send 100,000 to IBrokers :. PlaceOrder?

I am using IBrokers to open AUD-USD orders on IDEALPRO

Here is the syntax that 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)

      

Then I try to place an order for 100,000 using this API call:

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

      

The order doesn't work.

I see this in my log:

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

      

A simple workaround is to place 2 orders for 50,000.

I am looking for clues from other workarounds.

I suspect the error is that IBrokers is sending 1e + 05 to the API instead of 100000.

+3


source to share


1 answer


# 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)

      



+1


source







All Articles