Documentation ¶
Index ¶
- Constants
- Variables
- type AccountBalance
- type AccountInfo
- func (i *AccountInfo) AccountStream() <-chan *AccountUpdateEvent
- func (i *AccountInfo) BalancesStream() <-chan *BalanceUpdateEvent
- func (i *AccountInfo) OCOOrdersStream() <-chan *OCOOrderUpdateEvent
- func (i *AccountInfo) OrdersStream() <-chan *OrderUpdateEvent
- func (i *AccountInfo) Read() (AccountUpdateEventType, interface{}, error)
- type AccountUpdateEvent
- type AccountUpdateEventType
- type AggTradeUpdate
- type AggTrades
- type AllBookTicker
- type AllBookTickerUpdate
- type AllMarketMiniTicker
- type AllMarketMiniTickerUpdate
- type AllMarketTicker
- type AllMarketTickerUpdate
- type BalanceUpdateEvent
- type Client
- func (c *Client) AccountInfo(listenKey string) (*AccountInfo, error)
- func (c *Client) AggTrades(symbol string) (*AggTrades, error)
- func (c *Client) AllBookTickers() (*AllBookTicker, error)
- func (c *Client) AllMarketMiniTickers() (*AllMarketMiniTicker, error)
- func (c *Client) AllMarketTickers() (*AllMarketTicker, error)
- func (c *Client) CombineIndivBookTicker(symbols []string) (*CombinedBookTicker, error)
- func (c *Client) Depth(symbol string, frequency FrequencyType) (*Depth, error)
- func (c *Client) DepthLevel(symbol string, level DepthLevelType, frequency FrequencyType) (*DepthLevel, error)
- func (c *Client) IndivBookTicker(symbol string) (*IndivBookTicker, error)
- func (c *Client) IndivMiniTicker(symbol string) (*IndivMiniTicker, error)
- func (c *Client) IndivTicker(symbol string) (*IndivTicker, error)
- func (c *Client) Klines(symbol string, interval binance.KlineInterval) (*Klines, error)
- func (c *Client) Trades(symbol string) (*Trades, error)
- type CombinedBookTicker
- type CombinedBookTickerUpdate
- type Conn
- type Depth
- type DepthLevel
- type DepthLevelType
- type DepthLevelUpdate
- type DepthUpdate
- type FrequencyType
- type IndivBookTicker
- type IndivBookTickerUpdate
- type IndivMiniTicker
- type IndivMiniTickerUpdate
- type IndivTicker
- type IndivTickerUpdate
- type Klines
- type KlinesUpdate
- type OCOOrderUpdateEvent
- type OCOOrderUpdateEventOrder
- type OrderUpdateEvent
- type TradeUpdate
- type Trades
- type UpdateEventType
- type UpdateType
Constants ¶
const DefaultCombinedStreamPrefix = "wss://stream.binance.com:9443/stream?streams="
const DefaultPrefix = "wss://stream.binance.com:9443/ws/"
Variables ¶
var ErrIncorrectAccountEventType = errors.New("incorrect account event type")
ErrIncorrectAccountEventType represents error when event type can't before determined
Functions ¶
This section is empty.
Types ¶
type AccountBalance ¶
type AccountInfo ¶
type AccountInfo struct {
Conn
}
AccountInfo is a wrapper for account info websocket
func (*AccountInfo) AccountStream ¶
func (i *AccountInfo) AccountStream() <-chan *AccountUpdateEvent
func (*AccountInfo) BalancesStream ¶
func (i *AccountInfo) BalancesStream() <-chan *BalanceUpdateEvent
func (*AccountInfo) OCOOrdersStream ¶
func (i *AccountInfo) OCOOrdersStream() <-chan *OCOOrderUpdateEvent
func (*AccountInfo) OrdersStream ¶
func (i *AccountInfo) OrdersStream() <-chan *OrderUpdateEvent
func (*AccountInfo) Read ¶
func (i *AccountInfo) Read() (AccountUpdateEventType, interface{}, error)
Read reads a account info update message from account info websocket Remark: The websocket is used to update two different structs, which both are flat, hence every call to this function will return either one of the types initialized and the other one will be set to nil
type AccountUpdateEvent ¶
type AccountUpdateEvent struct { EventType AccountUpdateEventType `json:"e"` // EventType represents the update type Balances []AccountBalance `json:"B"` // Balances represents the account balances Time uint64 `json:"E"` // Time represents the event time LastUpdate uint64 `json:"u"` // LastUpdate represents last account update }
AccountUpdateEvent represents the incoming messages for account websocket updates
type AccountUpdateEventType ¶
type AccountUpdateEventType string
const ( // AccountUpdateEventTypeUnknown default for unknown type AccountUpdateEventTypeUnknown AccountUpdateEventType = "unknown" AccountUpdateEventTypeOutboundAccountPosition AccountUpdateEventType = "outboundAccountPosition" AccountUpdateEventTypeOrderReport AccountUpdateEventType = "executionReport" AccountUpdateEventTypeBalanceUpdate AccountUpdateEventType = "balanceUpdate" AccountUpdateEventTypeOCOReport AccountUpdateEventType = "listStatus" )
type AggTradeUpdate ¶
type AggTradeUpdate struct { EventType UpdateType `json:"e"` // EventType represents the update type Time uint64 `json:"E"` // Time represents the event time Symbol string `json:"s"` // Symbol represents the symbol related to the update TradeID int64 `json:"a"` // TradeID is the aggregated trade ID Price string `json:"p"` // Price is the trade price Quantity string `json:"q"` // Quantity is the trade quantity FirstBreakDownTradeID int64 `json:"f"` // FirstBreakDownTradeID is the first breakdown trade ID LastBreakDownTradeID int64 `json:"l"` // LastBreakDownTradeID is the last breakdown trade ID TradeTime uint64 `json:"T"` // Time is the trade time Maker bool `json:"m"` // Maker indicates whether buyer is a maker }
AggTradeUpdate represents the incoming messages for aggregated trades websocket updates
type AggTrades ¶
type AggTrades struct {
Conn
}
AggTrades is a wrapper for trades websocket
func (*AggTrades) Read ¶
func (t *AggTrades) Read() (*AggTradeUpdate, error)
Read reads a trades update message from aggregated trades websocket
func (*AggTrades) Stream ¶
func (t *AggTrades) Stream() <-chan *AggTradeUpdate
Stream NewStream a trades update message from aggregated trades websocket to channel
type AllBookTicker ¶
type AllBookTicker struct {
Conn
}
AllBookTicker is a wrapper for all book tickers websocket
func (*AllBookTicker) Read ¶
func (t *AllBookTicker) Read() (*AllBookTickerUpdate, error)
Read reads a book update message from all book tickers websocket
func (*AllBookTicker) Stream ¶
func (t *AllBookTicker) Stream() <-chan *AllBookTickerUpdate
Stream NewStream a book update message from all book tickers websocket to channel
type AllBookTickerUpdate ¶
type AllBookTickerUpdate IndivBookTickerUpdate
AllBookTickerUpdate represents incoming ticker websocket feed for all book tickers
type AllMarketMiniTicker ¶
type AllMarketMiniTicker struct {
Conn
}
AllMarketMiniTicker is a wrapper for all markets mini-tickers websocket
func (*AllMarketMiniTicker) Read ¶
func (t *AllMarketMiniTicker) Read() (*AllMarketMiniTickerUpdate, error)
Read reads a market update message from all markets mini-ticker websocket
func (*AllMarketMiniTicker) Stream ¶
func (t *AllMarketMiniTicker) Stream() <-chan *AllMarketMiniTickerUpdate
Stream NewStream a market update message from all markets mini-ticker websocket to channel
type AllMarketMiniTickerUpdate ¶
type AllMarketMiniTickerUpdate []IndivMiniTickerUpdate
AllMarketMiniTickerUpdate represents incoming mini-ticker websocket feed for all tickers
type AllMarketTicker ¶
type AllMarketTicker struct {
Conn
}
AllMarketTicker is a wrapper for all markets tickers websocket
func (*AllMarketTicker) Read ¶
func (t *AllMarketTicker) Read() (*AllMarketTickerUpdate, error)
Read reads a market update message from all markets ticker websocket
func (*AllMarketTicker) Stream ¶
func (t *AllMarketTicker) Stream() <-chan *AllMarketTickerUpdate
Stream NewStream a market update message from all markets ticker websocket to channel
type AllMarketTickerUpdate ¶
type AllMarketTickerUpdate []IndivTickerUpdate
AllMarketTickerUpdate represents incoming ticker websocket feed for all tickers
type BalanceUpdateEvent ¶
type BalanceUpdateEvent struct { EventType AccountUpdateEventType `json:"e"` // EventType represents the update type Asset string `json:"a"` // Asset BalanceDelta string `json:"d"` // Balance Delta Time uint64 `json:"E"` // Time represents the event time ClearTime uint64 `json:"T"` // Clear Time }
BalanceUpdateEvent represents the incoming message for account balances websocket updates
type Client ¶
type Client struct { Prefix string // contains filtered or unexported fields }
func (*Client) AccountInfo ¶
func (c *Client) AccountInfo(listenKey string) (*AccountInfo, error)
AccountInfo opens websocket with account info updates
func (*Client) AggTrades ¶
AggTrades opens websocket with aggregated trades updates for the given symbol
func (*Client) AllBookTickers ¶
func (c *Client) AllBookTickers() (*AllBookTicker, error)
AllBookTickers opens websocket with with single depth summary for all tickers
func (*Client) AllMarketMiniTickers ¶
func (c *Client) AllMarketMiniTickers() (*AllMarketMiniTicker, error)
AllMarketMiniTickers opens websocket with with single depth summary for all mini-tickers
func (*Client) AllMarketTickers ¶
func (c *Client) AllMarketTickers() (*AllMarketTicker, error)
AllMarketTickers opens websocket with with single depth summary for all tickers
func (*Client) CombineIndivBookTicker ¶
func (c *Client) CombineIndivBookTicker(symbols []string) (*CombinedBookTicker, error)
CombineIndivBookTicker opens websocket with combined book ticker best bid or ask updates for the given symbols
func (*Client) Depth ¶
func (c *Client) Depth(symbol string, frequency FrequencyType) (*Depth, error)
Depth opens websocket with depth updates for the given symbol (eg @100ms frequency)
func (*Client) DepthLevel ¶
func (c *Client) DepthLevel(symbol string, level DepthLevelType, frequency FrequencyType) (*DepthLevel, error)
DepthLevel opens websocket with depth updates for the given symbol (eg @100ms frequency)
func (*Client) IndivBookTicker ¶
func (c *Client) IndivBookTicker(symbol string) (*IndivBookTicker, error)
IndivBookTicker opens websocket with book ticker best bid or ask updates for the given symbol
func (*Client) IndivMiniTicker ¶
func (c *Client) IndivMiniTicker(symbol string) (*IndivMiniTicker, error)
IndivMiniTicker opens websocket with with single depth summary for all mini-tickers
func (*Client) IndivTicker ¶
func (c *Client) IndivTicker(symbol string) (*IndivTicker, error)
IndivTicker opens websocket with with single depth summary for all tickers
type CombinedBookTicker ¶
type CombinedBookTicker struct {
Conn
}
CombinedBookTicker is a wrapper for all book tickers websocket
func (*CombinedBookTicker) Read ¶
func (t *CombinedBookTicker) Read() (*CombinedBookTickerUpdate, error)
Read reads a book update message from combined book tickers websocket
func (*CombinedBookTicker) Stream ¶
func (t *CombinedBookTicker) Stream() <-chan *CombinedBookTickerUpdate
Stream NewStream a book update message from combined book tickers websocket to channel
type CombinedBookTickerUpdate ¶
type CombinedBookTickerUpdate struct { Stream string `json:"stream"` Data IndivBookTickerUpdate `json:"data"` }
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) NewStreamRaw ¶
type Depth ¶
type Depth struct {
Conn
}
Depth is a wrapper for depth websocket
func (*Depth) Read ¶
func (d *Depth) Read() (*DepthUpdate, error)
Read reads a depth update message from depth websocket
func (*Depth) Stream ¶
func (d *Depth) Stream() <-chan *DepthUpdate
Stream NewStream a depth update message from depth websocket to channel
type DepthLevel ¶
type DepthLevel struct {
Conn
}
DepthLevel is a wrapper for depth level websocket
func (*DepthLevel) Read ¶
func (d *DepthLevel) Read() (*DepthLevelUpdate, error)
Read reads a depth update message from depth level websocket
func (*DepthLevel) Stream ¶
func (d *DepthLevel) Stream() <-chan *DepthLevelUpdate
Stream NewStream a depth update message from depth level websocket to channel
type DepthLevelType ¶
type DepthLevelType string
DepthLevelType is a level for DepthLevel update
const ( DepthLevel5 DepthLevelType = "5" DepthLevel10 DepthLevelType = "10" DepthLevel20 DepthLevelType = "20" )
type DepthLevelUpdate ¶
type DepthLevelUpdate struct { LastUpdateID uint64 `json:"lastUpdateId"` // EventType represents the update type Bids []binance.DepthElem `json:"bids"` // Bids is a list of bids for symbol Asks []binance.DepthElem `json:"asks"` // Asks is a list of asks for symbol }
DepthLevelUpdate represents the incoming messages for depth level websocket updates
type DepthUpdate ¶
type DepthUpdate struct { EventType UpdateType `json:"e"` // EventType represents the update type Time uint64 `json:"E"` // Time represents the event time Symbol string `json:"s"` // Symbol represents the symbol related to the update FirstUpdateID uint64 `json:"U"` // FirstTradeID in event FinalUpdateID uint64 `json:"u"` // FirstTradeID in event to sync in /ws/v3/depth Bids []binance.DepthElem `json:"b"` // Bids is a list of bids for symbol Asks []binance.DepthElem `json:"a"` // Asks is a list of asks for symbol }
DepthUpdate represents the incoming messages for depth websocket updates
type FrequencyType ¶
type FrequencyType string
FrequencyType is a interval for Depth update
const ( // Frequency1000ms is default frequency Frequency1000ms FrequencyType = "@1000ms" // Frequency100ms for fastest updates Frequency100ms FrequencyType = "@100ms" )
type IndivBookTicker ¶
type IndivBookTicker struct {
Conn
}
IndivBookTicker is a wrapper for an individual book ticker websocket
func (*IndivBookTicker) Read ¶
func (t *IndivBookTicker) Read() (*IndivBookTickerUpdate, error)
Read reads a individual book symbol update message from individual book ticker websocket
func (*IndivBookTicker) Stream ¶
func (t *IndivBookTicker) Stream() <-chan *IndivBookTickerUpdate
Stream NewStream a individual book symbol update message from individual book ticker websocket to channel
type IndivBookTickerUpdate ¶
type IndivBookTickerUpdate struct { UpdateID int `json:"u"` // UpdateID to sync up with updateID in /ws/v3/depth Symbol string `json:"s"` // Symbol represents the symbol related to the update BidPrice string `json:"b"` // BidPrice BidQty string `json:"B"` // BidQty AskPrice string `json:"a"` // AskPrice AskQty string `json:"A"` // AskQty }
IndivBookTickerUpdate represents incoming book ticker websocket feed
type IndivMiniTicker ¶
type IndivMiniTicker struct {
Conn
}
IndivMiniTicker is a wrapper for an individual mini-ticker websocket
func (*IndivMiniTicker) Read ¶
func (t *IndivMiniTicker) Read() (*IndivMiniTickerUpdate, error)
Read reads a individual symbol update message from individual mini-ticker websocket
func (*IndivMiniTicker) Stream ¶
func (t *IndivMiniTicker) Stream() <-chan *IndivMiniTickerUpdate
Stream NewStream a individual update message from individual mini-ticker websocket to channel
type IndivMiniTickerUpdate ¶
type IndivMiniTickerUpdate struct { EventType UpdateType `json:"e"` // EventType represents the update type Time uint64 `json:"E"` // Time represents the event time Symbol string `json:"s"` // Symbol represents the symbol related to the update LastPrice string `json:"c"` // Last price OpenPrice string `json:"o"` // Open price HighPrice string `json:"h"` // High price LowPrice string `json:"l"` // Low price VolumeBase string `json:"v"` // Total traded base asset volume VolumeQuote string `json:"q"` // Total traded quote asset volume }
IndivMiniTickerUpdate represents incoming mini-ticker websocket feed
type IndivTicker ¶
type IndivTicker struct {
Conn
}
IndivTicker is a wrapper for an individual ticker websocket
func (*IndivTicker) Read ¶
func (t *IndivTicker) Read() (*IndivTickerUpdate, error)
Read reads a individual symbol update message from individual ticker websocket
func (*IndivTicker) Stream ¶
func (t *IndivTicker) Stream() <-chan *IndivTickerUpdate
Stream NewStream a individual update message from individual ticker websocket to channel
type IndivTickerUpdate ¶
type IndivTickerUpdate struct { EventType UpdateType `json:"e"` // EventType represents the update type Time uint64 `json:"E"` // Time represents the event time Symbol string `json:"s"` // Symbol represents the symbol related to the update Price string `json:"p"` // Price is the order price PricePercent string `json:"P"` // Price percent change WeightedPrice string `json:"w"` // Weighted average price FirstTrade string `json:"x"` // First trade(F)-1 price (first trade before the 24hr rolling window) LastPrice string `json:"c"` // Last price LastQty string `json:"Q"` // Last quantity BestBidPrice string `json:"b"` // Best bid price BestBidQty string `json:"B"` // Best bid quantity BestAskPrice string `json:"a"` // Best ask price BestAskQty string `json:"A"` // Best ask quantity OpenPrice string `json:"o"` // Open price HighPrice string `json:"h"` // High price LowPrice string `json:"l"` // Low price VolumeBase string `json:"v"` // Total traded base asset volume VolumeQuote string `json:"q"` // Total traded quote asset volume StatisticOT uint64 `json:"O"` // Statistics open time StatisticsCT uint64 `json:"C"` // Statistics close time FirstTradeID int64 `json:"F"` // First trade ID LastTradeID int64 `json:"L"` // Last trade ID TotalTrades int `json:"n"` // Total number of trades }
IndivTickerUpdate represents incoming ticker websocket feed
type Klines ¶
type Klines struct {
Conn
}
Klines is a wrapper for klines websocket
func (*Klines) Read ¶
func (k *Klines) Read() (*KlinesUpdate, error)
Read reads a klines update message from klines websocket
func (*Klines) Stream ¶
func (k *Klines) Stream() <-chan *KlinesUpdate
Stream NewStream a klines update message from klines websocket to channel
type KlinesUpdate ¶
type KlinesUpdate struct { EventType UpdateType `json:"e"` // EventType represents the update type Time uint64 `json:"E"` // Time represents the event time Symbol string `json:"s"` // Symbol represents the symbol related to the update Kline struct { StartTime uint64 `json:"t"` // StartTime is the start time of this bar EndTime uint64 `json:"T"` // EndTime is the end time of this bar Symbol string `json:"s"` // Symbol represents the symbol related to this kline Interval binance.KlineInterval `json:"i"` // Interval is the kline interval FirstTradeID int64 `json:"f"` // FirstTradeID is the first trade ID LastTradeID int64 `json:"L"` // LastTradeID is the first trade ID OpenPrice string `json:"o"` // OpenPrice represents the open price for this bar ClosePrice string `json:"c"` // ClosePrice represents the close price for this bar High string `json:"h"` // High represents the highest price for this bar Low string `json:"l"` // Low represents the lowest price for this bar Volume string `json:"v"` // Volume is the trades volume for this bar Trades int `json:"n"` // Trades is the number of conducted trades Final bool `json:"x"` // Final indicates whether this bar is final or yet may receive updates VolumeQuote string `json:"q"` // VolumeQuote indicates the quote volume for the symbol VolumeActiveBuy string `json:"V"` // VolumeActiveBuy represents the volume of active buy VolumeQuoteActiveBuy string `json:"Q"` // VolumeQuoteActiveBuy represents the quote volume of active buy } `json:"k"` // Kline is the kline update }
KlinesUpdate represents the incoming messages for klines websocket updates
type OCOOrderUpdateEvent ¶
type OCOOrderUpdateEvent struct { EventType AccountUpdateEventType `json:"e"` Orders []OCOOrderUpdateEventOrder `json:"O"` Symbol string `json:"s"` ContingencyType string `json:"c"` ListStatusType string `json:"l"` ListOrderStatus string `json:"L"` ListRejectReason binance.OrderFailure `json:"r"` ListClientOrderID string `json:"C"` TransactTime uint64 `json:"T"` OrderListID int64 `json:"g"` Time uint64 `json:"E"` }
type OrderUpdateEvent ¶
type OrderUpdateEvent struct { EventType AccountUpdateEventType `json:"e"` // EventType represents the update type Symbol string `json:"s"` // Symbol represents the symbol related to the update NewClientOrderID string `json:"c"` // NewClientOrderID is the new client order ID Side binance.OrderSide `json:"S"` // Side is the order side OrderType binance.OrderType `json:"o"` // OrderType represents the order type TimeInForce binance.TimeInForce `json:"f"` // TimeInForce represents the order TIF type OrigQty string `json:"q"` // OrigQty represents the order original quantity Price string `json:"p"` // Price is the order price StopPrice string `json:"P"` IcebergQty string `json:"F"` OrigClientOrderID string `json:"C"` ExecutionType binance.OrderStatus `json:"x"` // ExecutionType represents the execution type for the order Status binance.OrderStatus `json:"X"` // Status represents the order status for the order Error binance.OrderFailure `json:"r"` // Error represents an order rejection reason FilledQty string `json:"l"` // FilledQty represents the quantity of the last filled trade TotalFilledQty string `json:"z"` // TotalFilledQty is the accumulated quantity of filled trades on this order FilledPrice string `json:"L"` // FilledPrice is the price of last filled trade Commission string `json:"n"` // Commission is the commission for the trade CommissionAsset string `json:"N"` // CommissionAsset is the asset on which commission is taken QuoteTotalFilledQty string `json:"Z"` // Cumulative quote asset transacted quantity QuoteFilledQty string `json:"Y"` // Last quote asset transacted quantity (i.e. lastPrice * lastQty) QuoteQty string `json:"Q"` // Quote Order Qty Time uint64 `json:"E"` // Time represents the event time TradeTime uint64 `json:"T"` // TradeTime is the trade time OrderCreatedTime uint64 `json:"O"` // OrderTime represents the order time OrderID uint64 `json:"i"` // OrderID represents the order ID TradeID int64 `json:"t"` // TradeID represents the trade ID OrderListID int64 `json:"g"` StrategyID int `json:"j"` // Strategy ID; This is only visible if the strategyId parameter was provided upon order placement StrategyType int `json:"J"` // Strategy Type; This is only visible if the strategyType parameter was provided upon order placement Maker bool `json:"m"` // Maker represents whether buyer is maker or not }
OrderUpdateEvent represents the incoming messages for account orders websocket updates
type TradeUpdate ¶
type TradeUpdate struct { EventType UpdateType `json:"e"` // EventType represents the update type Symbol string `json:"s"` // Symbol represents the symbol related to the update Price string `json:"p"` // Price is the trade price Quantity string `json:"q"` // Quantity is the trade quantity Time uint64 `json:"E"` // Time represents the event time TradeTime uint64 `json:"T"` // Time is the trade time TradeID int64 `json:"t"` // TradeID is the aggregated trade ID BuyerID int `json:"b"` // BuyerID is the buyer trade ID SellerID int `json:"a"` // SellerID is the seller trade ID Maker bool `json:"m"` // Maker indicates whether buyer is a maker }
TradeUpdate represents the incoming messages for trades websocket updates
type Trades ¶
type Trades struct {
Conn
}
Trades is a wrapper for trades websocket
func (*Trades) Read ¶
func (t *Trades) Read() (*TradeUpdate, error)
Read reads a trades update message from trades websocket
func (*Trades) Stream ¶
func (t *Trades) Stream() <-chan *TradeUpdate
Stream NewStream a trades update message from trades websocket to channel
type UpdateEventType ¶
type UpdateEventType struct {
EventType AccountUpdateEventType `json:"e"` // EventType represents the update type
}
UpdateEventType represents only incoming event type
func (*UpdateEventType) UnmarshalJSON ¶
func (e *UpdateEventType) UnmarshalJSON(b []byte) error
UnmarshalJSON need to getting partial json data
type UpdateType ¶
type UpdateType string
UpdateType represents type of account update event
const ( UpdateTypeDepth UpdateType = "depthUpdate" UpdateTypeIndivTicker UpdateType = "24hrTicker" UpdateTypeKline UpdateType = "kline" UpdateTypeAggTrades UpdateType = "aggTrade" UpdateTypeTrades UpdateType = "trade" )