Documentation ¶
Overview ¶
Package binance is a Golang SDK for binance APIs.
Index ¶
- Constants
- Variables
- func AmountToLotSize(lot float64, precision int, amount float64) float64
- func IsAPIError(e error) bool
- 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 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 APIError
- type Account
- type AggTrade
- type AggTradesService
- func (s *AggTradesService) Do(ctx context.Context, opts ...RequestOption) (res []*AggTrade, err error)
- func (s *AggTradesService) EndTime(endTime int64) *AggTradesService
- func (s *AggTradesService) FromID(fromID int64) *AggTradesService
- func (s *AggTradesService) Limit(limit int) *AggTradesService
- func (s *AggTradesService) StartTime(startTime int64) *AggTradesService
- func (s *AggTradesService) Symbol(symbol string) *AggTradesService
- type Ask
- type Balance
- type Bid
- type BookTicker
- type BookTickerService
- type CancelOrderResponse
- type CancelOrderService
- func (s *CancelOrderService) Do(ctx context.Context, opts ...RequestOption) (res *CancelOrderResponse, err error)
- func (s *CancelOrderService) NewClientOrderID(newClientOrderID string) *CancelOrderService
- func (s *CancelOrderService) OrderID(orderID int64) *CancelOrderService
- func (s *CancelOrderService) OrigClientOrderID(origClientOrderID string) *CancelOrderService
- func (s *CancelOrderService) Symbol(symbol string) *CancelOrderService
- type Client
- func (c *Client) NewAggTradesService() *AggTradesService
- func (c *Client) NewBookTickerService() *BookTickerService
- func (c *Client) NewCancelOrderService() *CancelOrderService
- func (c *Client) NewCloseUserStreamService() *CloseUserStreamService
- func (c *Client) NewCreateOrderService() *CreateOrderService
- func (c *Client) NewCreateWithdrawService() *CreateWithdrawService
- func (c *Client) NewDepthService() *DepthService
- func (c *Client) NewExchangeInfoService() *ExchangeInfoService
- func (c *Client) NewGetAccountService() *GetAccountService
- func (c *Client) NewGetOrderService() *GetOrderService
- func (c *Client) NewGetWithdrawFeeService() *GetWithdrawFeeService
- func (c *Client) NewHistoricalTradesService() *HistoricalTradesService
- func (c *Client) NewKeepaliveUserStreamService() *KeepaliveUserStreamService
- func (c *Client) NewKlinesService() *KlinesService
- func (c *Client) NewListBookTickersService() *ListBookTickersService
- func (c *Client) NewListDepositsService() *ListDepositsService
- func (c *Client) NewListOpenOrdersService() *ListOpenOrdersService
- func (c *Client) NewListOrdersService() *ListOrdersService
- func (c *Client) NewListPriceChangeStatsService() *ListPriceChangeStatsService
- func (c *Client) NewListPricesService() *ListPricesService
- func (c *Client) NewListTradesService() *ListTradesService
- func (c *Client) NewListWithdrawsService() *ListWithdrawsService
- func (c *Client) NewPingService() *PingService
- func (c *Client) NewPriceChangeStatsService() *PriceChangeStatsService
- func (c *Client) NewRecentTradesService() *RecentTradesService
- func (c *Client) NewServerTimeService() *ServerTimeService
- func (c *Client) NewStartUserStreamService() *StartUserStreamService
- type CloseUserStreamService
- type CreateOrderResponse
- type CreateOrderService
- func (s *CreateOrderService) Do(ctx context.Context, opts ...RequestOption) (res *CreateOrderResponse, err error)
- func (s *CreateOrderService) IcebergQuantity(icebergQuantity string) *CreateOrderService
- func (s *CreateOrderService) NewClientOrderID(newClientOrderID string) *CreateOrderService
- func (s *CreateOrderService) NewOrderRespType(newOrderRespType NewOrderRespType) *CreateOrderService
- func (s *CreateOrderService) Price(price string) *CreateOrderService
- func (s *CreateOrderService) Quantity(quantity string) *CreateOrderService
- func (s *CreateOrderService) Side(side SideType) *CreateOrderService
- func (s *CreateOrderService) StopPrice(stopPrice string) *CreateOrderService
- func (s *CreateOrderService) Symbol(symbol string) *CreateOrderService
- func (s *CreateOrderService) Test(ctx context.Context, opts ...RequestOption) (err error)
- func (s *CreateOrderService) TimeInForce(timeInForce TimeInForce) *CreateOrderService
- func (s *CreateOrderService) Type(orderType OrderType) *CreateOrderService
- type CreateWithdrawService
- func (s *CreateWithdrawService) Address(address string) *CreateWithdrawService
- func (s *CreateWithdrawService) Amount(amount string) *CreateWithdrawService
- func (s *CreateWithdrawService) Asset(asset string) *CreateWithdrawService
- func (s *CreateWithdrawService) Do(ctx context.Context) (err error)
- func (s *CreateWithdrawService) Name(name string) *CreateWithdrawService
- type Deposit
- type DepositHistoryResponse
- type DepthResponse
- type DepthService
- type ErrHandler
- type ExchangeInfo
- type ExchangeInfoService
- type Fill
- type GetAccountService
- type GetOrderService
- func (s *GetOrderService) Do(ctx context.Context, opts ...RequestOption) (res *Order, err error)
- func (s *GetOrderService) OrderID(orderID int64) *GetOrderService
- func (s *GetOrderService) OrigClientOrderID(origClientOrderID string) *GetOrderService
- func (s *GetOrderService) Symbol(symbol string) *GetOrderService
- type GetWithdrawFeeService
- type HistoricalTradesService
- func (s *HistoricalTradesService) Do(ctx context.Context, opts ...RequestOption) (res []*Trade, err error)
- func (s *HistoricalTradesService) FromID(fromID int64) *HistoricalTradesService
- func (s *HistoricalTradesService) Limit(limit int) *HistoricalTradesService
- func (s *HistoricalTradesService) Symbol(symbol string) *HistoricalTradesService
- type KeepaliveUserStreamService
- type Kline
- type KlinesService
- func (s *KlinesService) Do(ctx context.Context, opts ...RequestOption) (res []*Kline, err error)
- func (s *KlinesService) EndTime(endTime int64) *KlinesService
- func (s *KlinesService) Interval(interval string) *KlinesService
- func (s *KlinesService) Limit(limit int) *KlinesService
- func (s *KlinesService) StartTime(startTime int64) *KlinesService
- func (s *KlinesService) Symbol(symbol string) *KlinesService
- type ListBookTickersService
- type ListDepositsService
- func (s *ListDepositsService) Asset(asset string) *ListDepositsService
- func (s *ListDepositsService) Do(ctx context.Context, opts ...RequestOption) (deposits []*Deposit, err error)
- func (s *ListDepositsService) EndTime(endTime int64) *ListDepositsService
- func (s *ListDepositsService) StartTime(startTime int64) *ListDepositsService
- func (s *ListDepositsService) Status(status int) *ListDepositsService
- type ListOpenOrdersService
- type ListOrdersService
- func (s *ListOrdersService) Do(ctx context.Context, opts ...RequestOption) (res []*Order, err error)
- func (s *ListOrdersService) Limit(limit int) *ListOrdersService
- func (s *ListOrdersService) OrderID(orderID int64) *ListOrdersService
- func (s *ListOrdersService) Symbol(symbol string) *ListOrdersService
- type ListPriceChangeStatsService
- type ListPricesService
- type ListTradesService
- func (s *ListTradesService) Do(ctx context.Context, opts ...RequestOption) (res []*TradeV3, err error)
- func (s *ListTradesService) FromID(fromID int64) *ListTradesService
- func (s *ListTradesService) Limit(limit int) *ListTradesService
- func (s *ListTradesService) Symbol(symbol string) *ListTradesService
- type ListWithdrawsService
- func (s *ListWithdrawsService) Asset(asset string) *ListWithdrawsService
- func (s *ListWithdrawsService) Do(ctx context.Context) (withdraws []*Withdraw, err error)
- func (s *ListWithdrawsService) EndTime(endTime int64) *ListWithdrawsService
- func (s *ListWithdrawsService) StartTime(startTime int64) *ListWithdrawsService
- func (s *ListWithdrawsService) Status(status int) *ListWithdrawsService
- type NewOrderRespType
- type Order
- type OrderType
- type PingService
- type PriceChangeStats
- type PriceChangeStatsService
- type RateLimit
- type RecentTradesService
- type RequestOption
- type ServerTimeService
- type SideType
- type StartUserStreamService
- type Symbol
- type SymbolPrice
- type TimeInForce
- type Trade
- type TradeV3
- type Withdraw
- type WithdrawFee
- type WithdrawHistoryResponse
- type WsAggTradeEvent
- type WsAggTradeHandler
- type WsAllMarketsStatEvent
- type WsAllMarketsStatHandler
- type WsAllMiniMarketsStatEvent
- type WsAllMiniMarketsStatServeHandler
- 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 ¶
const ( SideTypeBuy SideType = "BUY" SideTypeSell SideType = "SELL" OrderTypeLimit OrderType = "LIMIT" OrderTypeMarket OrderType = "MARKET" OrderTypeLimitMaker OrderType = "LIMIT_MAKER" OrderTypeStopLoss OrderType = "STOP_LOSS" OrderTypeStopLossLimit OrderType = "STOP_LOSS_LIMIT" OrderTypeTakeProfit OrderType = "TAKE_PROFIT" OrderTypeTakeProfitLimit OrderType = "TAKE_PROFIT_LIMIT" TimeInForceGTC TimeInForce = "GTC" TimeInForceIOC TimeInForce = "IOC" TimeInForceFOK TimeInForce = "FOK" NewOrderRespTypeACK NewOrderRespType = "ACK" NewOrderRespTypeRESULT NewOrderRespType = "RESULT" NewOrderRespTypeFULL NewOrderRespType = "FULL" )
Global enums
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 AmountToLotSize ¶
AmountToLotSize converts an amount to a lot sized amount
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 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 Account ¶
type Account struct { MakerCommission int64 `json:"makerCommission"` TakerCommission int64 `json:"takerCommission"` BuyerCommission int64 `json:"buyerCommission"` SellerCommission int64 `json:"sellerCommission"` CanTrade bool `json:"canTrade"` CanWithdraw bool `json:"canWithdraw"` CanDeposit bool `json:"canDeposit"` Balances []Balance `json:"balances"` }
Account define account info
type AggTrade ¶
type AggTrade struct { AggTradeID int64 `json:"a"` Price string `json:"p"` Quantity string `json:"q"` FirstTradeID int64 `json:"f"` LastTradeID int64 `json:"l"` Timestamp int64 `json:"T"` IsBuyerMaker bool `json:"m"` IsBestPriceMatch bool `json:"M"` }
AggTrade define aggregate trade info
type AggTradesService ¶
type AggTradesService struct {
// contains filtered or unexported fields
}
AggTradesService list aggregate trades
func (*AggTradesService) Do ¶
func (s *AggTradesService) Do(ctx context.Context, opts ...RequestOption) (res []*AggTrade, err error)
Do send request
func (*AggTradesService) EndTime ¶
func (s *AggTradesService) EndTime(endTime int64) *AggTradesService
EndTime set endTime
func (*AggTradesService) FromID ¶
func (s *AggTradesService) FromID(fromID int64) *AggTradesService
FromID set fromID
func (*AggTradesService) Limit ¶
func (s *AggTradesService) Limit(limit int) *AggTradesService
Limit set limit
func (*AggTradesService) StartTime ¶
func (s *AggTradesService) StartTime(startTime int64) *AggTradesService
StartTime set startTime
func (*AggTradesService) Symbol ¶
func (s *AggTradesService) Symbol(symbol string) *AggTradesService
Symbol set symbol
type Balance ¶
type Balance struct { Asset string `json:"asset"` Free string `json:"free"` Locked string `json:"locked"` }
Balance define user balance of your account
type BookTicker ¶
type BookTicker struct { Symbol string `json:"symbol"` BidPrice string `json:"bidPrice"` BidQuantity string `json:"bidQty"` AskPrice string `json:"askPrice"` AskQuantity string `json:"askQty"` }
BookTicker define book ticker info
type BookTickerService ¶
type BookTickerService struct {
// contains filtered or unexported fields
}
BookTickerService list symbol's book ticker
func (*BookTickerService) Do ¶
func (s *BookTickerService) Do(ctx context.Context, opts ...RequestOption) (res *BookTicker, err error)
Do send request
func (*BookTickerService) Symbol ¶
func (s *BookTickerService) Symbol(symbol string) *BookTickerService
Symbol set symbol
type CancelOrderResponse ¶
type CancelOrderResponse struct { Symbol string `json:"symbol"` OrigClientOrderID string `json:"origClientOrderId"` OrderID int64 `json:"orderId"` ClientOrderID string `json:"clientOrderId"` }
CancelOrderResponse define response of canceling order
type CancelOrderService ¶
type CancelOrderService struct {
// contains filtered or unexported fields
}
CancelOrderService cancel an order
func (*CancelOrderService) Do ¶
func (s *CancelOrderService) Do(ctx context.Context, opts ...RequestOption) (res *CancelOrderResponse, err error)
Do send request
func (*CancelOrderService) NewClientOrderID ¶
func (s *CancelOrderService) NewClientOrderID(newClientOrderID string) *CancelOrderService
NewClientOrderID set newClientOrderID
func (*CancelOrderService) OrderID ¶
func (s *CancelOrderService) OrderID(orderID int64) *CancelOrderService
OrderID set orderID
func (*CancelOrderService) OrigClientOrderID ¶
func (s *CancelOrderService) OrigClientOrderID(origClientOrderID string) *CancelOrderService
OrigClientOrderID set origClientOrderID
func (*CancelOrderService) Symbol ¶
func (s *CancelOrderService) Symbol(symbol string) *CancelOrderService
Symbol set symbol
type Client ¶
type Client struct { APIKey string SecretKey string BaseURL string UserAgent string HTTPClient *http.Client Debug bool Logger *log.Logger // contains filtered or unexported fields }
Client define API client
func NewClient ¶
NewClient initialize an API client instance with API key and secret key. You should always call this function before using this SDK. Services will be created by the form client.NewXXXService().
func (*Client) NewAggTradesService ¶
func (c *Client) NewAggTradesService() *AggTradesService
NewAggTradesService init aggregate trades service
func (*Client) NewBookTickerService ¶
func (c *Client) NewBookTickerService() *BookTickerService
NewBookTickerService init booking ticker service
func (*Client) NewCancelOrderService ¶
func (c *Client) NewCancelOrderService() *CancelOrderService
NewCancelOrderService init cancel order service
func (*Client) NewCloseUserStreamService ¶
func (c *Client) NewCloseUserStreamService() *CloseUserStreamService
NewCloseUserStreamService init closing user stream service
func (*Client) NewCreateOrderService ¶
func (c *Client) NewCreateOrderService() *CreateOrderService
NewCreateOrderService init creating order service
func (*Client) NewCreateWithdrawService ¶
func (c *Client) NewCreateWithdrawService() *CreateWithdrawService
NewCreateWithdrawService init creating withdraw service
func (*Client) NewDepthService ¶
func (c *Client) NewDepthService() *DepthService
NewDepthService init depth service
func (*Client) NewExchangeInfoService ¶
func (c *Client) NewExchangeInfoService() *ExchangeInfoService
NewExchangeInfoService init exchange info service
func (*Client) NewGetAccountService ¶
func (c *Client) NewGetAccountService() *GetAccountService
NewGetAccountService init getting account service
func (*Client) NewGetOrderService ¶
func (c *Client) NewGetOrderService() *GetOrderService
NewGetOrderService init get order service
func (*Client) NewGetWithdrawFeeService ¶
func (c *Client) NewGetWithdrawFeeService() *GetWithdrawFeeService
NewGetWithdrawFeeService init get withdraw fee service
func (*Client) NewHistoricalTradesService ¶
func (c *Client) NewHistoricalTradesService() *HistoricalTradesService
NewHistoricalTradesService init listing trades service
func (*Client) NewKeepaliveUserStreamService ¶
func (c *Client) NewKeepaliveUserStreamService() *KeepaliveUserStreamService
NewKeepaliveUserStreamService init keep alive user stream service
func (*Client) NewKlinesService ¶
func (c *Client) NewKlinesService() *KlinesService
NewKlinesService init klines service
func (*Client) NewListBookTickersService ¶
func (c *Client) NewListBookTickersService() *ListBookTickersService
NewListBookTickersService init listing booking tickers service
func (*Client) NewListDepositsService ¶
func (c *Client) NewListDepositsService() *ListDepositsService
NewListDepositsService init listing deposits service
func (*Client) NewListOpenOrdersService ¶
func (c *Client) NewListOpenOrdersService() *ListOpenOrdersService
NewListOpenOrdersService init list open orders service
func (*Client) NewListOrdersService ¶
func (c *Client) NewListOrdersService() *ListOrdersService
NewListOrdersService init listing orders service
func (*Client) NewListPriceChangeStatsService ¶
func (c *Client) NewListPriceChangeStatsService() *ListPriceChangeStatsService
NewListPriceChangeStatsService init list prices change stats service
func (*Client) NewListPricesService ¶
func (c *Client) NewListPricesService() *ListPricesService
NewListPricesService init listing prices service
func (*Client) NewListTradesService ¶
func (c *Client) NewListTradesService() *ListTradesService
NewListTradesService init listing trades service
func (*Client) NewListWithdrawsService ¶
func (c *Client) NewListWithdrawsService() *ListWithdrawsService
NewListWithdrawsService init listing withdraw service
func (*Client) NewPingService ¶
func (c *Client) NewPingService() *PingService
NewPingService init ping service
func (*Client) NewPriceChangeStatsService ¶
func (c *Client) NewPriceChangeStatsService() *PriceChangeStatsService
NewPriceChangeStatsService init prices change stats service
func (*Client) NewRecentTradesService ¶
func (c *Client) NewRecentTradesService() *RecentTradesService
NewRecentTradesService init recent trades service
func (*Client) NewServerTimeService ¶
func (c *Client) NewServerTimeService() *ServerTimeService
NewServerTimeService init server time service
func (*Client) NewStartUserStreamService ¶
func (c *Client) NewStartUserStreamService() *StartUserStreamService
NewStartUserStreamService init starting user stream service
type CloseUserStreamService ¶
type CloseUserStreamService struct {
// contains filtered or unexported fields
}
CloseUserStreamService delete listen key
func (*CloseUserStreamService) Do ¶
func (s *CloseUserStreamService) Do(ctx context.Context, opts ...RequestOption) (err error)
Do send request
func (*CloseUserStreamService) ListenKey ¶
func (s *CloseUserStreamService) ListenKey(listenKey string) *CloseUserStreamService
ListenKey set listen key
type CreateOrderResponse ¶
type CreateOrderResponse struct { Symbol string `json:"symbol"` OrderID int64 `json:"orderId"` ClientOrderID string `json:"clientOrderId"` TransactTime int64 `json:"transactTime"` Price string `json:"price"` OrigQuantity string `json:"origQty"` ExecutedQuantity string `json:"executedQty"` Status string `json:"status"` TimeInForce string `json:"timeInForce"` Type string `json:"type"` Side string `json:"side"` Fills []*Fill `json:"fills"` }
CreateOrderResponse define create order response
type CreateOrderService ¶
type CreateOrderService struct {
// contains filtered or unexported fields
}
CreateOrderService create order
func (*CreateOrderService) Do ¶
func (s *CreateOrderService) Do(ctx context.Context, opts ...RequestOption) (res *CreateOrderResponse, err error)
Do send request
func (*CreateOrderService) IcebergQuantity ¶
func (s *CreateOrderService) IcebergQuantity(icebergQuantity string) *CreateOrderService
IcebergQuantity set icebergQuantity
func (*CreateOrderService) NewClientOrderID ¶
func (s *CreateOrderService) NewClientOrderID(newClientOrderID string) *CreateOrderService
NewClientOrderID set newClientOrderID
func (*CreateOrderService) NewOrderRespType ¶
func (s *CreateOrderService) NewOrderRespType(newOrderRespType NewOrderRespType) *CreateOrderService
NewOrderRespType set icebergQuantity
func (*CreateOrderService) Price ¶
func (s *CreateOrderService) Price(price string) *CreateOrderService
Price set price
func (*CreateOrderService) Quantity ¶
func (s *CreateOrderService) Quantity(quantity string) *CreateOrderService
Quantity set quantity
func (*CreateOrderService) Side ¶
func (s *CreateOrderService) Side(side SideType) *CreateOrderService
Side set side
func (*CreateOrderService) StopPrice ¶
func (s *CreateOrderService) StopPrice(stopPrice string) *CreateOrderService
StopPrice set stopPrice
func (*CreateOrderService) Symbol ¶
func (s *CreateOrderService) Symbol(symbol string) *CreateOrderService
Symbol set symbol
func (*CreateOrderService) Test ¶
func (s *CreateOrderService) Test(ctx context.Context, opts ...RequestOption) (err error)
Test send test api to check if the request is valid
func (*CreateOrderService) TimeInForce ¶
func (s *CreateOrderService) TimeInForce(timeInForce TimeInForce) *CreateOrderService
TimeInForce set timeInForce
func (*CreateOrderService) Type ¶
func (s *CreateOrderService) Type(orderType OrderType) *CreateOrderService
Type set type
type CreateWithdrawService ¶
type CreateWithdrawService struct {
// contains filtered or unexported fields
}
CreateWithdrawService create withdraw
func (*CreateWithdrawService) Address ¶
func (s *CreateWithdrawService) Address(address string) *CreateWithdrawService
Address set address
func (*CreateWithdrawService) Amount ¶
func (s *CreateWithdrawService) Amount(amount string) *CreateWithdrawService
Amount set amount
func (*CreateWithdrawService) Asset ¶
func (s *CreateWithdrawService) Asset(asset string) *CreateWithdrawService
Asset set asset
func (*CreateWithdrawService) Do ¶
func (s *CreateWithdrawService) Do(ctx context.Context) (err error)
Do send request
func (*CreateWithdrawService) Name ¶
func (s *CreateWithdrawService) Name(name string) *CreateWithdrawService
Name set name
type Deposit ¶
type Deposit struct { InsertTime int64 `json:"insertTime"` Amount float64 `json:"amount"` Asset string `json:"asset"` Status int `json:"status"` TxID string `json:"txId"` }
Deposit define deposit info
type DepositHistoryResponse ¶
type DepositHistoryResponse struct { Success bool `json:"success"` Deposits []*Deposit `json:"depositList"` }
DepositHistoryResponse define deposit history
type DepthResponse ¶
type DepthResponse struct { LastUpdateID int64 `json:"lastUpdateId"` Bids []Bid `json:"bids"` Asks []Ask `json:"asks"` }
DepthResponse define depth info with bids and asks
type DepthService ¶
type DepthService struct {
// contains filtered or unexported fields
}
DepthService show depth info
func (*DepthService) Do ¶
func (s *DepthService) Do(ctx context.Context, opts ...RequestOption) (res *DepthResponse, err error)
Do send request
func (*DepthService) Symbol ¶
func (s *DepthService) Symbol(symbol string) *DepthService
Symbol set symbol
type ExchangeInfo ¶
type ExchangeInfo struct { Timezone string `json:"timezone"` ServerTime int64 `json:"serverTime"` RateLimits []RateLimit `json:"rateLimits"` ExchangeFilters []interface{} `json:"exchangeFilters"` Symbols []Symbol `json:"symbols"` }
ExchangeInfo exchange info
type ExchangeInfoService ¶
type ExchangeInfoService struct {
// contains filtered or unexported fields
}
ExchangeInfoService exchange info service
func (*ExchangeInfoService) Do ¶
func (s *ExchangeInfoService) Do(ctx context.Context, opts ...RequestOption) (res *ExchangeInfo, err error)
Do send request
type Fill ¶
type Fill struct { Price string `json:"price"` Quantity string `json:"qty"` Commission string `json:"commission"` CommissionAsset string `json:"commissionAsset"` }
Fill may be returned in an array of fills in a CreateOrderResponse.
type GetAccountService ¶
type GetAccountService struct {
// contains filtered or unexported fields
}
GetAccountService get account info
func (*GetAccountService) Do ¶
func (s *GetAccountService) Do(ctx context.Context, opts ...RequestOption) (res *Account, err error)
Do send request
type GetOrderService ¶
type GetOrderService struct {
// contains filtered or unexported fields
}
GetOrderService get an order
func (*GetOrderService) Do ¶
func (s *GetOrderService) Do(ctx context.Context, opts ...RequestOption) (res *Order, err error)
Do send request
func (*GetOrderService) OrderID ¶
func (s *GetOrderService) OrderID(orderID int64) *GetOrderService
OrderID set orderID
func (*GetOrderService) OrigClientOrderID ¶
func (s *GetOrderService) OrigClientOrderID(origClientOrderID string) *GetOrderService
OrigClientOrderID set origClientOrderID
func (*GetOrderService) Symbol ¶
func (s *GetOrderService) Symbol(symbol string) *GetOrderService
Symbol set symbol
type GetWithdrawFeeService ¶
type GetWithdrawFeeService struct {
// contains filtered or unexported fields
}
GetWithdrawFeeService get withdraw fee
func (*GetWithdrawFeeService) Asset ¶
func (s *GetWithdrawFeeService) Asset(asset string) *GetWithdrawFeeService
Asset set asset
func (*GetWithdrawFeeService) Do ¶
func (s *GetWithdrawFeeService) Do(ctx context.Context, opts ...RequestOption) (res *WithdrawFee, err error)
Do send request
type HistoricalTradesService ¶
type HistoricalTradesService struct {
// contains filtered or unexported fields
}
HistoricalTradesService trades
func (*HistoricalTradesService) Do ¶
func (s *HistoricalTradesService) Do(ctx context.Context, opts ...RequestOption) (res []*Trade, err error)
Do send request
func (*HistoricalTradesService) FromID ¶
func (s *HistoricalTradesService) FromID(fromID int64) *HistoricalTradesService
FromID set fromID
func (*HistoricalTradesService) Limit ¶
func (s *HistoricalTradesService) Limit(limit int) *HistoricalTradesService
Limit set limit
func (*HistoricalTradesService) Symbol ¶
func (s *HistoricalTradesService) Symbol(symbol string) *HistoricalTradesService
Symbol set symbol
type KeepaliveUserStreamService ¶
type KeepaliveUserStreamService struct {
// contains filtered or unexported fields
}
KeepaliveUserStreamService update listen key
func (*KeepaliveUserStreamService) Do ¶
func (s *KeepaliveUserStreamService) Do(ctx context.Context, opts ...RequestOption) (err error)
Do send request
func (*KeepaliveUserStreamService) ListenKey ¶
func (s *KeepaliveUserStreamService) ListenKey(listenKey string) *KeepaliveUserStreamService
ListenKey set listen key
type Kline ¶
type Kline struct { OpenTime int64 `json:"openTime"` Open string `json:"open"` High string `json:"high"` Low string `json:"low"` Close string `json:"close"` Volume string `json:"volume"` CloseTime int64 `json:"closeTime"` QuoteAssetVolume string `json:"quoteAssetVolume"` TradeNum int64 `json:"tradeNum"` TakerBuyBaseAssetVolume string `json:"takerBuyBaseAssetVolume"` TakerBuyQuoteAssetVolume string `json:"takerBuyQuoteAssetVolume"` }
Kline define kline info
type KlinesService ¶
type KlinesService struct {
// contains filtered or unexported fields
}
KlinesService list klines
func (*KlinesService) Do ¶
func (s *KlinesService) Do(ctx context.Context, opts ...RequestOption) (res []*Kline, err error)
Do send request
func (*KlinesService) EndTime ¶
func (s *KlinesService) EndTime(endTime int64) *KlinesService
EndTime set endTime
func (*KlinesService) Interval ¶
func (s *KlinesService) Interval(interval string) *KlinesService
Interval set interval
func (*KlinesService) Limit ¶
func (s *KlinesService) Limit(limit int) *KlinesService
Limit set limit
func (*KlinesService) StartTime ¶
func (s *KlinesService) StartTime(startTime int64) *KlinesService
StartTime set startTime
func (*KlinesService) Symbol ¶
func (s *KlinesService) Symbol(symbol string) *KlinesService
Symbol set symbol
type ListBookTickersService ¶
type ListBookTickersService struct {
// contains filtered or unexported fields
}
ListBookTickersService list all book tickers
func (*ListBookTickersService) Do ¶
func (s *ListBookTickersService) Do(ctx context.Context, opts ...RequestOption) (res []*BookTicker, err error)
Do send request
type ListDepositsService ¶
type ListDepositsService struct {
// contains filtered or unexported fields
}
ListDepositsService list deposits
func (*ListDepositsService) Asset ¶
func (s *ListDepositsService) Asset(asset string) *ListDepositsService
Asset set asset
func (*ListDepositsService) Do ¶
func (s *ListDepositsService) Do(ctx context.Context, opts ...RequestOption) (deposits []*Deposit, err error)
Do send request
func (*ListDepositsService) EndTime ¶
func (s *ListDepositsService) EndTime(endTime int64) *ListDepositsService
EndTime set endTime
func (*ListDepositsService) StartTime ¶
func (s *ListDepositsService) StartTime(startTime int64) *ListDepositsService
StartTime set startTime
func (*ListDepositsService) Status ¶
func (s *ListDepositsService) Status(status int) *ListDepositsService
Status set status
type ListOpenOrdersService ¶
type ListOpenOrdersService struct {
// contains filtered or unexported fields
}
ListOpenOrdersService list opened orders
func (*ListOpenOrdersService) Do ¶
func (s *ListOpenOrdersService) Do(ctx context.Context, opts ...RequestOption) (res []*Order, err error)
Do send request
func (*ListOpenOrdersService) Symbol ¶
func (s *ListOpenOrdersService) Symbol(symbol string) *ListOpenOrdersService
Symbol set symbol
type ListOrdersService ¶
type ListOrdersService struct {
// contains filtered or unexported fields
}
ListOrdersService list all orders
func (*ListOrdersService) Do ¶
func (s *ListOrdersService) Do(ctx context.Context, opts ...RequestOption) (res []*Order, err error)
Do send request
func (*ListOrdersService) Limit ¶
func (s *ListOrdersService) Limit(limit int) *ListOrdersService
Limit set limit
func (*ListOrdersService) OrderID ¶
func (s *ListOrdersService) OrderID(orderID int64) *ListOrdersService
OrderID set orderID
func (*ListOrdersService) Symbol ¶
func (s *ListOrdersService) Symbol(symbol string) *ListOrdersService
Symbol set symbol
type ListPriceChangeStatsService ¶
type ListPriceChangeStatsService struct {
// contains filtered or unexported fields
}
ListPriceChangeStatsService show stats of price change in last 24 hours for all symbols
func (*ListPriceChangeStatsService) Do ¶
func (s *ListPriceChangeStatsService) Do(ctx context.Context, opts ...RequestOption) (res []*PriceChangeStats, err error)
Do send request
type ListPricesService ¶
type ListPricesService struct {
// contains filtered or unexported fields
}
ListPricesService list all ticker prices
func (*ListPricesService) Do ¶
func (s *ListPricesService) Do(ctx context.Context, opts ...RequestOption) (res []*SymbolPrice, err error)
Do send request
type ListTradesService ¶
type ListTradesService struct {
// contains filtered or unexported fields
}
ListTradesService list trades
func (*ListTradesService) Do ¶
func (s *ListTradesService) Do(ctx context.Context, opts ...RequestOption) (res []*TradeV3, err error)
Do send request
func (*ListTradesService) FromID ¶
func (s *ListTradesService) FromID(fromID int64) *ListTradesService
FromID set fromID
func (*ListTradesService) Limit ¶
func (s *ListTradesService) Limit(limit int) *ListTradesService
Limit set limit
func (*ListTradesService) Symbol ¶
func (s *ListTradesService) Symbol(symbol string) *ListTradesService
Symbol set symbol
type ListWithdrawsService ¶
type ListWithdrawsService struct {
// contains filtered or unexported fields
}
ListWithdrawsService list withdraws
func (*ListWithdrawsService) Asset ¶
func (s *ListWithdrawsService) Asset(asset string) *ListWithdrawsService
Asset set asset
func (*ListWithdrawsService) Do ¶
func (s *ListWithdrawsService) Do(ctx context.Context) (withdraws []*Withdraw, err error)
Do send request
func (*ListWithdrawsService) EndTime ¶
func (s *ListWithdrawsService) EndTime(endTime int64) *ListWithdrawsService
EndTime set endTime
func (*ListWithdrawsService) StartTime ¶
func (s *ListWithdrawsService) StartTime(startTime int64) *ListWithdrawsService
StartTime set startTime
func (*ListWithdrawsService) Status ¶
func (s *ListWithdrawsService) Status(status int) *ListWithdrawsService
Status set status
type NewOrderRespType ¶
type NewOrderRespType string
NewOrderRespType define response JSON verbosity
type Order ¶
type Order struct { Symbol string `json:"symbol"` OrderID int64 `json:"orderId"` ClientOrderID string `json:"clientOrderId"` Price string `json:"price"` OrigQuantity string `json:"origQty"` ExecutedQuantity string `json:"executedQty"` Status string `json:"status"` TimeInForce string `json:"timeInForce"` Type string `json:"type"` Side string `json:"side"` StopPrice string `json:"stopPrice"` IcebergQuantity string `json:"icebergQty"` Time int64 `json:"time"` }
Order define order info
type PingService ¶
type PingService struct {
// contains filtered or unexported fields
}
PingService ping server
func (*PingService) Do ¶
func (s *PingService) Do(ctx context.Context, opts ...RequestOption) (err error)
Do send request
type PriceChangeStats ¶
type PriceChangeStats struct { Symbol string `json:"symbol"` PriceChange string `json:"priceChange"` PriceChangePercent string `json:"priceChangePercent"` WeightedAvgPrice string `json:"weightedAvgPrice"` PrevClosePrice string `json:"prevClosePrice"` LastPrice string `json:"lastPrice"` BidPrice string `json:"bidPrice"` AskPrice string `json:"askPrice"` OpenPrice string `json:"openPrice"` HighPrice string `json:"highPrice"` LowPrice string `json:"lowPrice"` Volume string `json:"volume"` OpenTime int64 `json:"openTime"` CloseTime int64 `json:"closeTime"` FristID int64 `json:"firstId"` LastID int64 `json:"lastId"` Count int64 `json:"count"` }
PriceChangeStats define price change stats
type PriceChangeStatsService ¶
type PriceChangeStatsService struct {
// contains filtered or unexported fields
}
PriceChangeStatsService show stats of price change in last 24 hours
func (*PriceChangeStatsService) Do ¶
func (s *PriceChangeStatsService) Do(ctx context.Context, opts ...RequestOption) (res *PriceChangeStats, err error)
Do send request
func (*PriceChangeStatsService) Symbol ¶
func (s *PriceChangeStatsService) Symbol(symbol string) *PriceChangeStatsService
Symbol set symbol
type RateLimit ¶
type RateLimit struct { RateLimitType string `json:"rateLimitType"` Interval string `json:"interval"` Limit int64 `json:"limit"` }
RateLimit struct
type RecentTradesService ¶
type RecentTradesService struct {
// contains filtered or unexported fields
}
RecentTradesService list recent trades
func (*RecentTradesService) Do ¶
func (s *RecentTradesService) Do(ctx context.Context, opts ...RequestOption) (res []*Trade, err error)
Do send request
func (*RecentTradesService) Limit ¶
func (s *RecentTradesService) Limit(limit int) *RecentTradesService
Limit set limit
func (*RecentTradesService) Symbol ¶
func (s *RecentTradesService) Symbol(symbol string) *RecentTradesService
Symbol set symbol
type RequestOption ¶
type RequestOption func(*request)
RequestOption define option type for request
func WithRecvWindow ¶
func WithRecvWindow(recvWindow int64) RequestOption
WithRecvWindow set recvWindow param for the request
type ServerTimeService ¶
type ServerTimeService struct {
// contains filtered or unexported fields
}
ServerTimeService get server time
func (*ServerTimeService) Do ¶
func (s *ServerTimeService) Do(ctx context.Context, opts ...RequestOption) (serverTime int64, err error)
Do send request
type StartUserStreamService ¶
type StartUserStreamService struct {
// contains filtered or unexported fields
}
StartUserStreamService create listen key for user stream service
func (*StartUserStreamService) Do ¶
func (s *StartUserStreamService) Do(ctx context.Context, opts ...RequestOption) (listenKey string, err error)
Do send request
type Symbol ¶
type Symbol struct { Symbol string `json:"symbol"` Status string `json:"status"` BaseAsset string `json:"baseAsset"` BaseAssetPrecision int `json:"baseAssetPrecision"` QuoteAsset string `json:"quoteAsset"` QuotePrecision int `json:"quotePrecision"` OrderTypes []string `json:"orderTypes"` IcebergAllowed bool `json:"icebergAllowed"` Filters []map[string]interface{} `json:"filters"` }
Symbol market symbol
type SymbolPrice ¶
SymbolPrice define symbol and price pair
type Trade ¶
type Trade struct { ID int64 `json:"id"` Price string `json:"price"` Quantity string `json:"qty"` Time int64 `json:"time"` IsBuyerMaker bool `json:"isBuyerMaker"` IsBestMatch bool `json:"isBestMatch"` }
Trade define trade info
type TradeV3 ¶
type TradeV3 struct { ID int64 `json:"id"` OrderID int64 `json:"orderId"` Price string `json:"price"` Quantity string `json:"qty"` Commission string `json:"commission"` CommissionAsset string `json:"commissionAsset"` Time int64 `json:"time"` IsBuyer bool `json:"isBuyer"` IsMaker bool `json:"isMaker"` IsBestMatch bool `json:"isBestMatch"` }
TradeV3 define v3 trade info
type Withdraw ¶
type Withdraw struct { Amount float64 `json:"amount"` Address string `json:"address"` Asset string `json:"asset"` TxID string `json:"txId"` ApplyTime int64 `json:"applyTime"` Status int `json:"status"` }
Withdraw define withdraw info
type WithdrawFee ¶
type WithdrawFee struct {
Fee float64 `json:"withdrawFee"` // docs specify string value but api returns decimal
}
WithdrawFee withdraw fee
type WithdrawHistoryResponse ¶
type WithdrawHistoryResponse struct { Withdraws []*Withdraw `json:"withdrawList"` Success bool `json:"success"` }
WithdrawHistoryResponse define withdraw history response
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