joshuaulrich / IBrokers

R API to Interactive Brokers Trader Workstation
65 stars 54 forks source link

twsConnect does not respect clientId #12

Open offerm opened 8 years ago

offerm commented 8 years ago

When using twsConnect with specific clientId, and that clientId is already in use, the code provides a connection using the next available clientId.

The reason can be seen in twsConnect lines 39-45:

if (curMsg == .twsIncomingMSG$ERR_MSG) {
    errMsg <- readBin(s, character(), 4)
    close(s)
    on.exit()
    return(twsConnect(clientId + 1, host, port, verbose, timeout, filename, blocking))
}

I suggest to add another argument to control how this should work.

Offer