R/socks.R

Defines functions socks

Documented in socks

#' All About Socks
#'
#' When called, \code{socks}() prints a detailed description of all the socks
#' in the sock_drawer.
#'
#' @section What is a "sock"?:
#' In InteractiveTradeR code & documentation, the term \strong{sock} -- when it
#' appears in code or in print -- should be understood to mean \strong{\emph{an
#' R socket connection, created by \link{socketConnection}(), that is open and
#' connected to TWS or IBG}}.
#' 
#' @section What is the "sock_drawer"?:
#' Socks that you have created with \link{create_new_connections}() -- for a
#' market subscription, for example -- live in the \code{sock_drawer}, an
#' environment in InteractiveTradeR designed to house socks. Most of the time,
#' you won't have to worry about the sock drawer at all if you simply pass the
#' value \emph{"async"} into a \emph{req_} function as the \emph{channel}
#' argument. Doing so will instruct InteractiveTradeR to use the first sock in
#' the drawer that it finds available (with a little load balancing) to service
#' your request. 
#' 
#' In this way, you can think of the sock drawer and all of the socks within it
#' as a single socket \emph{"async"}, so long as you don't care which particular
#' sock is used for a given request. If you \strong{do} care (for example, if
#' you're working with orders and require the
#' \strong{\href{master_client_id}{Master Socket}}), then you can always call
#' any of the \emph{req_} functions on a particular sock by specifying that
#' sock's name as the \emph{channel} argument in the call.
#'
#' @aliases sock_drawer
#'
#' @family utilities
#' @export
#'
socks <- function(){
  if(length(ls(sock_drawer)) > 0){
    mget(
      ls(sock_drawer),
      envir = sock_drawer
    ) %>%
      purrr::iwalk(print_async)
  }
  invisible()
}
JakeVestal/InteractiveTradeR documentation built on June 5, 2024, 2:21 p.m.