IBClient {rib} | R Documentation |
Client Connection Class
Description
This is the main class that manages the connection with the 'Trader Workstation', sends requests and handles responses.
Methods
-
IBClient$new()
: creates a new instance. -
$connect(host="localhost", port, clientId, connectOptions="")
: connects tohost:port
and performs the initial handshake using client identifierclientId
and additional optionsconnectOptions
. -
$checkMsg(wrap, timeout=0.2)
: waits for and process server messages. When available, messages are decoded and handed over to the appropriate callback defined inwrap
, which must be an instance of a child ofIBWrap
. Ifwrap
is missing, messages are read and immediately discarded. Returns the number of messages processed.This methods blocks up to
timeout
seconds. Needs to be called regularly. -
$disconnect()
: terminates the connection.
This class is modeled after the class EClient
from the official IB API
implementations.
In addition to the methods shown above, several others exist that are used to send
requests to the server.
Refer to the official documentation for a comprehensive list of the possible requests, including their signatures and descriptions.
See Also
EClient
definition from the official documentation.
Examples
## Not run:
# Instantiate a wrapper
wrap <- IBWrapSimple$new()
# Create a client and connect to a server
ic <- IBClient$new()
ic$connect(port=4002, clientId=1)
# Make a request
stock <- IBContract(symbol="GOOG", secType="STK", exchange="SMART", currency="USD")
ic$reqContractDetails(11, stock)
# Process responses
ic$checkMsg(wrap)
# Disconnect
ic$disconnect()
## End(Not run)