processMsg: Main TWS-API Event Manager

View source: R/processMsg.R

processMsgR Documentation

Main TWS-API Event Manager

Description

Function to manage all incoming messages from the TWS in a consistent manner.

This is used within the context of an event loop (often twsCALLBACK) and allows for custom processing by message type via the eWrapper argument.

Usage

processMsg(curMsg, con, eWrapper, timestamp, file, twsconn, ...)

Arguments

curMsg

The current incoming message

con

a socket connection from a twsConnection

eWrapper

a functional closure with methods for each message

timestamp

the timestamp format needed

file

the file or connection to write to

twsconn

the twsConnection object

...

additional arguments to internal calls

Details

This is used internally within the context of a larger infinite listener/loop.

The basic process involves one or more requests to the TWS for data/action, followed by a call to twsCALLBACK. Inside of the CALLBACK is a loop that fetches the incoming message type, and calls processMsg at each new message.

processMsg internally is a series of if-else statements that branch according to a known incoming message type. The eWrapper object is a closure containing a data environment that is static and a collection of callback functions for each type of incoming data.

This eWrapper function can be defined at multiple points prior to the use within processMsg, to allow for access to data outside of the processMsg call, as well as facilitate custom handling in an efficient manner.

Value

Called for its side-effects.

Note

The entire mechanism (twsCALLBACK -> processMsg -> eWrapper) is modeled after the official API.

Author(s)

Jeffrey A. Ryan

References

Interactive Brokers: https://www.interactivebrokers.com/

See Also

twsCALLBACK, eWrapper


IBrokers documentation built on Nov. 16, 2022, 5:05 p.m.