Documentation
¶
Index ¶
- Constants
- Variables
- func WsUserDataServe(listenKey string, handler WsUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- type Account
- type AutoCollectionService
- type Balance
- type CancelOpenOrdersServiceCM
- type CancelOpenOrdersServiceMargin
- type CancelOpenOrdersServiceUM
- type CancelOrderServiceCM
- type CancelOrderServiceMargin
- type CancelOrderServiceUM
- type ChangeLeverageServiceCM
- type ChangeLeverageServiceUM
- type ChangePositionModeServiceCM
- type ChangePositionModeServiceUM
- type Client
- func (c *Client) NewAutoCollectionService() *AutoCollectionService
- func (c *Client) NewCancelOpenOrdersServiceCM() *CancelOpenOrdersServiceCM
- func (c *Client) NewCancelOpenOrdersServiceMargin() *CancelOpenOrdersServiceMargin
- func (c *Client) NewCancelOpenOrdersServiceUM() *CancelOpenOrdersServiceUM
- func (c *Client) NewCancelOrderServiceCM() *CancelOrderServiceCM
- func (c *Client) NewCancelOrderServiceMargin() *CancelOrderServiceMargin
- func (c *Client) NewCancelOrderServiceUM() *CancelOrderServiceUM
- func (c *Client) NewChangeLeverageServiceCM() *ChangeLeverageServiceCM
- func (c *Client) NewChangeLeverageServiceUM() *ChangeLeverageServiceUM
- func (c *Client) NewChangePositionModeServiceCM() *ChangePositionModeServiceCM
- func (c *Client) NewChangePositionModeServiceUM() *ChangePositionModeServiceUM
- func (c *Client) NewCreateOrderServiceCM() *CreateOrderServiceCM
- func (c *Client) NewCreateOrderServiceMargin() *CreateOrderServiceMargin
- func (c *Client) NewCreateOrderServiceUM() *CreateOrderServiceUM
- func (c *Client) NewFutureRepayService() *FutureRepayService
- func (c *Client) NewGetAccountService() *GetAccountService
- func (c *Client) NewGetBalanceService() *GetBalanceService
- func (c *Client) NewGetCommissionRateService() *GetCommissionRateService
- func (c *Client) NewGetOrderServiceCM() *GetOrderServiceCM
- func (c *Client) NewGetOrderServiceMargin() *GetOrderServiceMargin
- func (c *Client) NewGetOrderServiceUM() *GetOrderServiceUM
- func (c *Client) NewGetPositionModeServiceCM() *GetPositionModeServiceCM
- func (c *Client) NewGetPositionModeServiceUM() *GetPositionModeServiceUM
- func (c *Client) NewGetPositionRiskServiceCM() *GetPositionRiskServiceCM
- func (c *Client) NewGetPositionRiskServiceUM() *GetPositionRiskServiceUM
- func (c *Client) NewKeepaliveUserStreamService() *KeepaliveUserStreamService
- func (c *Client) NewListOpenOrdersServiceCM() *ListOpenOrdersServiceCM
- func (c *Client) NewListOpenOrdersServiceMargin() *ListOpenOrdersServiceMargin
- func (c *Client) NewListOpenOrdersServiceUM() *ListOpenOrdersServiceUM
- func (c *Client) NewStartUserStreamService() *StartUserStreamService
- type CreateOrderServiceCM
- type CreateOrderServiceMargin
- type CreateOrderServiceUM
- type ErrHandler
- type FutureRepayService
- type FutureSubtype
- type GetAccountService
- type GetBalanceService
- type GetCommissionRateService
- type GetOrderServiceCM
- type GetOrderServiceMargin
- type GetOrderServiceUM
- type GetPositionModeServiceCM
- type GetPositionModeServiceUM
- type GetPositionRiskServiceCM
- type GetPositionRiskServiceUM
- type KeepaliveUserStreamService
- type ListOpenOrdersServiceCM
- type ListOpenOrdersServiceMargin
- type ListOpenOrdersServiceUM
- type RequestOption
- type StartUserStreamService
- type UserDataEventType
- type WsConfig
- type WsHandler
- type WsOrderTradeUpdate
- type WsUserDataEvent
- type WsUserDataHandler
Constants ¶
const ( UserDataEventTypeFutureOrderTradeUpdate UserDataEventType = "ORDER_TRADE_UPDATE" UserDataEventTypeMarginOrderTradeUpdate UserDataEventType = "executionReport" FutureSubtypeUM FutureSubtype = "UM" FutureSubtypeCM FutureSubtype = "CM" )
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 WsUserDataServe ¶
func WsUserDataServe(listenKey string, handler WsUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
WsUserDataServe serve user data handler with listen key
Types ¶
type Account ¶
type Account struct { UniMMR string `json:"uniMMR"` AccountEquity string `json:"accountEquity"` ActualEquity string `json:"actualEquity"` AccountInitialMargin string `json:"accountInitialMargin"` AccountMaintMargin string `json:"accountMaintMargin"` AccountStatus string `json:"accountStatus"` VirtualMaxWithdrawAmount string `json:"virtualMaxWithdrawAmount"` TotalAvailableBalance string `json:"totalAvailableBalance"` TotalMarginOpenLoss string `json:"totalMarginOpenLoss"` UpdateTime int64 `json:"updateTime"` }
type AutoCollectionService ¶
type AutoCollectionService struct {
// contains filtered or unexported fields
}
func (*AutoCollectionService) Do ¶
func (s *AutoCollectionService) Do(ctx context.Context, opts ...RequestOption) error
type Balance ¶
type Balance struct { Asset string `json:"asset"` TotalWalletBalance string `json:"totalWalletBalance"` CrossMarginAsset string `json:"crossMarginAsset"` CrossMarginBorrowed string `json:"crossMarginBorrowed"` CrossMarginFree string `json:"crossMarginFree"` CrossMarginInterest string `json:"crossMarginInterest"` CrossMarginLocked string `json:"crossMarginLocked"` UmWalletBalance string `json:"umWalletBalance"` UmUnrealizedPNL string `json:"umUnrealizedPNL"` CmWalletBalance string `json:"cmWalletBalance"` CmUnrealizedPNL string `json:"cmUnrealizedPNL"` NegativeBalance string `json:"negativeBalance"` UpdateTime int64 `json:"updateTime"` }
Balance define user balance of your account
type CancelOpenOrdersServiceCM ¶
type CancelOpenOrdersServiceCM struct {
Ds *delivery.CancelAllOpenOrdersService
}
func (*CancelOpenOrdersServiceCM) Do ¶
func (s *CancelOpenOrdersServiceCM) Do( ctx context.Context, opts ...delivery.RequestOption, ) error
type CancelOpenOrdersServiceMargin ¶
type CancelOpenOrdersServiceMargin struct {
Ms *binance.CancelMarginOpenOrdersService
}
Cancel open orders
type CancelOpenOrdersServiceUM ¶
type CancelOpenOrdersServiceUM struct {
Fs *futures.CancelAllOpenOrdersService
}
func (*CancelOpenOrdersServiceUM) Do ¶
func (s *CancelOpenOrdersServiceUM) Do( ctx context.Context, opts ...futures.RequestOption, ) error
type CancelOrderServiceCM ¶
type CancelOrderServiceCM struct {
Ds *delivery.CancelOrderService
}
func (*CancelOrderServiceCM) Do ¶
func (s *CancelOrderServiceCM) Do( ctx context.Context, opts ...delivery.RequestOption, ) (*delivery.CancelOrderResponse, error)
type CancelOrderServiceMargin ¶
type CancelOrderServiceMargin struct {
Ms *binance.CancelMarginOrderService
}
Cancel order
type CancelOrderServiceUM ¶
type CancelOrderServiceUM struct {
Fs *futures.CancelOrderService
}
func (*CancelOrderServiceUM) Do ¶
func (s *CancelOrderServiceUM) Do( ctx context.Context, opts ...futures.RequestOption, ) (*futures.CancelOrderResponse, error)
type ChangeLeverageServiceCM ¶
type ChangeLeverageServiceCM struct {
// contains filtered or unexported fields
}
func (*ChangeLeverageServiceCM) Do ¶
func (s *ChangeLeverageServiceCM) Do( ctx context.Context, opts ...delivery.RequestOption, ) (*delivery.SymbolLeverage, error)
func (*ChangeLeverageServiceCM) Leverage ¶
func (s *ChangeLeverageServiceCM) Leverage(leverage int) *ChangeLeverageServiceCM
func (*ChangeLeverageServiceCM) Symbol ¶
func (s *ChangeLeverageServiceCM) Symbol(symbol string) *ChangeLeverageServiceCM
type ChangeLeverageServiceUM ¶
type ChangeLeverageServiceUM struct {
// contains filtered or unexported fields
}
func (*ChangeLeverageServiceUM) Do ¶
func (s *ChangeLeverageServiceUM) Do( ctx context.Context, opts ...futures.RequestOption, ) (*futures.SymbolLeverage, error)
func (*ChangeLeverageServiceUM) Leverage ¶
func (s *ChangeLeverageServiceUM) Leverage(leverage int) *ChangeLeverageServiceUM
func (*ChangeLeverageServiceUM) Symbol ¶
func (s *ChangeLeverageServiceUM) Symbol(symbol string) *ChangeLeverageServiceUM
type ChangePositionModeServiceCM ¶
type ChangePositionModeServiceCM struct {
// contains filtered or unexported fields
}
func (*ChangePositionModeServiceCM) Do ¶
func (s *ChangePositionModeServiceCM) Do( ctx context.Context, opts ...delivery.RequestOption, ) error
func (*ChangePositionModeServiceCM) DualSide ¶
func (s *ChangePositionModeServiceCM) DualSide(dualSide bool) *ChangePositionModeServiceCM
type ChangePositionModeServiceUM ¶
type ChangePositionModeServiceUM struct {
// contains filtered or unexported fields
}
func (*ChangePositionModeServiceUM) Do ¶
func (s *ChangePositionModeServiceUM) Do( ctx context.Context, opts ...futures.RequestOption, ) error
func (*ChangePositionModeServiceUM) DualSide ¶
func (s *ChangePositionModeServiceUM) DualSide(dualSide bool) *ChangePositionModeServiceUM
type Client ¶
type Client struct { APIKey string SecretKey string BaseURL 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) NewAutoCollectionService ¶
func (c *Client) NewAutoCollectionService() *AutoCollectionService
func (*Client) NewCancelOpenOrdersServiceCM ¶
func (c *Client) NewCancelOpenOrdersServiceCM() *CancelOpenOrdersServiceCM
func (*Client) NewCancelOpenOrdersServiceMargin ¶
func (c *Client) NewCancelOpenOrdersServiceMargin() *CancelOpenOrdersServiceMargin
Cancel open orders
func (*Client) NewCancelOpenOrdersServiceUM ¶
func (c *Client) NewCancelOpenOrdersServiceUM() *CancelOpenOrdersServiceUM
func (*Client) NewCancelOrderServiceCM ¶
func (c *Client) NewCancelOrderServiceCM() *CancelOrderServiceCM
func (*Client) NewCancelOrderServiceMargin ¶
func (c *Client) NewCancelOrderServiceMargin() *CancelOrderServiceMargin
Cancel order
func (*Client) NewCancelOrderServiceUM ¶
func (c *Client) NewCancelOrderServiceUM() *CancelOrderServiceUM
func (*Client) NewChangeLeverageServiceCM ¶
func (c *Client) NewChangeLeverageServiceCM() *ChangeLeverageServiceCM
Change leverage
func (*Client) NewChangeLeverageServiceUM ¶
func (c *Client) NewChangeLeverageServiceUM() *ChangeLeverageServiceUM
func (*Client) NewChangePositionModeServiceCM ¶
func (c *Client) NewChangePositionModeServiceCM() *ChangePositionModeServiceCM
func (*Client) NewChangePositionModeServiceUM ¶
func (c *Client) NewChangePositionModeServiceUM() *ChangePositionModeServiceUM
Change position mode
func (*Client) NewCreateOrderServiceCM ¶
func (c *Client) NewCreateOrderServiceCM() *CreateOrderServiceCM
func (*Client) NewCreateOrderServiceMargin ¶
func (c *Client) NewCreateOrderServiceMargin() *CreateOrderServiceMargin
Create order
func (*Client) NewCreateOrderServiceUM ¶
func (c *Client) NewCreateOrderServiceUM() *CreateOrderServiceUM
func (*Client) NewFutureRepayService ¶
func (c *Client) NewFutureRepayService() *FutureRepayService
Repay
func (*Client) NewGetAccountService ¶
func (c *Client) NewGetAccountService() *GetAccountService
Get account
func (*Client) NewGetBalanceService ¶
func (c *Client) NewGetBalanceService() *GetBalanceService
Get balance
func (*Client) NewGetCommissionRateService ¶
func (c *Client) NewGetCommissionRateService() *GetCommissionRateService
Get commission rate
func (*Client) NewGetOrderServiceCM ¶
func (c *Client) NewGetOrderServiceCM() *GetOrderServiceCM
func (*Client) NewGetOrderServiceMargin ¶
func (c *Client) NewGetOrderServiceMargin() *GetOrderServiceMargin
Get order
func (*Client) NewGetOrderServiceUM ¶
func (c *Client) NewGetOrderServiceUM() *GetOrderServiceUM
func (*Client) NewGetPositionModeServiceCM ¶
func (c *Client) NewGetPositionModeServiceCM() *GetPositionModeServiceCM
func (*Client) NewGetPositionModeServiceUM ¶
func (c *Client) NewGetPositionModeServiceUM() *GetPositionModeServiceUM
func (*Client) NewGetPositionRiskServiceCM ¶
func (c *Client) NewGetPositionRiskServiceCM() *GetPositionRiskServiceCM
Get position risk
func (*Client) NewGetPositionRiskServiceUM ¶
func (c *Client) NewGetPositionRiskServiceUM() *GetPositionRiskServiceUM
func (*Client) NewKeepaliveUserStreamService ¶
func (c *Client) NewKeepaliveUserStreamService() *KeepaliveUserStreamService
Keepalive
func (*Client) NewListOpenOrdersServiceCM ¶
func (c *Client) NewListOpenOrdersServiceCM() *ListOpenOrdersServiceCM
func (*Client) NewListOpenOrdersServiceMargin ¶
func (c *Client) NewListOpenOrdersServiceMargin() *ListOpenOrdersServiceMargin
List open orders
func (*Client) NewListOpenOrdersServiceUM ¶
func (c *Client) NewListOpenOrdersServiceUM() *ListOpenOrdersServiceUM
func (*Client) NewStartUserStreamService ¶
func (c *Client) NewStartUserStreamService() *StartUserStreamService
User stream
type CreateOrderServiceCM ¶
type CreateOrderServiceCM struct {
Ds *delivery.CreateOrderService
}
func (*CreateOrderServiceCM) Do ¶
func (s *CreateOrderServiceCM) Do( ctx context.Context, opts ...delivery.RequestOption, ) (*delivery.CreateOrderResponse, error)
type CreateOrderServiceMargin ¶
type CreateOrderServiceMargin struct {
Ms *binance.CreateMarginOrderService
}
type CreateOrderServiceUM ¶
type CreateOrderServiceUM struct {
Fs *futures.CreateOrderService
}
func (*CreateOrderServiceUM) Do ¶
func (s *CreateOrderServiceUM) Do( ctx context.Context, opts ...futures.RequestOption, ) (*futures.CreateOrderResponse, error)
type FutureRepayService ¶
type FutureRepayService struct {
// contains filtered or unexported fields
}
func (*FutureRepayService) Do ¶
func (s *FutureRepayService) Do(ctx context.Context, opts ...RequestOption) error
type FutureSubtype ¶
type FutureSubtype string
type GetAccountService ¶
type GetAccountService struct {
// contains filtered or unexported fields
}
func (*GetAccountService) Do ¶
func (s *GetAccountService) Do(ctx context.Context, opts ...RequestOption) (*Account, error)
type GetBalanceService ¶
type GetBalanceService struct {
// contains filtered or unexported fields
}
GetBalanceService get account balance
func (*GetBalanceService) Do ¶
func (s *GetBalanceService) Do(ctx context.Context, opts ...RequestOption) ([]*Balance, error)
Do send request
type GetCommissionRateService ¶
type GetCommissionRateService struct {
// contains filtered or unexported fields
}
func (*GetCommissionRateService) Do ¶
func (s *GetCommissionRateService) Do( ctx context.Context, opts ...delivery.RequestOption, ) (*delivery.CommissionRate, error)
func (*GetCommissionRateService) Symbol ¶
func (s *GetCommissionRateService) Symbol(symbol string) *GetCommissionRateService
type GetOrderServiceCM ¶
type GetOrderServiceCM struct {
Ds *delivery.GetOrderService
}
func (*GetOrderServiceCM) Do ¶
func (s *GetOrderServiceCM) Do( ctx context.Context, opts ...delivery.RequestOption, ) (*delivery.Order, error)
type GetOrderServiceMargin ¶
type GetOrderServiceMargin struct {
Ms *binance.GetMarginOrderService
}
Get order
type GetOrderServiceUM ¶
type GetOrderServiceUM struct {
Fs *futures.GetOrderService
}
func (*GetOrderServiceUM) Do ¶
func (s *GetOrderServiceUM) Do( ctx context.Context, opts ...futures.RequestOption, ) (*futures.Order, error)
type GetPositionModeServiceCM ¶
type GetPositionModeServiceCM struct {
// contains filtered or unexported fields
}
func (*GetPositionModeServiceCM) Do ¶
func (s *GetPositionModeServiceCM) Do( ctx context.Context, opts ...delivery.RequestOption, ) (*delivery.PositionMode, error)
type GetPositionModeServiceUM ¶
type GetPositionModeServiceUM struct {
// contains filtered or unexported fields
}
func (*GetPositionModeServiceUM) Do ¶
func (s *GetPositionModeServiceUM) Do( ctx context.Context, opts ...futures.RequestOption, ) (*futures.PositionMode, error)
type GetPositionRiskServiceCM ¶
type GetPositionRiskServiceCM struct {
// contains filtered or unexported fields
}
func (*GetPositionRiskServiceCM) Do ¶
func (s *GetPositionRiskServiceCM) Do( ctx context.Context, opts ...delivery.RequestOption, ) ([]*delivery.PositionRisk, error)
type GetPositionRiskServiceUM ¶
type GetPositionRiskServiceUM struct {
// contains filtered or unexported fields
}
func (*GetPositionRiskServiceUM) Do ¶
func (s *GetPositionRiskServiceUM) Do( ctx context.Context, opts ...futures.RequestOption, ) ([]*futures.PositionRisk, error)
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 ListOpenOrdersServiceCM ¶
type ListOpenOrdersServiceCM struct {
Ds *delivery.ListOpenOrdersService
}
func (*ListOpenOrdersServiceCM) Do ¶
func (s *ListOpenOrdersServiceCM) Do( ctx context.Context, opts ...delivery.RequestOption, ) ([]*delivery.Order, error)
type ListOpenOrdersServiceMargin ¶
type ListOpenOrdersServiceMargin struct {
Ms *binance.ListMarginOpenOrdersService
}
List open orders
type ListOpenOrdersServiceUM ¶
type ListOpenOrdersServiceUM struct {
Fs *futures.ListOpenOrdersService
}
func (*ListOpenOrdersServiceUM) Do ¶
func (s *ListOpenOrdersServiceUM) Do( ctx context.Context, opts ...futures.RequestOption, ) ([]*futures.Order, error)
type RequestOption ¶
type RequestOption func(*request)
RequestOption define option type for request
func WithHeader ¶
func WithHeader(key, value string, replace bool) RequestOption
WithHeader set or add a header value to the request
func WithHeaders ¶
func WithHeaders(header http.Header) RequestOption
WithHeaders set or replace the headers of the request
func WithRecvWindow ¶
func WithRecvWindow(recvWindow int64) RequestOption
WithRecvWindow set recvWindow param for the 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 UserDataEventType ¶
type UserDataEventType string
type WsOrderTradeUpdate ¶
type WsOrderTradeUpdate struct { Margin *binance.WsOrderUpdate CM *delivery.WsOrderTradeUpdate UM *futures.WsOrderTradeUpdate }
type WsUserDataEvent ¶
type WsUserDataEvent struct { Event UserDataEventType `json:"e"` FutureSubtype FutureSubtype `json:"fs"` Time int64 `json:"E"` TransactionTime int64 `json:"T"` OrderTradeUpdate WsOrderTradeUpdate }
WsUserDataEvent define user data event
type WsUserDataHandler ¶
type WsUserDataHandler func(event *WsUserDataEvent)
WsUserDataHandler handle WsUserDataEvent