AlpacaSocket: AlpacaSocket

AlpacaSocketR Documentation

AlpacaSocket

Description

A WebSocket with modifications for Alpaca/Polygon websocket streams. \lifecycleexperimental

Super class

websocket::WebSocket -> AlpacaSocket

Public fields

opts

Options supplied to AlpacaStreams$new() are stored here. Channel specific streams are stored in nested lists with the channel/stream name. All of these options can be altered after the websocket has been activated, with the exception of write_dir.

Methods

Public methods

Inherited methods

Method new()

Connect to an Alpaca websocket

Usage
AlpacaSocket$new(opts, ...)
Arguments
opts

passed from AlpacaStreams

...

passed on to WebSocket


Method lastmessage()

Returns the last message received by the socket

Usage
AlpacaSocket$lastmessage()

Method logs()

Returns the message log

Usage
AlpacaSocket$logs(channel)
Arguments
channel

(character) Channel name of logs to be returned. Use "status" to get all status messages for the socket.


Method channel()

Sends request to websocket to join the specified channel. Channel options are inherited from defaults set in AlpacaStreams$initialize unless overridden. Notes 1. the Polygon website is only available to Polygon subscribers. 2. The sip data stream is only available to Alpaca PRO subscribers.

Usage
AlpacaSocket$channel(
  channel = NULL,
  subscribe = TRUE,
  overwrite = FALSE,
  msg_action = NULL,
  ...
)
Arguments
channel

The channel to join.

subscribe

(logical) Default TRUE. Set to FALSE to unsubscribe from specified channel(s).

overwrite

(logical) Default FALSE. Set to TRUE to overwrite data from previous instances of this channel socket.

msg_action

(expression) An expression that performs a user-specified action on the receipt of websocket message. These act on the msg object seen printed to the console when a message is received (if toConsole = TRUE). The msg object also contains a ⁠$ts⁠ column with the timestamp as a POSIXct and a ⁠$socket⁠ column with the socket name of origin ("Alpaca"/"Polygon") that are not visible in what is printed to the console but accessible to msg_action. The expression can also reference the self internal environment of this R6Class.

...

Named arguments from AlpacaStreams$new()

Details

If log = TRUE for a Polygon channel, all non-status messages will be stored as tibbles named according to their respective channel name and accessed via the ⁠$logs()⁠ method.


Method auth()

Authorize the stream (this is done automatically when initializing via the AlpacaStreams class.)

Usage
AlpacaSocket$auth()

Method clone()

The objects of this class are cloneable with this method.

Usage
AlpacaSocket$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Super classes

websocket::WebSocket -> AlpacaforR::AlpacaSocket -> PolygonSocket

Methods

Public methods

Inherited methods

Method clone()

The objects of this class are cloneable with this method.

Usage
PolygonSocket$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


jagg19/AlpacaforR documentation built on July 3, 2023, 12:14 p.m.