Learn R Programming

IBrokers (version 0.10-2)

twsCALLBACK: Internal Data Callback Routine

Description

twsCALLBACK is the primary function that is called after a request for data is sent. Within this call messages are recieved from the TWS, processed, and further actions can be handled.

Usage

twsCALLBACK(twsCon, eWrapper, timestamp, file, playback = 1, ...)

Value

No value is returned. This function is called for its side effects.

Arguments

twsCon

a twsConnection object

eWrapper

a closure created by eWrapper()

timestamp

a logical indicating if timestamps should be created

file

the file or connection to write to

playback

is this a live or playback connection

...

additional arguments to internal calls

Author

Jeffrey A. Ryan

Details

This function is used as the primary management tool within all data calls built into IBrokers.

It works as is, or can be modified to manage unique data and trading requirements.

The general logic of the function is to recieve the header to each incoming message from the TWS. This then gets passed to the processMsg function, along with the eWrapper object.

The eWrapper object can maintain state data (prices), and has functions for managing all incoming message types from the TWS.

Once the processMsg call returns, another cycle of the infinite loop occurs.

If the eWrapper object is used to maintain state information, it is possible to access this information from outside of the processMsg call, and thus be able to apply trade logic based upon the data acquired from the TWS.

An example will soon be available in the vignettes included in the package.

See Also

eWrapper