Establish (force) a connection to TWS or IBG

Description

As long as you are logged-in to either IB TWS or IB Gateway, and at least one of the clientIds is not in use, a connection will be established. If the first attempt to connect fails, several more connection attempts will be made until a connection is established, or the clientIds are used up.

Usage

1
ConnectIB(clientIds = 1:10)

Arguments

clientIds

numeric vector. These will be tried one at a time in order until a connection is established.

Details

This will first try to connect using the first value of clientIds in a call to twsConnect. If that fails because you are not connected to TWS, it will try to connect using ibgConnect. If it fails because the clientId is already in use, it will continue trying each of the values in clientIds until a connection is established or there are no more to try.

Value

a connected 'twsconn' object

Author(s)

Garrett See

See Also

twsConnect, ibgConnect

Examples

1
2
3
4
5
6
7
## Not run: 
con1 <- ConnectIB(851:852)
con2 <- ConnectIB(851:852)
con3 <- ConnectIB(851:852) #out of ids
lapply(list(con1, con2), twsDisconnect)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.