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.
processMsg(curMsg, con, eWrapper, timestamp, file, twsconn, ...)
Called for its side-effects.
The current incoming message
a socket connection from a twsConnection
a functional closure with methods for each message
the timestamp format needed
the file or connection to write to
the twsConnection object
additional arguments to internal calls
Jeffrey A. Ryan
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.
Interactive Brokers: https://www.interactivebrokers.com/
twsCALLBACK
, eWrapper