Documentation ¶
Overview ¶
Package binance defines the connectivity with Binance.
Index ¶
Constants ¶
View Source
const ( WebSocketURL = "wss://data-stream.binance.vision/ws/ticker" WebSocketRequestsPerSecond = 5 )
Connection parameters for Binance. These are only provided for convenience in testing - operational values should be in the environment.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection wraps a Binance websocket connection.
func Factory ¶
func Factory( url string, symbol string, onQuote func(*mkt.Quote), onTrade func(*mkt.Trade), onError func(error), limiter *utl.RateLimiter, lifetime time.Duration, ) *Connection
Factory is the [dma.ConnectionFactory] for a Connection.
type Request ¶
type Request struct { Method string `json:"method"` // "SUBSCRIBE" or "UNSUBSCRIBE". Params []string `json:"params"` // Example "btcusdt@ticker" - the symbol must be lower case. ID int64 `json:"id"` // Unique per request. }
Request is a stream request.
type Response ¶
type Response struct { Result *string `json:"result,omitempty"` // nil means success. ID int64 `json:"id"` // }
Response to a non-query request.
type Ticker ¶
type Ticker struct { Symbol string `json:"s"` BidPx string `json:"b"` BidSize string `json:"B"` AskPx string `json:"a"` AskSize string `json:"A"` LastQty string `json:"Q"` LastPx string `json:"c"` TradeID int64 `json:"L"` }
Ticker is the message for an individual symbol ticker stream. However json.Unmarshal fails with real data (claiming field "L" is a string), but unmarshaling into a basic map does work - albeit with "L" being parsed to a float64. The struct is kept for reference only.
Click to show internal directories.
Click to hide internal directories.