req_current_time: Request Current Time

View source: R/req_current_time.R

req_current_timeR Documentation

Request Current Time

Description

Fetch the current time from IB's servers.

Usage

req_current_time(channel = NULL)

Arguments

channel

One of the following:

  • Not Specified (Default): Opens a new connection to IB, uses it to issue the request and retrieve the response, and closes connection behind itself upon completion.

  • The Name of a Sock: Character vector, length 1. The name of an open, connected socket in the sock_drawer; e.g., "master", "tws", or "sock_123"

  • Numeric Client ID: Numeric, length 1. The client ID for which open orders are to be retrieved; e.g., 0, 874, 123. If a client ID is passed, and no socket in the sock_drawer is connected on that ID, then a new socket will be opened on that ID, and closed upon function exit.

  • A sockconn Connection: An open connection object of class "sockconn", connected to the IB API; e.g., sock_drawer$tws

Details

IB servers use the UTC timezone, but req_current_time() returns the time in terms of whatever time zone is set in your current session of R. To check your timezone, run the basic R command Sys.timezone().

Value

A POSIXct date-time object. See DateTimeClasses for details.

See Also

Other quick fetch: req_family_codes(), req_managed_accts()

Examples

# Fetch the current time
current_time <- req_current_time()

# Verify that current_time is a POSIXct object
class(current_time)

# Print current_time
current_time

JakeVestal/InteractiveTradeR documentation built on June 5, 2024, 2:21 p.m.