Documentation ¶
Index ¶
- Constants
- Variables
- func FormatTimestamp(t time.Time) int64
- func WsBookTickerServe(symbol string, handler WsBookTickerHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- type CancelOCOResponse
- type CancelOCOService
- func (s *CancelOCOService) Do(ctx context.Context, opts ...RequestOption) (res *CancelOCOResponse, err error)
- func (s *CancelOCOService) ListClientOrderID(listClientOrderID string) *CancelOCOService
- func (s *CancelOCOService) NewClientOrderID(newClientOrderID string) *CancelOCOService
- func (s *CancelOCOService) OrderListID(orderListID int64) *CancelOCOService
- func (s *CancelOCOService) Symbol(symbol string) *CancelOCOService
- type Client
- func (c *Client) NewCancelOCOService() *CancelOCOService
- func (c *Client) NewCreateOCOService() *CreateOCOService
- func (c *Client) NewGetOCOService() *GetOCOService
- func (c *Client) NewListOCOService() *ListOCOService
- func (c *Client) NewListOpenOCOService() *ListOpenOCOService
- func (c *Client) NewPingService() *PingService
- func (c *Client) NewServerTimeService() *ServerTimeService
- func (c *Client) NewSetServerTimeService() *SetServerTimeService
- type CreateOCOResponse
- type CreateOCOService
- func (s *CreateOCOService) Do(ctx context.Context, opts ...RequestOption) (res *CreateOCOResponse, err error)
- func (s *CreateOCOService) LimitClientOrderID(limitClientOrderID string) *CreateOCOService
- func (s *CreateOCOService) NewOrderRespType(newOrderRespType NewOrderRespType) *CreateOCOService
- func (s *CreateOCOService) Price(price string) *CreateOCOService
- func (s *CreateOCOService) Quantity(quantity string) *CreateOCOService
- func (s *CreateOCOService) Side(side SideType) *CreateOCOService
- func (s *CreateOCOService) StopClientOrderID(stopClientOrderID string) *CreateOCOService
- func (s *CreateOCOService) StopIcebergQty(stopIcebergQty string) *CreateOCOService
- func (s *CreateOCOService) StopLimitPrice(stopLimitPrice string) *CreateOCOService
- func (s *CreateOCOService) StopLimitTimeInForce(stopLimitTimeInForce TimeInForceType) *CreateOCOService
- func (s *CreateOCOService) StopPrice(stopPrice string) *CreateOCOService
- func (s *CreateOCOService) Symbol(symbol string) *CreateOCOService
- type ErrHandler
- type GetOCOService
- type ListOCOService
- func (s *ListOCOService) Do(ctx context.Context, opts ...RequestOption) (res []*OCOResponse, err error)
- func (s *ListOCOService) EndTime(endTime int64) *ListOCOService
- func (s *ListOCOService) FromID(fromID int64) *ListOCOService
- func (s *ListOCOService) Limit(limit int) *ListOCOService
- func (s *ListOCOService) StartTime(startTime int64) *ListOCOService
- func (s *ListOCOService) Symbol(symbol string) *ListOCOService
- type ListOpenOCOService
- type NewOrderRespType
- type OCOListOrderStatusType
- type OCOListStatusType
- type OCOOrder
- type OCOOrderReport
- type OCOResponse
- type OrderStatusType
- type OrderType
- type PingService
- type RequestOption
- type ServerTimeService
- type SetServerTimeService
- type SideType
- type TimeInForceType
- type WsBookTickerEvent
- type WsBookTickerHandler
- type WsConfig
- type WsHandler
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" OrderStatusTypeNew OrderStatusType = "NEW" OrderStatusTypePartiallyFilled OrderStatusType = "PARTIALLY_FILLED" OrderStatusTypeFilled OrderStatusType = "FILLED" OrderStatusTypeCanceled OrderStatusType = "CANCELED" OrderStatusTypePendingCancel OrderStatusType = "PENDING_CANCEL" OrderStatusTypeRejected OrderStatusType = "REJECTED" OrderStatusTypeExpired OrderStatusType = "EXPIRED" OCOListStatusTypeResponce OCOListStatusType = "RESPONSE" OCOListStatusTypeExecStarted OCOListStatusType = "EXEC_STARTED" OCOListStatusTypeAllDone OCOListStatusType = "ALL_DONE" OCOListOrderStatusTypeExecuting OCOListOrderStatusType = "EXECUTING" OCOListOrderStatusTypeAllDone OCOListOrderStatusType = "ALL_DONE" OCOListOrderStatusTypeReject OCOListOrderStatusType = "REJECT" TimeInForceTypeGTC TimeInForceType = "GTC" TimeInForceTypeIOC TimeInForceType = "IOC" TimeInForceTypeFOK TimeInForceType = "FOK" NewOrderRespTypeACK NewOrderRespType = "ACK" NewOrderRespTypeRESULT NewOrderRespType = "RESULT" NewOrderRespTypeFULL NewOrderRespType = "FULL" )
Variables ¶
var ( //baseFutureURL = "wss://fstream.binance.com/ws" //combinedBaseURL = "wss://stream.binance.com:9443/stream?streams=" // 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 FormatTimestamp ¶
FormatTimestamp formats a time into Unix timestamp in milliseconds, as requested by Binance.
func WsBookTickerServe ¶
func WsBookTickerServe(symbol string, handler WsBookTickerHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsBookTickerServe serve websocket partial depth handler with a symbol
Types ¶
type CancelOCOResponse ¶
type CancelOCOResponse struct { OrderListID int64 `json:"orderListId"` ContingencyType string `json:"contingencyType"` ListStatusType OCOListStatusType `json:"listStatusType"` ListOrderStatus OCOListOrderStatusType `json:"listOrderStatus"` ListClientOrderID string `json:"listClientOrderId"` TransactionTime int64 `json:"transactionTime"` Symbol string `json:"symbol"` Orders []*OCOOrder `json:"orders"` OrderReports []*OCOOrderReport `json:"orderReports"` }
CancelOCOResponse define response of canceling OCO order
type CancelOCOService ¶
type CancelOCOService struct {
// contains filtered or unexported fields
}
CancelOCOService cancel an OCO order
func (*CancelOCOService) Do ¶
func (s *CancelOCOService) Do(ctx context.Context, opts ...RequestOption) (res *CancelOCOResponse, err error)
Do send request
func (*CancelOCOService) ListClientOrderID ¶
func (s *CancelOCOService) ListClientOrderID(listClientOrderID string) *CancelOCOService
ListClientOrderID set listClientOrderID
func (*CancelOCOService) NewClientOrderID ¶
func (s *CancelOCOService) NewClientOrderID(newClientOrderID string) *CancelOCOService
NewClientOrderID set newClientOrderID
func (*CancelOCOService) OrderListID ¶
func (s *CancelOCOService) OrderListID(orderListID int64) *CancelOCOService
OrderListID set orderListID
func (*CancelOCOService) Symbol ¶
func (s *CancelOCOService) Symbol(symbol string) *CancelOCOService
Symbol set symbol
type Client ¶
type Client struct { APIKey string SecretKey string BaseURL string UserAgent string HTTPClient *http.Client Debug bool Logger *log.Logger TimeOffset int64 // 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) NewCancelOCOService ¶
func (c *Client) NewCancelOCOService() *CancelOCOService
NewCancelOCOService init cancel order service
func (*Client) NewCreateOCOService ¶
func (c *Client) NewCreateOCOService() *CreateOCOService
NewCreateOCOService init creating OCO service
func (*Client) NewGetOCOService ¶
func (c *Client) NewGetOCOService() *GetOCOService
NewGetOCOService init get order service
func (*Client) NewListOCOService ¶
func (c *Client) NewListOCOService() *ListOCOService
NewListOCOService init listing orders service
func (*Client) NewListOpenOCOService ¶
func (c *Client) NewListOpenOCOService() *ListOpenOCOService
NewListOpenOCOService init list open orders service
func (*Client) NewPingService ¶
func (c *Client) NewPingService() *PingService
NewPingService init ping service
func (*Client) NewServerTimeService ¶
func (c *Client) NewServerTimeService() *ServerTimeService
NewServerTimeService init server time service
func (*Client) NewSetServerTimeService ¶
func (c *Client) NewSetServerTimeService() *SetServerTimeService
NewSetServerTimeService init set server time service
type CreateOCOResponse ¶
type CreateOCOResponse struct { OrderListID int64 `json:"orderListId"` ContingencyType string `json:"contingencyType"` ListStatusType OCOListStatusType `json:"listStatusType"` ListOrderStatus OCOListOrderStatusType `json:"listOrderStatus"` ListClientOrderID string `json:"listClientOrderId"` TransactionTime int64 `json:"transactionTime"` Symbol string `json:"symbol"` Orders []*OCOOrder `json:"orders"` OrderReports []*OCOOrderReport `json:"orderReports"` }
CreateOCOResponse define create OCO order response
type CreateOCOService ¶
type CreateOCOService struct {
// contains filtered or unexported fields
}
CreateOCOService create OCO order
func (*CreateOCOService) Do ¶
func (s *CreateOCOService) Do(ctx context.Context, opts ...RequestOption) (res *CreateOCOResponse, err error)
Do send request
func (*CreateOCOService) LimitClientOrderID ¶
func (s *CreateOCOService) LimitClientOrderID(limitClientOrderID string) *CreateOCOService
LimitClientOrderID set limitClientOrderID
func (*CreateOCOService) NewOrderRespType ¶
func (s *CreateOCOService) NewOrderRespType(newOrderRespType NewOrderRespType) *CreateOCOService
NewOrderRespType set icebergQuantity
func (*CreateOCOService) Price ¶
func (s *CreateOCOService) Price(price string) *CreateOCOService
Price set price
func (*CreateOCOService) Quantity ¶
func (s *CreateOCOService) Quantity(quantity string) *CreateOCOService
Quantity set quantity
func (*CreateOCOService) Side ¶
func (s *CreateOCOService) Side(side SideType) *CreateOCOService
Side set side
func (*CreateOCOService) StopClientOrderID ¶
func (s *CreateOCOService) StopClientOrderID(stopClientOrderID string) *CreateOCOService
StopClientOrderID set stopClientOrderID
func (*CreateOCOService) StopIcebergQty ¶
func (s *CreateOCOService) StopIcebergQty(stopIcebergQty string) *CreateOCOService
StopIcebergQty set stop limit price
func (*CreateOCOService) StopLimitPrice ¶
func (s *CreateOCOService) StopLimitPrice(stopLimitPrice string) *CreateOCOService
StopLimitPrice set stop limit price
func (*CreateOCOService) StopLimitTimeInForce ¶
func (s *CreateOCOService) StopLimitTimeInForce(stopLimitTimeInForce TimeInForceType) *CreateOCOService
StopLimitTimeInForce set stopLimitTimeInForce
func (*CreateOCOService) StopPrice ¶
func (s *CreateOCOService) StopPrice(stopPrice string) *CreateOCOService
StopPrice set stop price
func (*CreateOCOService) Symbol ¶
func (s *CreateOCOService) Symbol(symbol string) *CreateOCOService
Symbol set symbol
type GetOCOService ¶
type GetOCOService struct {
// contains filtered or unexported fields
}
GetOCOService get an OCO order
func (*GetOCOService) Do ¶
func (s *GetOCOService) Do(ctx context.Context, opts ...RequestOption) (res *OCOResponse, err error)
Do send request
func (*GetOCOService) OrderListID ¶
func (s *GetOCOService) OrderListID(orderListID int64) *GetOCOService
OrderListID set orderListID
func (*GetOCOService) OrigClientOrderID ¶
func (s *GetOCOService) OrigClientOrderID(origClientOrderID string) *GetOCOService
OrigClientOrderID set listClientOrderID
type ListOCOService ¶
type ListOCOService struct {
// contains filtered or unexported fields
}
ListOCOService all account orders; active, canceled, or filled
func (*ListOCOService) Do ¶
func (s *ListOCOService) Do(ctx context.Context, opts ...RequestOption) (res []*OCOResponse, err error)
Do send request
func (*ListOCOService) EndTime ¶
func (s *ListOCOService) EndTime(endTime int64) *ListOCOService
EndTime set endtime
func (*ListOCOService) FromID ¶
func (s *ListOCOService) FromID(fromID int64) *ListOCOService
FromID set orderListID
func (*ListOCOService) Limit ¶
func (s *ListOCOService) Limit(limit int) *ListOCOService
Limit set limit
func (*ListOCOService) StartTime ¶
func (s *ListOCOService) StartTime(startTime int64) *ListOCOService
StartTime set starttime
func (*ListOCOService) Symbol ¶
func (s *ListOCOService) Symbol(symbol string) *ListOCOService
Symbol set symbol
type ListOpenOCOService ¶
type ListOpenOCOService struct {
// contains filtered or unexported fields
}
ListOpenOCOService list opened OCO orders
func (*ListOpenOCOService) Do ¶
func (s *ListOpenOCOService) Do(ctx context.Context, opts ...RequestOption) (res []*OCOResponse, err error)
Do send request
type NewOrderRespType ¶
type NewOrderRespType string
NewOrderRespType define response JSON verbosity
type OCOListOrderStatusType ¶
type OCOListOrderStatusType string
type OCOListStatusType ¶
type OCOListStatusType string
type OCOOrder ¶
type OCOOrder struct { Symbol string `json:"symbol"` OrderID int64 `json:"orderId"` ClientOrderID string `json:"clientOrderId"` }
OCOOrder may be returned in an array of OCOOrder in a CreateOCOResponse.
type OCOOrderReport ¶
type OCOOrderReport struct { Symbol string `json:"symbol"` OrderID int64 `json:"orderId"` OrderListID int64 `json:"orderListId"` ClientOrderID string `json:"clientOrderId"` TransactionTime int64 `json:"transactionTime"` Price string `json:"price"` OrigQuantity string `json:"origQty"` ExecutedQuantity string `json:"executedQty"` CummulativeQuoteQuantity string `json:"cummulativeQuoteQty"` Status OrderStatusType `json:"status"` TimeInForce TimeInForceType `json:"timeInForce"` Type OrderType `json:"type"` Side SideType `json:"side"` StopPrice string `json:"stopPrice"` }
OCOOrderReport may be returned in an array of OCOOrderReport in a CreateOCOResponse.
type OCOResponse ¶
type OCOResponse struct { OrderListID int64 `json:"orderListId"` ContingencyType string `json:"contingencyType"` ListStatusType OCOListStatusType `json:"listStatusType"` ListOrderStatus OCOListOrderStatusType `json:"listOrderStatus"` ListClientOrderID string `json:"listClientOrderId"` TransactionTime int64 `json:"transactionTime"` Symbol string `json:"symbol"` Orders []*OCOOrder `json:"orders"` }
OCOResponse define OCO order response
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 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 SetServerTimeService ¶
type SetServerTimeService struct {
// contains filtered or unexported fields
}
SetServerTimeService set server time
func (*SetServerTimeService) Do ¶
func (s *SetServerTimeService) Do(ctx context.Context, opts ...RequestOption) (timeOffset int64, err error)
Do send request
type TimeInForceType ¶
type TimeInForceType string
TimeInForceType define time in force type of order
type WsBookTickerEvent ¶
type WsBookTickerEvent struct { UpdateID int64 `json:"u"` Symbol string `json:"s"` BidPrice string `json:"b"` BidQuantity string `json:"B"` AskPrice string `json:"a"` AskQuantity string `json:"A"` }
WsBookTickerEvent define websocket individual book ticker event
type WsBookTickerHandler ¶
type WsBookTickerHandler func(event *WsBookTickerEvent)
WsBookTickerHandler handle websocket partial depth event