IBClient: Client Connection Class

IBClientR 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 to host:port and performs the initial handshake using client identifier clientId and additional options connectOptions.

  • $checkMsg(wrap, timeout=0.2): waits for and process server messages. When available, messages are decoded and handed over to the appropriate callback defined in wrap, which must be an instance of a child of IBWrap. If wrap 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

IBWrap.

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)

lbilli/rib documentation built on April 22, 2024, 7:26 p.m.