Documentation ¶
Index ¶
- Variables
- func WsAggTradeServe(symbol string, handler WsAggTradeHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func WsAllMarketsStatServe(handler WsAllMarketsStatHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func WsAllMiniMarketsStatServe(handler WsAllMiniMarketsStatServeHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func WsCombinedPartialDepthServe(symbolLevels map[string]string, handler WsPartialDepthHandler, ...) (doneC, stopC chan struct{}, err error)
- func WsDepthServe(symbol string, handler WsDepthHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func WsFutureUserDataServe(listenKey string, handler WsHandler, errHandler ErrHandler, ...) (doneC, stopC chan struct{}, err error)
- func WsKlineServe(symbol string, interval string, handler WsKlineHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func WsMarketStatServe(symbol string, handler WsMarketStatHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func WsPartialDepthServe(symbol string, levels string, handler WsPartialDepthHandler, ...) (doneC, stopC chan struct{}, err error)
- func WsTradeServe(symbol string, handler WsTradeHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func WsUserDataServe(listenKey string, handler WsHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- type Ask
- type Bid
- type BinanceFutures
- func (b *BinanceFutures) AmendOrder(symbol string, id string, price float64, size float64, opts ...OrderOption) (result *Order, err error)
- func (b *BinanceFutures) CancelAllOrders(symbol string, opts ...OrderOption) (err error)
- func (b *BinanceFutures) CancelOrder(symbol string, id string, opts ...OrderOption) (result *Order, err error)
- func (b *BinanceFutures) CloseLong(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
- func (b *BinanceFutures) CloseShort(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
- func (b *BinanceFutures) GetBalance(currency string) (result *Balance, err error)
- func (b *BinanceFutures) GetContractID() (symbol string, err error)
- func (b *BinanceFutures) GetName() (name string)
- func (b *BinanceFutures) GetOpenOrders(symbol string, opts ...OrderOption) (result []*Order, err error)
- func (b *BinanceFutures) GetOrder(symbol string, id string, opts ...OrderOption) (result *Order, err error)
- func (b *BinanceFutures) GetOrderBook(symbol string, depth int) (result *OrderBook, err error)
- func (b *BinanceFutures) GetPositions(symbol string) (result []*Position, err error)
- func (b *BinanceFutures) GetRecords(symbol string, period string, from int64, end int64, limit int) (records []*Record, err error)
- func (b *BinanceFutures) GetTime() (tm int64, err error)
- func (b *BinanceFutures) IntervalKlinePeriod(period string) string
- func (b *BinanceFutures) OpenLong(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
- func (b *BinanceFutures) OpenShort(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
- func (b *BinanceFutures) PlaceOrder(symbol string, direction Direction, orderType OrderType, price float64, ...) (result *Order, err error)
- func (b *BinanceFutures) SetContractType(currencyPair string, contractType string) (err error)
- func (b *BinanceFutures) SetLeverRate(value float64) (err error)
- func (b *BinanceFutures) SetProxy(proxyURL string) error
- func (b *BinanceFutures) SubscribeLevel2Snapshots(market Market, callback func(ob *OrderBook)) error
- func (b *BinanceFutures) SubscribeOrders(market Market, callback func(orders []*Order)) error
- func (b *BinanceFutures) SubscribePositions(market Market, callback func(positions []*Position)) error
- func (b *BinanceFutures) SubscribeTrades(market Market, callback func(trades []*Trade)) error
- type BinanceOrder
- type BinancePosition
- type ErrHandler
- type EventOrder
- type EventPosition
- type EventType
- type WsAggTradeEvent
- type WsAggTradeHandler
- type WsAllMarketsStatEvent
- type WsAllMarketsStatHandler
- type WsAllMiniMarketsStatEvent
- type WsAllMiniMarketsStatServeHandler
- type WsConfig
- type WsDepthEvent
- type WsDepthHandler
- type WsHandler
- type WsKline
- type WsKlineEvent
- type WsKlineHandler
- type WsMarketStatEvent
- type WsMarketStatHandler
- type WsMiniMarketsStatEvent
- type WsPartialDepthEvent
- type WsPartialDepthHandler
- type WsTradeEvent
- type WsTradeHandler
Constants ¶
This section is empty.
Variables ¶
var ( // WebsocketTimeout is an interval for sending ping/pong messages if WebsocketKeepalive is enabled WebsocketTimeout = time.Second * 60 // WebsocketKeepalive enables sending ping/pong messages to check the connection stability WebsocketKeepalive = false )
Functions ¶
func WsAggTradeServe ¶
func WsAggTradeServe(symbol string, handler WsAggTradeHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsAggTradeServe serve websocket aggregate handler with a symbol
func WsAllMarketsStatServe ¶
func WsAllMarketsStatServe(handler WsAllMarketsStatHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsAllMarketsStatServe serve websocket that push 24hr statistics for all market every second
func WsAllMiniMarketsStatServe ¶
func WsAllMiniMarketsStatServe(handler WsAllMiniMarketsStatServeHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsAllMiniMarketsStatServe serve websocket that push mini version of 24hr statistics for all market every second
func WsCombinedPartialDepthServe ¶
func WsCombinedPartialDepthServe(symbolLevels map[string]string, handler WsPartialDepthHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsCombinedPartialDepthServe is similar to WsPartialDepthServe, but it for multiple symbols
func WsDepthServe ¶
func WsDepthServe(symbol string, handler WsDepthHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsDepthServe serve websocket depth handler with a symbol
func WsFutureUserDataServe ¶
func WsFutureUserDataServe(listenKey string, handler WsHandler, errHandler ErrHandler, wsConfig ...*WsConfig) (doneC, stopC chan struct{}, err error)
WsFutureUserDataServe serve user data handler with listen key
func WsKlineServe ¶
func WsKlineServe(symbol string, interval string, handler WsKlineHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsKlineServe serve websocket kline handler with a symbol and interval like 15m, 30s
func WsMarketStatServe ¶
func WsMarketStatServe(symbol string, handler WsMarketStatHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsMarketStatServe serve websocket that push 24hr statistics for single market every second
func WsPartialDepthServe ¶
func WsPartialDepthServe(symbol string, levels string, handler WsPartialDepthHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsPartialDepthServe serve websocket partial depth handler with a symbol
func WsTradeServe ¶
func WsTradeServe(symbol string, handler WsTradeHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsTradeServe serve websocket handler with a symbol
func WsUserDataServe ¶
func WsUserDataServe(listenKey string, handler WsHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsUserDataServe serve user data handler with listen key
Types ¶
type BinanceFutures ¶
type BinanceFutures struct {
// contains filtered or unexported fields
}
BinanceFutures the Binance futures exchange
func NewBinanceFutures ¶
func NewBinanceFutures(params *Parameters) *BinanceFutures
func (*BinanceFutures) AmendOrder ¶
func (*BinanceFutures) CancelAllOrders ¶
func (b *BinanceFutures) CancelAllOrders(symbol string, opts ...OrderOption) (err error)
func (*BinanceFutures) CancelOrder ¶
func (b *BinanceFutures) CancelOrder(symbol string, id string, opts ...OrderOption) (result *Order, err error)
func (*BinanceFutures) CloseLong ¶
func (b *BinanceFutures) CloseLong(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
func (*BinanceFutures) CloseShort ¶
func (b *BinanceFutures) CloseShort(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
func (*BinanceFutures) GetBalance ¶
func (b *BinanceFutures) GetBalance(currency string) (result *Balance, err error)
currency: USDT
func (*BinanceFutures) GetContractID ¶
func (b *BinanceFutures) GetContractID() (symbol string, err error)
func (*BinanceFutures) GetName ¶
func (b *BinanceFutures) GetName() (name string)
func (*BinanceFutures) GetOpenOrders ¶
func (b *BinanceFutures) GetOpenOrders(symbol string, opts ...OrderOption) (result []*Order, err error)
func (*BinanceFutures) GetOrder ¶
func (b *BinanceFutures) GetOrder(symbol string, id string, opts ...OrderOption) (result *Order, err error)
func (*BinanceFutures) GetOrderBook ¶
func (b *BinanceFutures) GetOrderBook(symbol string, depth int) (result *OrderBook, err error)
func (*BinanceFutures) GetPositions ¶
func (b *BinanceFutures) GetPositions(symbol string) (result []*Position, err error)
func (*BinanceFutures) GetRecords ¶
func (*BinanceFutures) GetTime ¶
func (b *BinanceFutures) GetTime() (tm int64, err error)
func (*BinanceFutures) IntervalKlinePeriod ¶
func (b *BinanceFutures) IntervalKlinePeriod(period string) string
func (*BinanceFutures) OpenLong ¶
func (b *BinanceFutures) OpenLong(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
func (*BinanceFutures) OpenShort ¶
func (b *BinanceFutures) OpenShort(symbol string, orderType OrderType, price float64, size float64) (result *Order, err error)
func (*BinanceFutures) PlaceOrder ¶
func (b *BinanceFutures) PlaceOrder(symbol string, direction Direction, orderType OrderType, price float64, size float64, opts ...PlaceOrderOption) (result *Order, err error)
func (*BinanceFutures) SetContractType ¶
func (b *BinanceFutures) SetContractType(currencyPair string, contractType string) (err error)
func (*BinanceFutures) SetLeverRate ¶
func (b *BinanceFutures) SetLeverRate(value float64) (err error)
func (*BinanceFutures) SetProxy ¶
func (b *BinanceFutures) SetProxy(proxyURL string) error
SetProxy ... proxyURL: http://127.0.0.1:1080
func (*BinanceFutures) SubscribeLevel2Snapshots ¶
func (b *BinanceFutures) SubscribeLevel2Snapshots(market Market, callback func(ob *OrderBook)) error
SubscribeLevel2Snapshots 订阅orderbook .
func (*BinanceFutures) SubscribeOrders ¶
func (b *BinanceFutures) SubscribeOrders(market Market, callback func(orders []*Order)) error
func (*BinanceFutures) SubscribePositions ¶
func (b *BinanceFutures) SubscribePositions(market Market, callback func(positions []*Position)) error
func (*BinanceFutures) SubscribeTrades ¶
func (b *BinanceFutures) SubscribeTrades(market Market, callback func(trades []*Trade)) error
SubscribeTrades 订阅逐笔成交.
type BinanceOrder ¶
type BinanceOrder struct { ID int64 `json:"i"` // ID ClientOId string `json:"c"` // 客户端订单ID Symbol string `json:"s"` // 标 Price string `json:"p"` // 价格 StopPx string `json:"sp"` // 触发价 Amount string `json:"q"` // 委托数量 AvgPrice string `json:"ap"` // 平均成交价 FilledAmount string `json:"z"` // 成交数量 Direction string `json:"S"` // 委托方向 Type string `json:"ot"` // 委托类型 Status string `json:"X"` // 委托状态 }
BinanceOrder .
type BinancePosition ¶
type BinancePosition struct { Symbol string `json:"s"` Size string `json:"pa"` CostPrice string `json:"ep"` }
BinancePosition 仓位.
type EventOrder ¶
type EventOrder struct { Event string `json:"e"` UpdateTime int64 `json:"E"` Order BinanceOrder `json:"o"` }
EventOrder .
type EventPosition ¶
type EventPosition struct { Event string `json:"e"` UpdateTime int64 `json:"E"` A struct { Positions []BinancePosition `json:"P"` } `json:"a"` }
EventPosition 仓位信息事件.
type WsAggTradeEvent ¶
type WsAggTradeEvent struct { Event string `json:"e"` Time int64 `json:"E"` Symbol string `json:"s"` AggTradeID int64 `json:"a"` Price string `json:"p"` Quantity string `json:"q"` FirstBreakdownTradeID int64 `json:"f"` LastBreakdownTradeID int64 `json:"l"` TradeTime int64 `json:"T"` IsBuyerMaker bool `json:"m"` Placeholder bool `json:"M"` // add this field to avoid case insensitive unmarshaling }
WsAggTradeEvent define websocket aggregate trade event
type WsAggTradeHandler ¶
type WsAggTradeHandler func(event *WsAggTradeEvent)
WsAggTradeHandler handle websocket aggregate trade event
type WsAllMarketsStatEvent ¶
type WsAllMarketsStatEvent []*WsMarketStatEvent
WsAllMarketsStatEvent define array of websocket market statistics events
type WsAllMarketsStatHandler ¶
type WsAllMarketsStatHandler func(event WsAllMarketsStatEvent)
WsAllMarketsStatHandler handle websocket that push all markets statistics for 24hr
type WsAllMiniMarketsStatEvent ¶
type WsAllMiniMarketsStatEvent []*WsMiniMarketsStatEvent
WsAllMiniMarketsStatEvent define array of websocket market mini-ticker statistics events
type WsAllMiniMarketsStatServeHandler ¶
type WsAllMiniMarketsStatServeHandler func(event WsAllMiniMarketsStatEvent)
WsAllMiniMarketsStatServeHandler handle websocket that push all mini-ticker market statistics for 24hr
type WsDepthEvent ¶
type WsDepthEvent struct { Event string `json:"e"` Time int64 `json:"E"` Symbol string `json:"s"` UpdateID int64 `json:"u"` FirstUpdateID int64 `json:"U"` Bids []Bid `json:"b"` Asks []Ask `json:"a"` }
WsDepthEvent define websocket depth event
type WsDepthHandler ¶
type WsDepthHandler func(event *WsDepthEvent)
WsDepthHandler handle websocket depth event
type WsKline ¶
type WsKline struct { StartTime int64 `json:"t"` EndTime int64 `json:"T"` Symbol string `json:"s"` Interval string `json:"i"` FirstTradeID int64 `json:"f"` LastTradeID int64 `json:"L"` Open string `json:"o"` Close string `json:"c"` High string `json:"h"` Low string `json:"l"` Volume string `json:"v"` TradeNum int64 `json:"n"` IsFinal bool `json:"x"` QuoteVolume string `json:"q"` ActiveBuyVolume string `json:"V"` ActiveBuyQuoteVolume string `json:"Q"` }
WsKline define websocket kline
type WsKlineEvent ¶
type WsKlineEvent struct { Event string `json:"e"` Time int64 `json:"E"` Symbol string `json:"s"` Kline WsKline `json:"k"` }
WsKlineEvent define websocket kline event
type WsKlineHandler ¶
type WsKlineHandler func(event *WsKlineEvent)
WsKlineHandler handle websocket kline event
type WsMarketStatEvent ¶
type WsMarketStatEvent struct { Event string `json:"e"` Time int64 `json:"E"` Symbol string `json:"s"` PriceChange string `json:"p"` PriceChangePercent string `json:"P"` WeightedAvgPrice string `json:"w"` PrevClosePrice string `json:"x"` LastPrice string `json:"c"` CloseQty string `json:"Q"` BidPrice string `json:"b"` BidQty string `json:"B"` AskPrice string `json:"a"` AskQty string `json:"A"` OpenPrice string `json:"o"` HighPrice string `json:"h"` LowPrice string `json:"l"` BaseVolume string `json:"v"` QuoteVolume string `json:"q"` OpenTime int64 `json:"O"` CloseTime int64 `json:"C"` FirstID int64 `json:"F"` LastID int64 `json:"L"` Count int64 `json:"n"` }
WsMarketStatEvent define websocket market statistics event
type WsMarketStatHandler ¶
type WsMarketStatHandler func(event *WsMarketStatEvent)
WsMarketStatHandler handle websocket that push single market statistics for 24hr
type WsMiniMarketsStatEvent ¶
type WsMiniMarketsStatEvent struct { Event string `json:"e"` Time int64 `json:"E"` Symbol string `json:"s"` LastPrice string `json:"c"` OpenPrice string `json:"o"` HighPrice string `json:"h"` LowPrice string `json:"l"` BaseVolume string `json:"v"` QuoteVolume string `json:"q"` }
WsMiniMarketsStatEvent define websocket market mini-ticker statistics event
type WsPartialDepthEvent ¶
type WsPartialDepthEvent struct { Symbol string LastUpdateID int64 `json:"lastUpdateId"` Bids []Bid `json:"bids"` Asks []Ask `json:"asks"` }
WsPartialDepthEvent define websocket partial depth book event
type WsPartialDepthHandler ¶
type WsPartialDepthHandler func(event *WsPartialDepthEvent)
WsPartialDepthHandler handle websocket partial depth event
type WsTradeEvent ¶
type WsTradeEvent struct { Event string `json:"e"` Time int64 `json:"E"` Symbol string `json:"s"` TradeID int64 `json:"t"` Price string `json:"p"` Quantity string `json:"q"` BuyerOrderID int64 `json:"b"` SellerOrderID int64 `json:"a"` TradeTime int64 `json:"T"` IsBuyerMaker bool `json:"m"` Placeholder bool `json:"M"` // add this field to avoid case insensitive unmarshaling }
WsTradeEvent define websocket trade event
type WsTradeHandler ¶
type WsTradeHandler func(event *WsTradeEvent)
WsTradeHandler handle websocket trade event