stream

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DataStreamURL is the URL for the data websocket stream.
	// The DATA_PROXY_WS environment variable overrides it.
	DataStreamURL = "https://stream.data.alpaca.markets"

	// MaxConnectionAttempts is the maximum number of retries for connecting to the websocket
	MaxConnectionAttempts = 3
)

Functions

func Close

func Close() error

Close gracefully closes all streams

func SubscribeBars

func SubscribeBars(handler func(bar Bar), symbols ...string) error

SubscribeBars issues a subscribe command to the given symbols and registers the handler to be called for each bar.

func SubscribeQuotes

func SubscribeQuotes(handler func(quote Quote), symbols ...string) error

SubscribeQuotes issues a subscribe command to the given symbols and registers the handler to be called for each quote.

func SubscribeTradeUpdates

func SubscribeTradeUpdates(handler func(update alpaca.TradeUpdate)) error

SubscribeTradeUpdates issues a subscribe command to the user's trade updates and registers the handler to be called for each update.

func SubscribeTrades

func SubscribeTrades(handler func(trade Trade), symbols ...string) error

SubscribeTrades issues a subscribe command to the given symbols and registers the handler to be called for each trade.

func UnsubscribeBars

func UnsubscribeBars(symbols ...string) error

UnsubscribeBars issues an unsubscribe command for the given bar symbols

func UnsubscribeQuotes

func UnsubscribeQuotes(symbols ...string) error

UnsubscribeQuotes issues an unsubscribe command for the given quote symbols

func UnsubscribeTradeUpdates

func UnsubscribeTradeUpdates() error

UnsubscribeTradeUpdates issues an unsubscribe command for the user's trade updates

func UnsubscribeTrades

func UnsubscribeTrades(symbols ...string) error

UnsubscribeTrades issues an unsubscribe command for the given trade symbols

func UseFeed

func UseFeed(feed string) error

UseFeed sets the feed used by the data v2 stream. Supported feeds: iex, sip.

Types

type Bar

type Bar struct {
	Symbol    string
	Open      float64
	High      float64
	Low       float64
	Close     float64
	Volume    uint64
	Timestamp time.Time
}

Bar is an aggregate of trades

type Quote

type Quote struct {
	Symbol      string
	BidExchange string
	BidPrice    float64
	BidSize     uint32
	AskExchange string
	AskPrice    float64
	AskSize     uint32
	Timestamp   time.Time
	Conditions  []string
	Tape        string
}

Quote is a stock quote from the market

type Trade

type Trade struct {
	ID         int64
	Symbol     string
	Exchange   string
	Price      float64
	Size       uint32
	Timestamp  time.Time
	Conditions []string
	Tape       string
}

Trade is a stock trade that happened on the market

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL