Documentation ¶
Overview ¶
Package streaming implements a client for the Luno Streaming API.
Example:
c, err := streaming.Dial(keyID, keySecret, "XBTZAR") if err != nil { log.Fatal(err) } defer c.Close() for { seq, bids, asks := c.OrderBookSnapshot() log.Printf("%d: %v %v\n", seq, bids[0], asks[0]) time.Sleep(time.Minute) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func Dial ¶
func Dial(keyID, keySecret, pair string, onUpdate func(), opts ...DialOption) (*Conn, error)
Dial initiates a connection to the streaming service and starts processing data for the given market pair. The connection will automatically reconnect on error.
func (*Conn) Close ¶
func (c *Conn) Close()
Close the stream. After calling this the client will stop receiving new updates and the results of querying the Conn struct (Snapshot, Status...) will be zeroed values.
func (*Conn) OrderBookSnapshot ¶
OrderBookSnapshot returns the latest order book. Deprecated at v0.0.8, use Snapshot().
type ConnectCallback ¶
type ConnectCallback func(*Conn)
type CreateUpdate ¶
type DeleteUpdate ¶
type DeleteUpdate struct {
OrderID string `json:"order_id"`
}
type DialOption ¶
type DialOption func(*Conn)
func WithConnectCallback ¶
func WithConnectCallback(fn ConnectCallback) DialOption
WithConnectCallback returns an options which sets a callback function for when the connection is fully initialised and the orderbook has been set up.
func WithUpdateCallback ¶
func WithUpdateCallback(fn UpdateCallback) DialOption
WithUpdateCallback returns an options which sets a callback function for streaming updates. Each update will first be applied to the order book, and then passed to the callback function.
type Snapshot ¶
type Snapshot struct { Sequence int64 Bids, Asks []luno.OrderBookEntry Status luno.Status LastTrade TradeUpdate }
type StatusUpdate ¶
type StatusUpdate struct {
Status string `json:"status"`
}
type TradeUpdate ¶
type Update ¶
type Update struct { Sequence int64 `json:"sequence,string"` TradeUpdates []*TradeUpdate `json:"trade_updates"` CreateUpdate *CreateUpdate `json:"create_update"` DeleteUpdate *DeleteUpdate `json:"delete_update"` StatusUpdate *StatusUpdate `json:"status_update"` Timestamp int64 `json:"timestamp"` }
type UpdateCallback ¶
type UpdateCallback func(Update)