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 BackoffHandler ¶ added in v0.0.31
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func Dial ¶
func Dial(keyID, keySecret, pair string, 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 ¶ added in v0.0.8
type ConnectCallback func(*Conn)
type CreateUpdate ¶
type DeleteUpdate ¶
type DeleteUpdate struct {
OrderID string `json:"order_id"`
}
type DialOption ¶
type DialOption func(*Conn)
func WithBackoffHandler ¶ added in v0.0.31
func WithBackoffHandler(fn BackoffHandler, attemptReset time.Duration) DialOption
WithBackoffHandler specifies a custom handler to calculate backoff duration after each disconnect. Attempt will increment with each subsequent call until the attemptReset duration exceeds the duration since the last disconnect, at which point it will reset to 0.
func WithConnectCallback ¶ added in v0.0.8
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 ¶ added in v0.0.8
type Snapshot struct { Sequence int64 Bids, Asks []luno.OrderBookEntry Status luno.Status LastTrade TradeUpdate }
type StatusUpdate ¶ added in v0.0.8
type StatusUpdate struct {
Status string `json:"status"`
}
type TradeUpdate ¶
type TradeUpdate struct { // Sequence is the monotonically increasing sequence number of the trade // for the market in question. Sequence int64 `json:"sequence"` // Base is the volume of the base currency that was filled. Base decimal.Decimal `json:"base,string"` // Counter is the price at which the order filled. Counter decimal.Decimal `json:"counter,string"` // MakerOrderID is the ID of the pre-existing order in the order book that was matched. MakerOrderID string `json:"maker_order_id"` // TakeOrderID is the ID of the order that matched against a pre-existing order. TakerOrderID string `json:"taker_order_id"` // Deprecated: Use MakerOrderID. OrderID string `json:"order_id"` }
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)