Documentation
¶
Index ¶
- Constants
- func GetServerTime() (t *time.Time, err error)
- func Ping() error
- type AggregateTrade
- type AggregateTradeEvent
- type AggregateTradeStream
- type ChartEvent
- type ChartInterval
- type ChartStream
- type DiffDepth
- type DiffDepthStream
- type ExchangeFilterType
- type ExchangeInfo
- type Kline
- type Order
- type OrderBook
- type OrderBookTicker
- type OrderSide
- type OrderStatus
- type OrderType
- type PartialBookStream
- type Price
- type RateLimit
- type RateLimitInterval
- type RateLimiterType
- type Symbol
- type SymbolFilter
- type SymbolFilterType
- type SymbolStatus
- type SymbolType
- type Ticker
- type TickerEvent
- type TickerStream
- type TickersStream
- type Trade
- type TradeEvent
- type TradeStream
Constants ¶
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") )
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") )
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") )
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
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
const ( BuyOrder = OrderSide("BUY") SellOrder = OrderSide("SELL") )
Order sides
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
const ( RequestsRLType = RateLimiterType("REQUESTS") OrdersRLType = RateLimiterType("ORDERS") )
Rate limiter types
const ( SecondRLInterval = RateLimitInterval("SECOND") MinuteRLInterval = RateLimitInterval("MINUTE") DayRLInterval = RateLimitInterval("DAY") )
Rate limit intervals
const Spot = SymbolStatus("SPOT")
Spot symbol type
Variables ¶
This section is empty.
Functions ¶
func GetServerTime ¶
GetServerTime gets Binance server time
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 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
type OrderBook ¶
OrderBook represents all orders for given Symbol
func GetOrderBook ¶
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 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 RateLimit ¶
type RateLimit struct { RateLimitType RateLimiterType `json:"rateLimitType"` Interval RateLimitInterval `json:"interval"` Limit int `json:"limit"` }
RateLimit struct
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 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 GetTickers ¶
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 ¶
GetOldTrades gets up to 500 older trades
func GetRecentTrades ¶
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)