binance

package module
v0.0.0-...-f29fddd Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2018 License: MIT Imports: 9 Imported by: 0

README

Go Binance API

go-binance is Binance public API implementation in golang

Installation

go get github.com/bloc4ain/go-binance

Examples

REST API

Test connectivity to the Rest API.
err := binance.Ping()
Test connectivity to the Rest API and get the current server time.
time, err := binance.GetServerTime()
Get current exchange trading rules and symbol information
info, err := binance.GetExchangeInfo()
Get order book
book, err := binance.GetOrderBook("TRXBTC", "1000")
Get recent trade list
trades, err := binance.GetRecentTrades("TRXBTC", "500")
Old trade lookup
trades, err := binance.GetRecentTrades("TRXBTC", "500")
Get compressed, aggregate trades
trades, err := binance.GetAggregateTrades("TRXBTC", "100", "", "", "")
Query order status

Orders are assigned with order ID when issued and can later be queried using it

trades, err := binance.GetKlines("TRXBTC", "100", "", "", "")

Streams examples

Aggregate Trade Streams
// The Aggregate Trade Streams push trade information that is aggregated for a single taker order.
stream, err := binance.OpenAggregateTradeStream("TRXBTC")
if err != nil {
	fmt.Printf("Stream open error: %s\n", err)
	return
}
defer stream.Close()
for {
	update, err := stream.Read()
	if err != nil {
		fmt.Printf("Stream read error: %s\n", err)
		return
	}
	fmt.Printf("%+v\n", update)
}
Trade Streams
// The Trade Streams push raw trade information; each trade has a unique buyer and seller.
stream, err := binance.OpenTradeStream("TRXBTC")
if err != nil {
	fmt.Printf("Stream open error: %s\n", err)
	return
}
defer stream.Close()
for {
	update, err := stream.Read()
	if err != nil {
		fmt.Printf("Stream read error: %s\n", err)
		return
	}
	fmt.Printf("%+v\n", update)
}
Kline/Candlestick Streams
// The Kline/Candlestick Stream push updates to the current klines/candlestick every second.
stream, err := binance.OpenChartStream("TRXBTC", binance.ChartIntervalOneMin)
if err != nil {
	fmt.Printf("Stream open error: %s\n", err)
	return
}
defer stream.Close()
for {
	update, err := stream.Read()
	if err != nil {
		fmt.Printf("Stream read error: %s\n", err)
		return
	}
	fmt.Printf("%+v\n", update)
}
Individual Symbol Ticker Streams
// 24hr Ticker statistics for a single symbol pushed every second
stream, err := binance.OpenTickerStream("TRXBTC")
if err != nil {
	fmt.Printf("Stream open error: %s\n", err)
	return
}
defer stream.Close()
for {
	update, err := stream.Read()
	if err != nil {
		fmt.Printf("Stream read error: %s\n", err)
		return
	}
	fmt.Printf("%+v\n", update)
}
All Market Tickers Stream
// 24hr Ticker statistics for all symbols in an array pushed every second
stream, err := binance.OpenTickersStream()
if err != nil {
	fmt.Printf("Stream open error: %s\n", err)
	return
}
defer stream.Close()
for {
	update, err := stream.Read()
	if err != nil {
		fmt.Printf("Stream read error: %s\n", err)
		return
	}
	fmt.Printf("%+v\n", update)
}
Partial Book Depth Streams
// Top <levels> bids and asks, pushed every second. Valid <levels> are 5, 10, or 20.
stream, err := binance.OpenPartialBookStream("TRXBTC", "20")
if err != nil {
	fmt.Printf("Stream open error: %s\n", err)
	return
}
defer stream.Close()
for {
	update, err := stream.Read()
	if err != nil {
		fmt.Printf("Stream read error: %s\n", err)
		return
	}
	fmt.Printf("%+v\n", update)
}
Diff. Depth Stream
// Order book price and quantity depth updates used to locally manage an order book pushed every second.
stream, err := binance.OpenDiffDepthStream("TRXBTC")
if err != nil {
	fmt.Printf("Stream open error: %s\n", err)
	return
}
defer stream.Close()
for {
	update, err := stream.Read()
	if err != nil {
		fmt.Printf("Stream read error: %s\n", err)
		return
	}
	fmt.Printf("%+v\n", update)
}

How to manage a local order book correctly

  1. Open a stream using binance.OpenDiffDepthStream
  2. Buffer the events you receive from the stream
  3. Get a depth snapshot using binance.GetOrderBook
  4. Drop any event where FinalUpdateID is <= LastUpdateID in the snapshot
  5. The first processed should have FirstUpdateID <= LastUpdateID+1 AND FinalUpdateID >= LastUpdateID+1
  6. While listening to the stream, each new event's FirstUpdateID should be equal to the previous event's FinalUpdateID+1
  7. The data in each event is the absolute quantity for a price level
  8. If the quantity is 0, remove the price level
  9. Receiving an event that removes a price level that is not in your local order book can happen and is normal.

License

This project is licensed under the MIT License. See the LICENSE file for more info.

Documentation

Index

Constants

View Source
const (
	// SymbolFilterTypePrice defines the price rules for a symbol.
	SymbolFilterTypePrice = SymbolFilterType("PRICE_FILTER")

	// SymbolFilterTypeLotSize filter defines the quantity (aka "lots" in auction terms) rules for a symbol.
	SymbolFilterTypeLotSize = SymbolFilterType("LOT_SIZE")

	// SymbolFilterMinNotional filter defines the minimum notional value allowed for an order on a symbol.
	// An order's notional value is the price * quantity.
	SymbolFilterMinNotional = SymbolFilterType("MIN_NOTIONAL")

	// SymbolFilterMaxNumOrders filter defines the maximum number of orders an account is allowed to have open on a symbol.
	// Note that both "algo" orders and normal orders are counted for this filter.
	SymbolFilterMaxNumOrders = SymbolFilterType("MAX_NUM_ORDERS")

	// SymbolFilterMaxAlgoOrders filter defines the maximum number of "algo" orders an account is allowed to have open on a symbol.
	// "Algo" orders are STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
	SymbolFilterMaxAlgoOrders = SymbolFilterType("MAX_ALGO_ORDERS")
)
View Source
const (
	// ExchangeFTMaxNumOrders filter defines the maximum number of orders an account is allowed to have open on the exchange.
	// Note that both "algo" orders and normal orders are counted for this filter.
	ExchangeFTMaxNumOrders = ExchangeFilterType("EXCHANGE_MAX_NUM_ORDERS")

	// ExchangeFTMaxAlgoOrders filter defines the maximum number of "algo" orders an account is allowed to have open on the exchange.
	// "Algo" orders are STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
	ExchangeFTMaxAlgoOrders = ExchangeFilterType("EXCHANGE_MAX_ALGO_ORDERS")
)
View Source
const (
	// SymbolStatusPreTrading represents symbol that will traded in the future.
	SymbolStatusPreTrading = SymbolStatus("PRE_TRADING")

	// SymbolStatusTrading represents symbol that can be currently traded.
	SymbolStatusTrading = SymbolStatus("TRADING")

	// SymbolStatusPostTrading represents POST_TRADING status
	SymbolStatusPostTrading = SymbolStatus("POST_TRADING")

	// SymbolStatusEndOfDay represents END_OF_DAY status
	SymbolStatusEndOfDay = SymbolStatus("END_OF_DAY")

	// SymbolStatusHalt represents HALT status
	SymbolStatusHalt = SymbolStatus("HALT")

	// SymbolStatusAuctionMatch represents AUCTION_MATCH status
	SymbolStatusAuctionMatch = SymbolStatus("AUCTION_MATCH")

	// SymbolStatusBreak represents BREAK status
	SymbolStatusBreak = SymbolStatus("BREAK")
)
View Source
const (
	// OrderStatusNew represents NEW status
	OrderStatusNew = OrderStatus("NEW")

	// OrderStatusPartiallyFilled represents PARTIALLY_FILLED status
	OrderStatusPartiallyFilled = OrderStatus("PARTIALLY_FILLED")

	// OrderStatusFilled represents FILLED status
	OrderStatusFilled = OrderStatus("FILLED")

	// OrderStatusCanceled represents CANCELED
	OrderStatusCanceled = OrderStatus("CANCELED")

	// OrderStatusPendingCancel represents PENDING_CANCEL status
	OrderStatusPendingCancel = OrderStatus("PENDING_CANCEL")

	// OrderStatusRejected represents REJECTED status
	OrderStatusRejected = OrderStatus("REJECTED")

	// OrderStatusExpired represents EXPIRED status
	OrderStatusExpired = OrderStatus("EXPIRED")
)

Order statuses

View Source
const (
	LimitOrder           = OrderType("LIMIT")
	MarketOrder          = OrderType("MARKET")
	StopLossOrder        = OrderType("STOP_LOSS")
	StopLossLimitOrder   = OrderType("STOP_LOSS_LIMIT")
	TakeProfitOrder      = OrderType("TAKE_PROFIT")
	TakeProfitLimitOrder = OrderType("TAKE_PROFIT_LIMIT")
	LimitMakerOrder      = OrderType("LIMIT_MAKER")
)

Order types

View Source
const (
	BuyOrder  = OrderSide("BUY")
	SellOrder = OrderSide("SELL")
)

Order sides

View Source
const (
	ChartIntervalOneMin     = ChartInterval("1m")
	ChartIntervalThreeMin   = ChartInterval("3m")
	ChartIntervalFiveMin    = ChartInterval("5m")
	ChartIntervalFifteenMin = ChartInterval("15m")
	ChartIntervalThirtyMin  = ChartInterval("30m")
	ChartIntervalOneHour    = ChartInterval("1h")
	ChartIntervalTwoHour    = ChartInterval("2h")
	ChartIntervalFourHour   = ChartInterval("4h")
	ChartIntervalSixHour    = ChartInterval("6h")
	ChartIntervalEightHour  = ChartInterval("8h")
	ChartIntervalTwelveHour = ChartInterval("12h")
	ChartIntervalOneDay     = ChartInterval("1d")
	ChartIntervalThreeDay   = ChartInterval("3d")
	ChartIntervalOneWeek    = ChartInterval("1w")
	ChartIntervalOneMonth   = ChartInterval("1M")
)

Chart intervals

View Source
const (
	RequestsRLType = RateLimiterType("REQUESTS")
	OrdersRLType   = RateLimiterType("ORDERS")
)

Rate limiter types

View Source
const (
	SecondRLInterval = RateLimitInterval("SECOND")
	MinuteRLInterval = RateLimitInterval("MINUTE")
	DayRLInterval    = RateLimitInterval("DAY")
)

Rate limit intervals

View Source
const Spot = SymbolStatus("SPOT")

Spot symbol type

Variables

This section is empty.

Functions

func GetServerTime

func GetServerTime() (t *time.Time, err error)

GetServerTime gets Binance server time

func Ping

func Ping() error

Ping tests connection to the Rest API

Types

type AggregateTrade

type AggregateTrade struct {
	ID               uint64  `json:"a"`
	Price            float64 `json:"p"`
	Quantity         float64 `json:"q"`
	FirstTradeID     uint64  `json:"f"`
	LastTradeID      uint64  `json:"l"`
	Timestamp        uint64  `json:"T"`
	IsBuyerMaker     bool    `json:"m"`
	IsBestPriceMatch bool    `json:"M"`
}

AggregateTrade struct

func GetAggregateTrades

func GetAggregateTrades(symbol, limit, fromID, startTime, endTime string) (list []AggregateTrade, err error)

GetAggregateTrades get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.

type AggregateTradeEvent

type AggregateTradeEvent struct {
	EventType     string      `json:"e"`
	EventTime     uint64      `json:"E"`
	Symbol        string      `json:"s"`
	TradeID       uint64      `json:"t"`
	Price         float64     `json:"p,string"`
	Quantity      float64     `json:"q,string"`
	BuyerOrderID  uint64      `json:"b"`
	SellerOrderID uint64      `json:"a"`
	TradeTime     uint64      `json:"T"`
	IsMarketMaker bool        `json:"m"`
	Ignore        interface{} `json:"M"`
}

AggregateTradeEvent struct

type AggregateTradeStream

type AggregateTradeStream struct {
	// contains filtered or unexported fields
}

AggregateTradeStream struct

func OpenAggregateTradeStream

func OpenAggregateTradeStream(symbol string) (*AggregateTradeStream, error)

OpenAggregateTradeStream opens websocket with trade information that is aggregated for a single taker order.

func (AggregateTradeStream) Close

func (s AggregateTradeStream) Close() error

Close function closes underlying websocket connection

func (AggregateTradeStream) Read

func (s AggregateTradeStream) Read() (event *AggregateTradeEvent, err error)

type ChartEvent

type ChartEvent struct {
	EventType string `json:"e"`
	EventTime uint64 `json:"E"`
	Symbol    string `json:"s"`
	Kline     struct {
		KlineStart               uint64 `json:"t"`
		KlineClose               uint64 `json:"T"`
		Symbol                   string `json:"s"`
		Interval                 string `json:"i"`
		FirstTradeID             uint64 `json:"f"`
		LastTradeID              uint64 `json:"L"`
		OpenPrice                string `json:"o"`
		ClosePrice               string `json:"c"`
		HighPrice                string `json:"h"`
		LowPrice                 string `json:"l"`
		BaseAssetVolume          string `json:"v"`
		NumberOfTrades           int    `json:"n"`
		IsClosed                 bool   `json:"x"`
		QuoteAssetVolume         string `json:"q"`
		TakerBuyBaseAssetVolume  string `json:"V"`
		TakerBuyQuoteAssetVolume string `json:"Q"`
	} `json:"k"`
}

ChartEvent represents updates to the current klines/candlestick

type ChartInterval

type ChartInterval string

ChartInterval string

type ChartStream

type ChartStream struct {
	// contains filtered or unexported fields
}

ChartStream struct

func OpenChartStream

func OpenChartStream(symbol string, interval ChartInterval) (*ChartStream, error)

OpenChartStream pushes trade information that is aggregated for a single taker order.

func (ChartStream) Close

func (s ChartStream) Close() error

Close function closes underlying websocket connection

func (ChartStream) Read

func (s ChartStream) Read() (event ChartEvent, err error)

type DiffDepth

type DiffDepth struct {
	EventType     string
	EventTime     uint64
	Symbol        string
	FirstUpdateID uint64
	FinalUpdateID uint64
	Bids          []Order
	Asks          []Order
}

DiffDepth represents order book price and quantity depth updates used to locally manage an order book

type DiffDepthStream

type DiffDepthStream struct {
	// contains filtered or unexported fields
}

DiffDepthStream struct

func OpenDiffDepthStream

func OpenDiffDepthStream(symbol string) (*DiffDepthStream, error)

OpenDiffDepthStream pushes trade information that is aggregated for a single taker order.

func (DiffDepthStream) Close

func (s DiffDepthStream) Close() error

Close function closes underlying websocket connection

func (DiffDepthStream) Read

func (s DiffDepthStream) Read() (event *DiffDepth, err error)

type ExchangeFilterType

type ExchangeFilterType string

ExchangeFilterType defines trading rules on exchange.

type ExchangeInfo

type ExchangeInfo struct {
	Timezone        string      `json:"timezone"`
	ServerTime      uint64      `json:"serverTime"`
	RateLimits      []RateLimit `json:"rateLimits"`
	ExchangeFilters interface{} `json:"exchangeFilters"` // Ignored
	Symbols         []Symbol    `json:"symbols"`
}

ExchangeInfo represents current general cryptocurrency trade information

func GetExchangeInfo

func GetExchangeInfo() (info *ExchangeInfo, err error)

GetExchangeInfo gets trade information for all symbols

type Kline

type Kline struct {
	OpenTime              time.Time
	Open                  float64
	High                  float64
	Low                   float64
	Close                 float64
	Volume                float64
	CloseTime             time.Time
	QuoteAssetVolume      float64
	TradesCount           int
	TakerBuyBaseAssetVol  float64
	TakerBuyQuoteAssetVol float64
}

Kline struct

func GetKlines

func GetKlines(symbol, interval, limit, startTime, endTime string) ([]Kline, error)

GetKlines gets lline/candlestick bars for a symbol.

type Order

type Order struct {
	Price    float64
	Quantity float64
}

Order struct

type OrderBook

type OrderBook struct {
	Symbol       string
	LastUpdateID uint64
	Bids         []Order
	Asks         []Order
}

OrderBook represents all orders for given Symbol

func GetOrderBook

func GetOrderBook(symbol, limit string) (*OrderBook, error)

GetOrderBook gets orders for given symbol. Weight is adjusted based on the limit where [Limit 5, 10, 20, 50, 100] = [Weight 1]; [Limit 500] = [Weight 5]; [Limit 1000] = [Weight 10]

type OrderBookTicker

type OrderBookTicker struct {
	Symbol   string  `json:"symbol"`
	BidPrice float64 `json:"bidPrice,string"`
	BidQty   float64 `json:"bidQty,string"`
	AskPrice float64 `json:"askPrice,string"`
	AskQty   float64 `json:"askQty,string"`
}

OrderBookTicker represents best price/qty for a symbol

func GetOrderBookTicker

func GetOrderBookTicker(symbol string) (t *OrderBookTicker, err error)

GetOrderBookTicker gets best price/qty on the order book for a symbol

func GetOrderBookTickers

func GetOrderBookTickers() (list []OrderBookTicker, err error)

GetOrderBookTickers gets best price/qty on the order book for all symbols

type OrderSide

type OrderSide string

OrderSide string

type OrderStatus

type OrderStatus string

OrderStatus string

type OrderType

type OrderType string

OrderType string

type PartialBookStream

type PartialBookStream struct {
	// contains filtered or unexported fields
}

PartialBookStream struct

func OpenPartialBookStream

func OpenPartialBookStream(symbol, level string) (*PartialBookStream, error)

OpenPartialBookStream pushes trade information that is aggregated for a single taker order.

func (PartialBookStream) Close

func (s PartialBookStream) Close() error

Close function closes underlying websocket connection

func (PartialBookStream) Read

func (s PartialBookStream) Read() (event *OrderBook, err error)

type Price

type Price struct {
	Symbol string  `json:"symbol"`
	Price  float64 `json:"price,string"`
}

Price struct

func GetPrice

func GetPrice(symbol string) (price *Price, err error)

GetPrice gets latest price for a symbol

func GetPrices

func GetPrices() (list []Price, err error)

GetPrices gets latest price for all symbols

type RateLimit

type RateLimit struct {
	RateLimitType RateLimiterType   `json:"rateLimitType"`
	Interval      RateLimitInterval `json:"interval"`
	Limit         int               `json:"limit"`
}

RateLimit struct

type RateLimitInterval

type RateLimitInterval string

RateLimitInterval string“

type RateLimiterType

type RateLimiterType string

RateLimiterType string

type Symbol

type Symbol struct {
	Name               string         `json:"symbol"`
	Status             string         `json:"status"`
	BaseAsset          string         `json:"baseAsset"`
	BaseAssetPrecision int            `json:"baseAssetPrecision"`
	QuoteAsset         string         `json:"quoteAsset"`
	QuotePrecision     int            `json:"quotePrecision"`
	OrderTypes         []OrderType    `json:"orderTypes"`
	IcebergAllowed     bool           `json:"icebergAllowed"`
	Filters            []SymbolFilter `json:"filters"`
}

Symbol struct

type SymbolFilter

type SymbolFilter struct {
	FilterType  SymbolFilterType `json:"filterType"`
	MinNotional float64          `json:"minNotional,string,omitempty"`
	MinPrice    float64          `json:"minPrice,string,omitempty"`
	MaxPrice    float64          `json:"maxPrice,string,omitempty"`
	TickSize    float64          `json:"tickSize,string,omitempty"`
	MinQty      float64          `json:"minQty,string,omitempty"`
	MaxQty      float64          `json:"maxQty,string,omitempty"`
	StepSize    float64          `json:"stepSize,string,omitempty"`
}

SymbolFilter struct

type SymbolFilterType

type SymbolFilterType string

SymbolFilterType defines trading rules on a symbol.

type SymbolStatus

type SymbolStatus string

SymbolStatus represents symbol trading status

type SymbolType

type SymbolType string

SymbolType string

type Ticker

type Ticker struct {
	Symbol             string  `json:"symbol"`
	PriceChange        float64 `json:"priceChange,string"`
	PriceChangePercent float64 `json:"priceChangePercent,string"`
	WeightedAvgPrice   float64 `json:"weightedAvgPrice,string"`
	PrevClosePrice     float64 `json:"prevClosePrice,string"`
	LastPrice          float64 `json:"lastPrice,string"`
	LastQty            float64 `json:"lastQty,string"`
	BidPrice           float64 `json:"bidPrice,string"`
	AskPrice           float64 `json:"askPrice,string"`
	OpenPrice          float64 `json:"openPrice,string"`
	HighPrice          float64 `json:"highPrice,string"`
	LowPrice           float64 `json:"lowPrice,string"`
	Volume             float64 `json:"volume,string"`
	QuoteVolume        float64 `json:"quoteVolume,string"`
	OpenTime           int64   `json:"openTime"`
	CloseTime          int64   `json:"closeTime"`
	FirstTradeID       int     `json:"firstId"`
	LastTradeID        int     `json:"lastId"`
	TradeCount         int     `json:"count"`
}

Ticker represents 24 hour price change statistics

func GetTicker

func GetTicker(symbol string) (t *Ticker, err error)

GetTicker returns 24hr statistics for symbol

func GetTickers

func GetTickers() (list []Ticker, err error)

GetTickers gets tickers for all symbols

type TickerEvent

type TickerEvent struct {
	EventType                string  `json:"e"`
	EventTime                uint64  `json:"E"`
	Symbol                   string  `json:"s"`
	PriceChange              float64 `json:"p,string"`
	PriceChangePercent       float64 `json:"P,string"`
	WeightedAvgPrice         float64 `json:"w,string"`
	PrevDayClosePrice        float64 `json:"x,string"`
	CurrDayClosePrice        float64 `json:"c,string"`
	CLoseTradeQuantity       float64 `json:"Q,string"`
	BestBidPrice             float64 `json:"b,string"`
	BidQuantity              float64 `json:"B,string"`
	BestAskPrice             float64 `json:"a,string"`
	BestAskQuantity          float64 `json:"A,string"`
	OpenPrice                float64 `json:"o,string"`
	ClosePrice               float64 `json:"h,string"`
	LowPrice                 float64 `json:"l,string"`
	TotalTradedBaseAssetVol  float64 `json:"v,string"`
	TotalTradedQuoteAssetVol float64 `json:"q,string"`
	StatOpenTime             uint64  `json:"O"`
	StatCloseTime            uint64  `json:"C"`
	FirstTradeID             uint64  `json:"F"`
	LastTradeID              uint64  `json:"L"`
	TotalTrades              int     `json:"n"`
}

TickerEvent represents ticker change event

type TickerStream

type TickerStream struct {
	// contains filtered or unexported fields
}

TickerStream struct

func OpenTickerStream

func OpenTickerStream(symbol string) (*TickerStream, error)

OpenTickerStream pushes trade information that is aggregated for a single taker order.

func (TickerStream) Close

func (s TickerStream) Close() error

Close function closes underlying websocket connection

func (TickerStream) Read

func (s TickerStream) Read() (event TickerEvent, err error)

type TickersStream

type TickersStream struct {
	// contains filtered or unexported fields
}

TickersStream struct

func OpenTickersStream

func OpenTickersStream() (*TickersStream, error)

OpenTickersStream pushes trade information that is aggregated for a single taker order.

func (TickersStream) Close

func (s TickersStream) Close() error

Close function closes underlying websocket connection

func (TickersStream) Read

func (s TickersStream) Read() (events []TickerEvent, err error)

type Trade

type Trade struct {
	ID           uint64 `json:"id"`
	Price        string `json:"price"`
	Quantity     string `json:"qty"`
	Time         uint64 `json:"time"`
	IsBuyerMaker bool   `json:"isBuyerMaker"`
	IsBestMatch  bool   `json:"isBestMatch"`
}

Trade represents raw trade information

func GetOldTrades

func GetOldTrades(symbol, limit, fromID string) (list []Trade, err error)

GetOldTrades gets up to 500 older trades

func GetRecentTrades

func GetRecentTrades(symbol, limit string) (list []Trade, err error)

GetRecentTrades gets up to 500 trades

type TradeEvent

type TradeEvent struct {
	EventType     string  `json:"e"`
	EventTime     uint64  `json:"E"`
	Symbol        string  `json:"s"`
	TradeID       uint64  `json:"t"`
	Price         float64 `json:"p,string"`
	Quantity      float64 `json:"q,string"`
	BuyerOrderID  uint64  `json:"b"`
	SellerOrderID uint64  `json:"a"`
	TradeTime     int64   `json:"T"`
	IsBuyerMaker  bool    `json:"m"`
}

TradeEvent struct

type TradeStream

type TradeStream struct {
	// contains filtered or unexported fields
}

TradeStream struct

func OpenTradeStream

func OpenTradeStream(symbol string) (*TradeStream, error)

OpenTradeStream opens websocket with raw trade information; each trade has a unique buyer and seller.

func (TradeStream) Close

func (s TradeStream) Close() error

Close function closes underlying websocket connection

func (TradeStream) Read

func (s TradeStream) Read() (event *TradeEvent, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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