Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines a client to the Polygon WebSocket API.
func (*Client) Close ¶
func (c *Client) Close()
Close attempt to gracefully close the connection to the server.
func (*Client) Connect ¶
Connect dials the WebSocket server and starts the read/write and process threads. If any subscription messages are pushed before connecting, it will also send those to the server.
func (*Client) Error ¶ added in v0.7.0
Error returns an error channel. If the client hits a fatal error (e.g. auth failed), it will push an error to this channel and close the connection.
type Config ¶
type Config struct {
// APIKey is the API key used to authenticate against the server.
APIKey string
// Feed is the data feed (e.g. Delayed, RealTime) which represents the server host.
Feed Feed
// Market is the type of market (e.g. Stocks, Crypto) used to connect to the server.
Market Market
// MaxRetries is the maximum number of retry attempts that will occur. If the maximum
// is reached, the client will close the connection. Omitting this will cause the
// client to reconnect indefinitely until the user closes it.
MaxRetries *uint64
// RawData is a flag indicating whether data should be returned as a raw JSON.
RawData bool
// Log is an optional logger. Any logger implementation can be used as long as it
// implements the basic Logger interface. Omitting this will disable client logging.
Log Logger
}
Config is a set of WebSocket client options.
type Feed ¶
type Feed string
Feed is the data feed (e.g. Delayed, RealTime) which represents the server host.
type Logger ¶
type Logger interface {
Debugf(template string, args ...any)
Infof(template string, args ...any)
Errorf(template string, args ...any)
}
Logger is a basic logger interface used for logging within the client.
type Market ¶
type Market string
Market is the type of market (e.g. Stocks, Crypto) used to connect to the server.
type Topic ¶
type Topic uint8
Topic is the data type used to subscribe and retrieve data from the server.
const ( StocksSecAggs Topic = 11 StocksMinAggs Topic = 12 StocksTrades Topic = 13 StocksQuotes Topic = 14 StocksImbalances Topic = 15 StocksLULD Topic = 16 OptionsSecAggs Topic = 31 OptionsMinAggs Topic = 32 OptionsTrades Topic = 33 OptionsQuotes Topic = 34 ForexMinAggs Topic = 51 ForexQuotes Topic = 52 CryptoMinAggs Topic = 71 CryptoTrades Topic = 72 CryptoQuotes Topic = 73 CryptoL2Book Topic = 74 )