req_ids | R Documentation |
Fetch the next valid order ID available for the socket specified by
channel. In InteractiveTradeR, the need for req_ids
() is
largely abstracted away and it is unlikely that the user will need this
function. However, it is used by other functions in the package and is
included here for completeness.
req_ids(channel = NULL)
channel |
One of the following:
|
More information can be found in IB's documentation here: Next Valid Identifier
Unlike orders placed using the TWS graphical user interface – which all use
orderId = 0
– every order placed by an API on a particular
socket must have a unique integer order identifier. This identifier is the
"ID" meant by the function's name "Request IDs".
Keeping track of order IDs is necessary because in practice, any number of different users may need to submit orders – each requiring a unique order ID – to a given account or account structure. Although each user may keep track of order IDs locally, there is no way to be sure that some other user hasn't already used the ID without querying the IB servers.
req_ids
() should, perhaps, really be named "req_id
", without
the "s", because it only returns the emphnext valid id – a single integer.
The plural form of the function's name is due to historical reasons arising
from older versions of the IB API system.
The function req_ids()
fulfills this role by querying IB and returning
the next valid ID: the lowest-valued integer that hasn't yet been
used as an order ID by any user on a particular client, and therefore may be
utilized as the ID for a new order to be placed on that socket.
Integer. The next valid order ID available on the specified socket.
Other orders:
cancel_order()
,
place_order()
,
req_all_open_orders()
,
req_auto_open_orders()
,
req_completed_orders()
,
req_open_orders()
# Create some socket connections
create_new_connections(5, include_master = TRUE, include_tws = TRUE)
# Fetch the next valid ID on the master socket:
req_ids("master")
# Fetch the next valid ID on the TWS socket:
req_ids("tws")
# Note that opening orders within TWS itself does not affect the next valid TWS
# id -- only orders submitted via the API will cause it to increment.
# Repeat for the other sockets:
req_ids("sock_1")
req_ids("sock_2")
req_ids("sock_3")
# Calling req_ids() in sync mode will work, but isn't of much use because
# because, by definition, the socket isn't specified:
req_ids()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.