delivery

package
v2.0.0-...-332b403 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SideTypeBuy  SideType = "BUY"
	SideTypeSell SideType = "SELL"

	PositionSideTypeBoth  PositionSideType = "BOTH"
	PositionSideTypeLong  PositionSideType = "LONG"
	PositionSideTypeShort PositionSideType = "SHORT"

	OrderTypeLimit              OrderType = "LIMIT"
	OrderTypeMarket             OrderType = "MARKET"
	OrderTypeStop               OrderType = "STOP"
	OrderTypeStopMarket         OrderType = "STOP_MARKET"
	OrderTypeTakeProfit         OrderType = "TAKE_PROFIT"
	OrderTypeTakeProfitMarket   OrderType = "TAKE_PROFIT_MARKET"
	OrderTypeTrailingStopMarket OrderType = "TRAILING_STOP_MARKET"

	TimeInForceTypeGTC TimeInForceType = "GTC" // Good Till Cancel
	TimeInForceTypeIOC TimeInForceType = "IOC" // Immediate or Cancel
	TimeInForceTypeFOK TimeInForceType = "FOK" // Fill or Kill
	TimeInForceTypeGTX TimeInForceType = "GTX" // Good Till Crossing (Post Only)

	NewOrderRespTypeACK    NewOrderRespType = "ACK"
	NewOrderRespTypeRESULT NewOrderRespType = "RESULT"
	NewOrderRespTypeFULL   NewOrderRespType = "FULL"

	OrderExecutionTypeNew         OrderExecutionType = "NEW"
	OrderExecutionTypePartialFill OrderExecutionType = "PARTIAL_FILL"
	OrderExecutionTypeFill        OrderExecutionType = "FILL"
	OrderExecutionTypeCanceled    OrderExecutionType = "CANCELED"
	OrderExecutionTypeCalculated  OrderExecutionType = "CALCULATED"
	OrderExecutionTypeExpired     OrderExecutionType = "EXPIRED"
	OrderExecutionTypeTrade       OrderExecutionType = "TRADE"

	OrderStatusTypeNew             OrderStatusType = "NEW"
	OrderStatusTypePartiallyFilled OrderStatusType = "PARTIALLY_FILLED"
	OrderStatusTypeFilled          OrderStatusType = "FILLED"
	OrderStatusTypeCanceled        OrderStatusType = "CANCELED"
	OrderStatusTypeRejected        OrderStatusType = "REJECTED"
	OrderStatusTypeExpired         OrderStatusType = "EXPIRED"

	SymbolTypeFuture SymbolType = "FUTURE"

	WorkingTypeMarkPrice     WorkingType = "MARK_PRICE"
	WorkingTypeContractPrice WorkingType = "CONTRACT_PRICE"

	SymbolStatusTypePreTrading   SymbolStatusType = "PRE_TRADING"
	SymbolStatusTypeTrading      SymbolStatusType = "TRADING"
	SymbolStatusTypePostTrading  SymbolStatusType = "POST_TRADING"
	SymbolStatusTypeEndOfDay     SymbolStatusType = "END_OF_DAY"
	SymbolStatusTypeHalt         SymbolStatusType = "HALT"
	SymbolStatusTypeAuctionMatch SymbolStatusType = "AUCTION_MATCH"
	SymbolStatusTypeBreak        SymbolStatusType = "BREAK"

	SymbolFilterTypeLotSize       SymbolFilterType = "LOT_SIZE"
	SymbolFilterTypePrice         SymbolFilterType = "PRICE_FILTER"
	SymbolFilterTypePercentPrice  SymbolFilterType = "PERCENT_PRICE"
	SymbolFilterTypeMarketLotSize SymbolFilterType = "MARKET_LOT_SIZE"
	SymbolFilterTypeMaxNumOrders  SymbolFilterType = "MAX_NUM_ORDERS"

	SideEffectTypeNoSideEffect SideEffectType = "NO_SIDE_EFFECT"
	SideEffectTypeMarginBuy    SideEffectType = "MARGIN_BUY"
	SideEffectTypeAutoRepay    SideEffectType = "AUTO_REPAY"

	MarginTypeIsolated MarginType = "ISOLATED"
	MarginTypeCrossed  MarginType = "CROSSED"

	UserDataEventTypeListenKeyExpired    UserDataEventType = "listenKeyExpired"
	UserDataEventTypeMarginCall          UserDataEventType = "MARGIN_CALL"
	UserDataEventTypeAccountUpdate       UserDataEventType = "ACCOUNT_UPDATE"
	UserDataEventTypeOrderTradeUpdate    UserDataEventType = "ORDER_TRADE_UPDATE"
	UserDataEventTypeAccountConfigUpdate UserDataEventType = "ACCOUNT_CONFIG_UPDATE"

	UserDataEventReasonTypeDeposit             UserDataEventReasonType = "DEPOSIT"
	UserDataEventReasonTypeWithdraw            UserDataEventReasonType = "WITHDRAW"
	UserDataEventReasonTypeOrder               UserDataEventReasonType = "ORDER"
	UserDataEventReasonTypeFundingFee          UserDataEventReasonType = "FUNDING_FEE"
	UserDataEventReasonTypeWithdrawReject      UserDataEventReasonType = "WITHDRAW_REJECT"
	UserDataEventReasonTypeAdjustment          UserDataEventReasonType = "ADJUSTMENT"
	UserDataEventReasonTypeInsuranceClear      UserDataEventReasonType = "INSURANCE_CLEAR"
	UserDataEventReasonTypeAdminDeposit        UserDataEventReasonType = "ADMIN_DEPOSIT"
	UserDataEventReasonTypeAdminWithdraw       UserDataEventReasonType = "ADMIN_WITHDRAW"
	UserDataEventReasonTypeMarginTransfer      UserDataEventReasonType = "MARGIN_TRANSFER"
	UserDataEventReasonTypeMarginTypeChange    UserDataEventReasonType = "MARGIN_TYPE_CHANGE"
	UserDataEventReasonTypeAssetTransfer       UserDataEventReasonType = "ASSET_TRANSFER"
	UserDataEventReasonTypeOptionsPremiumFee   UserDataEventReasonType = "OPTIONS_PREMIUM_FEE"
	UserDataEventReasonTypeOptionsSettleProfit UserDataEventReasonType = "OPTIONS_SETTLE_PROFIT"
)

Global enums

Variables

View Source
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
	// UseTestnet switch all the WS streams from production to the testnet
	UseTestnet = false
)

Functions

func WsAggTradeServe

func WsAggTradeServe(symbol string, handler WsAggTradeHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsAggTradeServe serve websocket that push trade information that is aggregated for a single taker order.

func WsAllBookTickerServe

func WsAllBookTickerServe(handler WsBookTickerHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsAllBookTickerServe serve websocket that pushes updates to the best bid or ask price or quantity in real-time for all symbols.

func WsAllLiquidationOrderServe

func WsAllLiquidationOrderServe(handler WsLiquidationOrderHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsAllLiquidationOrderServe serve websocket that pushes force liquidation order information for all symbols.

func WsAllMarketTickerServe

func WsAllMarketTickerServe(handler WsAllMarketTickerHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsAllMarketTickerServe serve websocket that pushes price and funding rate for all markets.

func WsAllMiniMarketTickerServe

func WsAllMiniMarketTickerServe(handler WsAllMiniMarketTickerHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsAllMiniMarketTickerServe serve websocket that pushes price and funding rate for all markets.

func WsBookTickerServe

func WsBookTickerServe(symbol string, handler WsBookTickerHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsBookTickerServe serve websocket that pushes updates to the best bid or ask price or quantity in real-time for a specified symbol.

func WsContinuousKlineServe

func WsContinuousKlineServe(pair string, contractType string, interval string, handler WsContinuousKlineHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsContinuousKlineServe serve websocket kline handler with a pair, a contract type and interval like 15m, 30s

func WsDiffDepthServe

func WsDiffDepthServe(symbol string, handler WsDepthHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsDiffDepthServe serve websocket diff. depth handler.

func WsDiffDepthServeWithRate

func WsDiffDepthServeWithRate(symbol string, rate *time.Duration, handler WsDepthHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsDiffDepthServe serve websocket diff. depth handler with rate.

func WsIndexPriceKlineServe

func WsIndexPriceKlineServe(pair string, interval string, handler WsIndexPriceKlineHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsIndexPriceKlineServe serve websocket kline handler with a pair and interval like 15m, 30s

func WsIndexPriceServe

func WsIndexPriceServe(symbol string, handler WsIndexPriceHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsIndexPriceServe serve websocket that pushes index price for a pair.

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 WsLiquidationOrderServe

func WsLiquidationOrderServe(symbol string, handler WsLiquidationOrderHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsLiquidationOrderServe serve websocket that pushes force liquidation order information for specific symbol.

func WsMarkPriceKlineServe

func WsMarkPriceKlineServe(symbol string, interval string, handler WsMarkPriceKlineHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsMarkPriceKlineServe serve websocket kline handler with a symbol and interval like 15m, 30s

func WsMarkPriceServe

func WsMarkPriceServe(symbol string, handler WsMarkPriceHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsMarkPriceServe serve websocket that pushes price and funding rate for a single symbol.

func WsMarketTickerServe

func WsMarketTickerServe(symbol string, handler WsMarketTickerHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsMarketTickerServe serve websocket that pushes 24hr rolling window mini-ticker statistics for a single symbol.

func WsMiniMarketTickerServe

func WsMiniMarketTickerServe(symbol string, handler WsMiniMarketTickerHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsMiniMarketTickerServe serve websocket that pushes 24hr rolling window mini-ticker statistics for a single symbol.

func WsPairMarkPriceServe

func WsPairMarkPriceServe(handler WsPairMarkPriceHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsPairMarkPriceServe serve websocket that pushes price and funding rate for all symbol.

func WsPartialDepthServe

func WsPartialDepthServe(symbol string, levels int, handler WsDepthHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsPartialDepthServe serve websocket partial depth handler.

func WsPartialDepthServeWithRate

func WsPartialDepthServeWithRate(symbol string, levels int, rate *time.Duration, handler WsDepthHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

WsPartialDepthServeWithRate serve websocket partial depth handler with rate.

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 {
	Assets      []*AccountAsset    `json:"assets"`
	CanDeposit  bool               `json:"canDeposit"`
	CanTrade    bool               `json:"canTrade"`
	CanWithdraw bool               `json:"canWithdraw"`
	FeeTier     int                `json:"feeTier"`
	Positions   []*AccountPosition `json:"positions"`
	UpdateTime  int64              `json:"updateType"`
}

Account define account info

type AccountAsset

type AccountAsset struct {
	Asset                  string `json:"asset"`
	WalletBalance          string `json:"walletBalance"`
	UnrealizedProfit       string `json:"unrealizedProfit"`
	MarginBalance          string `json:"marginBalance"`
	MaintMargin            string `json:"maintMargin"`
	InitialMargin          string `json:"initialMargin"`
	PositionInitialMargin  string `json:"positionInitialMargin"`
	OpenOrderInitialMargin string `json:"openOrderInitialMargin"`
	MaxWithdrawAmount      string `json:"maxWithdrawAmount"`
	CrossWalletBalance     string `json:"crossWalletBalance"`
	CrossUnPnl             string `json:"crossUnPnl"`
	AvailableBalance       string `json:"availableBalance"`
}

AccountAsset define account asset

type AccountPosition

type AccountPosition struct {
	Symbol                 string `json:"symbol"`
	PositionAmt            string `json:"positionAmt"`
	InitialMargin          string `json:"initialMargin"`
	MaintMargin            string `json:"maintMargin"`
	UnrealizedProfit       string `json:"unrealizedProfit"`
	PositionInitialMargin  string `json:"positionInitialMargin"`
	OpenOrderInitialMargin string `json:"openOrderInitialMargin"`
	Leverage               string `json:"leverage"`
	Isolated               bool   `json:"isolated"`
	PositionSide           string `json:"positionSide"`
	EntryPrice             string `json:"entryPrice"`
	MaxQty                 string `json:"maxQty"`
}

AccountPosition define accoutn position

type Ask

type Ask = common.PriceLevel

Ask is a type alias for PriceLevel.

type Balance

type Balance struct {
	AccountAlias       string `json:"accountAlias"`
	Asset              string `json:"asset"`
	Balance            string `json:"balance"`
	WithdrawAvailable  string `json:"withdrawAvailable"`
	CrossWalletBalance string `json:"crossWalletBalance"`
	CrossUnPnl         string `json:"crossUnPnl"`
	AvailableBalance   string `json:"availableBalance"`
	UpdateTime         int64  `json:"updateTime"`
}

Balance define user balance of your account

type Bid

type Bid = common.PriceLevel

Bid is a type alias for PriceLevel.

type BookTicker

type BookTicker struct {
	Symbol      string `json:"symbol"`
	Pair        string `json:"pair"`
	BidPrice    string `json:"bidPrice"`
	BidQuantity string `json:"bidQty"`
	AskPrice    string `json:"askPrice"`
	AskQuantity string `json:"askQty"`
}

BookTicker define book ticker info.

type CancelAllOpenOrdersService

type CancelAllOpenOrdersService struct {
	// contains filtered or unexported fields
}

CancelAllOpenOrdersService cancel all open orders

func (*CancelAllOpenOrdersService) Do

func (s *CancelAllOpenOrdersService) Do(ctx context.Context, opts ...RequestOption) (err error)

Do send request

func (*CancelAllOpenOrdersService) Symbol

Symbol set symbol

type CancelOrderResponse

type CancelOrderResponse struct {
	AvgPrice         string           `json:"avgPrice"`
	ClientOrderID    string           `json:"clientOrderId"`
	CumQuantity      string           `json:"cumQty"`
	CumBase          string           `json:"cumBase"`
	ExecutedQuantity string           `json:"executedQty"`
	OrderID          int64            `json:"orderId"`
	OrigQuantity     string           `json:"origQty"`
	OrigType         OrderType        `json:"origType"`
	Price            string           `json:"price"`
	ReduceOnly       bool             `json:"reduceOnly"`
	Side             SideType         `json:"side"`
	PositionSide     PositionSideType `json:"positionSide"`
	Status           OrderStatusType  `json:"status"`
	StopPrice        string           `json:"stopPrice"`
	ClosePosition    bool             `json:"closePosition"`
	Symbol           string           `json:"symbol"`
	Pair             string           `json:"pair"`
	TimeInForce      TimeInForceType  `json:"timeInForce"`
	Type             OrderType        `json:"type"`
	ActivatePrice    string           `json:"activatePrice"`
	PriceRate        string           `json:"priceRate"`
	UpdateTime       int64            `json:"updateTime"`
	WorkingType      WorkingType      `json:"workingType"`
	PriceProtect     bool             `json:"priceProtect"`
}

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) 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 ChangeLeverageService

type ChangeLeverageService struct {
	// contains filtered or unexported fields
}

ChangeLeverageService change user's initial leverage of specific symbol market

func (*ChangeLeverageService) Do

func (s *ChangeLeverageService) Do(ctx context.Context, opts ...RequestOption) (res *SymbolLeverage, err error)

Do send request

func (*ChangeLeverageService) Leverage

func (s *ChangeLeverageService) Leverage(leverage int) *ChangeLeverageService

Leverage set leverage

func (*ChangeLeverageService) Symbol

Symbol set symbol

type ChangeMarginTypeService

type ChangeMarginTypeService struct {
	// contains filtered or unexported fields
}

ChangeMarginTypeService change user's margin type of specific symbol market

func (*ChangeMarginTypeService) Do

func (s *ChangeMarginTypeService) Do(ctx context.Context, opts ...RequestOption) (err error)

Do send request

func (*ChangeMarginTypeService) MarginType

func (s *ChangeMarginTypeService) MarginType(marginType MarginType) *ChangeMarginTypeService

MarginType set margin type

func (*ChangeMarginTypeService) Symbol

Symbol set symbol

type ChangePositionModeService

type ChangePositionModeService struct {
	// contains filtered or unexported fields
}

ChangePositionModeService change user's position mode

func (*ChangePositionModeService) Do

func (s *ChangePositionModeService) Do(ctx context.Context, opts ...RequestOption) (err error)

Do send request

func (*ChangePositionModeService) DualSide

Change user's position mode: true - Hedge Mode, false - One-way Mode

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

func NewClient(apiKey, secretKey string) *Client

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) NewCancelAllOpenOrdersService

func (c *Client) NewCancelAllOpenOrdersService() *CancelAllOpenOrdersService

NewCancelAllOpenOrdersService init cancel all open orders service

func (*Client) NewCancelOrderService

func (c *Client) NewCancelOrderService() *CancelOrderService

NewCancelOrderService init cancel order service

func (*Client) NewChangeLeverageService

func (c *Client) NewChangeLeverageService() *ChangeLeverageService

NewChangeLeverageService init change leverage service

func (*Client) NewChangeMarginTypeService

func (c *Client) NewChangeMarginTypeService() *ChangeMarginTypeService

NewChangeMarginTypeService init change margin type service

func (*Client) NewChangePositionModeService

func (c *Client) NewChangePositionModeService() *ChangePositionModeService

NewChangePositionModeService init change position mode 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) NewExchangeInfoService

func (c *Client) NewExchangeInfoService() *ExchangeInfoService

NewExchangeInfoService init exchange info service

func (*Client) NewGetAccountService

func (c *Client) NewGetAccountService() *GetAccountService

NewGetAccountService init account service

func (*Client) NewGetBalanceService

func (c *Client) NewGetBalanceService() *GetBalanceService

NewGetBalanceService init balance service

func (*Client) NewGetOrderService

func (c *Client) NewGetOrderService() *GetOrderService

NewGetOrderService init get order service

func (*Client) NewGetPositionModeService

func (c *Client) NewGetPositionModeService() *GetPositionModeService

NewGetPositionModeService init get position mode service

func (*Client) NewGetPositionRiskService

func (c *Client) NewGetPositionRiskService() *GetPositionRiskService

NewGetPositionRiskService init getting position risk 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) NewListLiquidationOrdersService

func (c *Client) NewListLiquidationOrdersService() *ListLiquidationOrdersService

NewListLiquidationOrdersService init funding rate 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) 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

func (*Client) NewStartUserStreamService

func (c *Client) NewStartUserStreamService() *StartUserStreamService

NewStartUserStreamService init starting user stream service

func (*Client) NewUpdatePositionMarginService

func (c *Client) NewUpdatePositionMarginService() *UpdatePositionMarginService

NewUpdatePositionMarginService init update position margin

func (*Client) SetApiEndpoint

func (c *Client) SetApiEndpoint(url string) *Client

SetApiEndpoint set api Endpoint

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 {
	ClientOrderID    string           `json:"clientOrderId"`
	CumQuantity      string           `json:"cumQty"`
	CumBase          string           `json:"cumBase"`
	ExecutedQuantity string           `json:"executedQty"`
	OrderID          int64            `json:"orderId"`
	AvgPrice         string           `json:"avgPrice"`
	OrigQuantity     string           `json:"origQty"`
	Price            string           `json:"price"`
	ReduceOnly       bool             `json:"reduceOnly"`
	Side             SideType         `json:"side"`
	PositionSide     PositionSideType `json:"positionSide"`
	Status           OrderStatusType  `json:"status"`
	StopPrice        string           `json:"stopPrice"`
	ClosePosition    bool             `json:"closePosition"`
	Symbol           string           `json:"symbol"`
	Pair             string           `json:"pair"`
	TimeInForce      TimeInForceType  `json:"timeInForce"`
	Type             OrderType        `json:"type"`
	OrigType         OrderType        `json:"origType"`
	ActivatePrice    string           `json:"activatePrice"`
	PriceRate        string           `json:"priceRate"`
	UpdateTime       int64            `json:"updateTime"`
	WorkingType      WorkingType      `json:"workingType"`
	PriceProtect     bool             `json:"priceProtect"`
}

CreateOrderResponse define create order response

type CreateOrderService

type CreateOrderService struct {
	// contains filtered or unexported fields
}

CreateOrderService create order

func (*CreateOrderService) ActivationPrice

func (s *CreateOrderService) ActivationPrice(activationPrice string) *CreateOrderService

ActivationPrice set activationPrice

func (*CreateOrderService) CallbackRate

func (s *CreateOrderService) CallbackRate(callbackRate string) *CreateOrderService

CallbackRate set callbackRate

func (*CreateOrderService) ClosePosition

func (s *CreateOrderService) ClosePosition(closePosition bool) *CreateOrderService

ClosePosition set closePosition

func (*CreateOrderService) Do

func (s *CreateOrderService) Do(ctx context.Context, opts ...RequestOption) (res *CreateOrderResponse, err error)

Do send request

func (*CreateOrderService) NewClientOrderID

func (s *CreateOrderService) NewClientOrderID(newClientOrderID string) *CreateOrderService

NewClientOrderID set newClientOrderID

func (*CreateOrderService) NewOrderResponseType

func (s *CreateOrderService) NewOrderResponseType(newOrderResponseType NewOrderRespType) *CreateOrderService

NewOrderResponseType set newOrderResponseType

func (*CreateOrderService) PositionSide

func (s *CreateOrderService) PositionSide(positionSide PositionSideType) *CreateOrderService

PositionSide set side

func (*CreateOrderService) Price

func (s *CreateOrderService) Price(price string) *CreateOrderService

Price set price

func (*CreateOrderService) PriceProtect

func (s *CreateOrderService) PriceProtect(priceProtect bool) *CreateOrderService

PriceProtect set priceProtect

func (*CreateOrderService) Quantity

func (s *CreateOrderService) Quantity(quantity string) *CreateOrderService

Quantity set quantity

func (*CreateOrderService) ReduceOnly

func (s *CreateOrderService) ReduceOnly(reduceOnly bool) *CreateOrderService

ReduceOnly set reduceOnly

func (*CreateOrderService) Side

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) TimeInForce

func (s *CreateOrderService) TimeInForce(timeInForce TimeInForceType) *CreateOrderService

TimeInForce set timeInForce

func (*CreateOrderService) Type

func (s *CreateOrderService) Type(orderType OrderType) *CreateOrderService

Type set type

func (*CreateOrderService) WorkingType

func (s *CreateOrderService) WorkingType(workingType WorkingType) *CreateOrderService

WorkingType set workingType

type ErrHandler

type ErrHandler func(err error)

ErrHandler handles errors

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 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 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) (res []*Balance, 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 GetPositionModeService

type GetPositionModeService struct {
	// contains filtered or unexported fields
}

GetPositionModeService get user's position mode

func (*GetPositionModeService) Do

func (s *GetPositionModeService) Do(ctx context.Context, opts ...RequestOption) (res *PositionMode, err error)

Do send request

type GetPositionRiskService

type GetPositionRiskService struct {
	// contains filtered or unexported fields
}

GetPositionRiskService get account balance

func (*GetPositionRiskService) Do

func (s *GetPositionRiskService) Do(ctx context.Context, opts ...RequestOption) (res []*PositionRisk, err error)

Do send request

func (*GetPositionRiskService) MarginAsset

func (s *GetPositionRiskService) MarginAsset(marginAsset string) *GetPositionRiskService

MarginAsset set margin asset

func (*GetPositionRiskService) Pair

Pair set pair

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

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 LiquidationOrder

type LiquidationOrder struct {
	Symbol           string          `json:"symbol"`
	Price            string          `json:"price"`
	OrigQuantity     string          `json:"origQty"`
	ExecutedQuantity string          `json:"executedQty"`
	AveragePrice     string          `json:"avragePrice"`
	Status           OrderStatusType `json:"status"`
	TimeInForce      TimeInForceType `json:"timeInForce"`
	Type             OrderType       `json:"type"`
	Side             SideType        `json:"side"`
	Time             int64           `json:"time"`
}

LiquidationOrder define liquidation order

type ListBookTickersService

type ListBookTickersService struct {
	// contains filtered or unexported fields
}

ListBookTickersService list best price/qty on the order book for a symbol or symbols.

func (*ListBookTickersService) Do

func (s *ListBookTickersService) Do(ctx context.Context, opts ...RequestOption) (res []*BookTicker, err error)

Do send request.

func (*ListBookTickersService) Pair

Pair set pair.

func (*ListBookTickersService) Symbol

Symbol set symbol.

type ListLiquidationOrdersService

type ListLiquidationOrdersService struct {
	// contains filtered or unexported fields
}

ListLiquidationOrdersService list liquidation orders

func (*ListLiquidationOrdersService) Do

Do send request

func (*ListLiquidationOrdersService) EndTime

EndTime set startTime

func (*ListLiquidationOrdersService) Limit

Limit set limit

func (*ListLiquidationOrdersService) Pair

Pair set pair

func (*ListLiquidationOrdersService) StartTime

StartTime set startTime

func (*ListLiquidationOrdersService) Symbol

Symbol set symbol

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) Pair

Pair set pair

func (*ListOpenOrdersService) Symbol

Symbol set symbol

type ListOrdersService

type ListOrdersService struct {
	// contains filtered or unexported fields
}

ListOrdersService all account orders; active, canceled, or filled

func (*ListOrdersService) Do

func (s *ListOrdersService) Do(ctx context.Context, opts ...RequestOption) (res []*Order, err error)

Do send request

func (*ListOrdersService) EndTime

func (s *ListOrdersService) EndTime(endTime int64) *ListOrdersService

EndTime set endtime

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) Pair

Pair set pair

func (*ListOrdersService) StartTime

func (s *ListOrdersService) StartTime(startTime int64) *ListOrdersService

StartTime set starttime

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 single symbol, all symbols or pairs of symbols.

func (*ListPriceChangeStatsService) Do

Do send request.

func (*ListPriceChangeStatsService) Pair

Pair set pair.

func (*ListPriceChangeStatsService) Symbol

Symbol set symbol.

type ListPricesService

type ListPricesService struct {
	// contains filtered or unexported fields
}

ListPricesService list latest price for a symbol or symbols.

func (*ListPricesService) Do

func (s *ListPricesService) Do(ctx context.Context, opts ...RequestOption) (res []*SymbolPrice, err error)

Do send request.

func (*ListPricesService) Pair

Pair set pair.

func (*ListPricesService) Symbol

func (s *ListPricesService) Symbol(symbol string) *ListPricesService

Symbol set symbol.

type LotSizeFilter

type LotSizeFilter struct {
	MaxQuantity string `json:"maxQty"`
	MinQuantity string `json:"minQty"`
	StepSize    string `json:"stepSize"`
}

LotSizeFilter define lot size filter of symbol

type MarginType

type MarginType string

MarginType define margin type

type MarketLotSizeFilter

type MarketLotSizeFilter struct {
	MaxQuantity string `json:"maxQty"`
	MinQuantity string `json:"minQty"`
	StepSize    string `json:"stepSize"`
}

MarketLotSizeFilter define market lot size filter of symbol

type MaxNumOrdersFilter

type MaxNumOrdersFilter struct {
	Limit int64 `json:"limit"`
}

MaxNumOrdersFilter define max num orders filter of symbol

type NewOrderRespType

type NewOrderRespType string

NewOrderRespType define response JSON verbosity

type Order

type Order struct {
	AvgPrice         string           `json:"avgPrice"`
	ClientOrderID    string           `json:"clientOrderId"`
	CumBase          string           `json:"cumBase"`
	ExecutedQuantity string           `json:"executedQty"`
	OrderID          int64            `json:"orderId"`
	OrigQuantity     string           `json:"origQty"`
	OrigType         OrderType        `json:"origType"`
	Price            string           `json:"price"`
	ReduceOnly       bool             `json:"reduceOnly"`
	Side             SideType         `json:"side"`
	PositionSide     PositionSideType `json:"positionSide"`
	Status           OrderStatusType  `json:"status"`
	StopPrice        string           `json:"stopPrice"`
	ClosePosition    bool             `json:"closePosition"`
	Symbol           string           `json:"symbol"`
	Pair             string           `json:"pair"`
	Time             int64            `json:"time"`
	TimeInForce      TimeInForceType  `json:"timeInForce"`
	Type             OrderType        `json:"type"`
	ActivatePrice    string           `json:"activatePrice"`
	PriceRate        string           `json:"priceRate"`
	UpdateTime       int64            `json:"updateTime"`
	WorkingType      WorkingType      `json:"workingType"`
	PriceProtect     bool             `json:"priceProtect"`
}

Order define order info

type OrderExecutionType

type OrderExecutionType string

OrderExecutionType define order execution type

type OrderStatusType

type OrderStatusType string

OrderStatusType define order status type

type OrderType

type OrderType string

OrderType define order type

type PercentPriceFilter

type PercentPriceFilter struct {
	MultiplierDecimal int    `json:"multiplierDecimal"`
	MultiplierUp      string `json:"multiplierUp"`
	MultiplierDown    string `json:"multiplierDown"`
}

PercentPriceFilter define percent price filter of symbol

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 PositionMode

type PositionMode struct {
	DualSidePosition bool `json:"dualSidePosition"`
}

Response of user's position mode

type PositionRisk

type PositionRisk struct {
	Symbol           string `json:"symbol"`
	PositionAmt      string `json:"positionAmt"`
	EntryPrice       string `json:"entryPrice"`
	MarkPrice        string `json:"markPrice"`
	UnRealizedProfit string `json:"unRealizedProfit"`
	LiquidationPrice string `json:"liquidationPrice"`
	Leverage         string `json:"leverage"`
	MaxQuantity      string `json:"maxQty"`
	MarginType       string `json:"marginType"`
	IsolatedMargin   string `json:"isolatedMargin"`
	IsAutoAddMargin  string `json:"isAutoAddMargin"`
	PositionSide     string `json:"positionSide"`
}

PositionRisk define position risk info

type PositionSideType

type PositionSideType string

PositionSideType define position side type of order

type PriceChangeStats

type PriceChangeStats struct {
	Symbol             string `json:"symbol"`
	Pair               string `json:"pair"`
	PriceChange        string `json:"priceChange"`
	PriceChangePercent string `json:"priceChangePercent"`
	WeightedAvgPrice   string `json:"weightedAvgPrice"`
	LastPrice          string `json:"lastPrice"`
	LastQuantity       string `json:"lastQty"`
	OpenPrice          string `json:"openPrice"`
	HighPrice          string `json:"highPrice"`
	LowPrice           string `json:"lowPrice"`
	Volume             string `json:"volume"`
	BaseVolume         string `json:"baseVolume"`
	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 PriceFilter

type PriceFilter struct {
	MaxPrice string `json:"maxPrice"`
	MinPrice string `json:"minPrice"`
	TickSize string `json:"tickSize"`
}

PriceFilter define price filter of symbol

type RateLimit

type RateLimit struct {
	RateLimitType string `json:"rateLimitType"`
	Interval      string `json:"interval"`
	IntervalNum   int64  `json:"intervalNum"`
	Limit         int64  `json:"limit"`
}

RateLimit struct

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 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 SideEffectType

type SideEffectType string

SideEffectType define side effect type for orders

type SideType

type SideType string

SideType define side type of order

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 {
	OrderType             []OrderType              `json:"OrderType"`
	TimeInForce           []TimeInForceType        `json:"timeInForce"`
	Filters               []map[string]interface{} `json:"filters"`
	Symbol                string                   `json:"symbol"`
	Pair                  string                   `json:"pair"`
	ContractType          string                   `json:"contractType"`
	DeliveryDate          int64                    `json:"deliveryDate"`
	OnboardDate           int64                    `json:"onboardDate"`
	ContractStatus        string                   `json:"contractStatus"`
	ContractSize          int                      `json:"contractSize"`
	PricePrecision        int                      `json:"pricePrecision"`
	QuantityPrecision     int                      `json:"quantityPrecision"`
	MaintMarginPercent    string                   `json:"maintMarginPercent"`
	RequiredMarginPercent string                   `json:"requiredMarginPercent"`
	QuoteAsset            string                   `json:"quoteAsset"`
	BaseAsset             string                   `json:"baseAsset"`
	MarginAsset           string                   `json:"marginAsset"`
	BaseAssetPrecision    int                      `json:"baseAssetPrecision"`
	QuotePrecision        int                      `json:"quotePrecision"`
	EqualQtyPrecision     int                      `json:"equalQtyPrecision"`
	TriggerProtect        string                   `json:"triggerProtect"`
	UnderlyingType        string                   `json:"underlyingType"`
	UnderlyingSubType     []interface{}            `json:"underlyingSubType"`
}

Symbol market symbol

func (*Symbol) LotSizeFilter

func (s *Symbol) LotSizeFilter() *LotSizeFilter

LotSizeFilter return lot size filter of symbol

func (*Symbol) MarketLotSizeFilter

func (s *Symbol) MarketLotSizeFilter() *MarketLotSizeFilter

MarketLotSizeFilter return market lot size filter of symbol

func (*Symbol) MaxNumOrdersFilter

func (s *Symbol) MaxNumOrdersFilter() *MaxNumOrdersFilter

MaxNumOrdersFilter return max num orders filter of symbol

func (*Symbol) PercentPriceFilter

func (s *Symbol) PercentPriceFilter() *PercentPriceFilter

PercentPriceFilter return percent price filter of symbol

func (*Symbol) PriceFilter

func (s *Symbol) PriceFilter() *PriceFilter

PriceFilter return price filter of symbol

type SymbolFilterType

type SymbolFilterType string

SymbolFilterType define symbol filter type

type SymbolLeverage

type SymbolLeverage struct {
	Leverage    int    `json:"leverage"`
	MaxQuantity string `json:"maxQty"`
	Symbol      string `json:"symbol"`
}

SymbolLeverage define leverage info of symbol

type SymbolPrice

type SymbolPrice struct {
	Symbol string `json:"symbol"`
	Pair   string `json:"ps"`
	Price  string `json:"price"`
}

SymbolPrice define symbol, price and pair.

type SymbolStatusType

type SymbolStatusType string

SymbolStatusType define symbol status type

type SymbolType

type SymbolType string

SymbolType define symbol type

type TimeInForceType

type TimeInForceType string

TimeInForceType define time in force type of order

type UpdatePositionMarginService

type UpdatePositionMarginService struct {
	// contains filtered or unexported fields
}

UpdatePositionMarginService update isolated position margin

func (*UpdatePositionMarginService) Amount

Amount set position margin amount

func (*UpdatePositionMarginService) Do

Do send request

func (*UpdatePositionMarginService) PositionSide

Side set side

func (*UpdatePositionMarginService) Symbol

Symbol set symbol

func (*UpdatePositionMarginService) Type

Type set action type: 1: Add postion margin,2: Reduce postion margin

type UserDataEventReasonType

type UserDataEventReasonType string

UserDataEventReasonType define reason type for user data event

type UserDataEventType

type UserDataEventType string

UserDataEventType define user data event type

type WorkingType

type WorkingType string

WorkingType define working type

type WsAccountConfigUpdate

type WsAccountConfigUpdate struct {
	Symbol   string `json:"s"`
	Leverage int64  `json:"l"`
}

WsAccountConfigUpdate define account config update

type WsAccountUpdate

type WsAccountUpdate struct {
	Reason    UserDataEventReasonType `json:"m"`
	Balances  []WsBalance             `json:"B"`
	Positions []WsPosition            `json:"P"`
}

WsAccountUpdate define account update

type WsAggTradeEvent

type WsAggTradeEvent struct {
	Event            string `json:"e"`
	Time             int64  `json:"E"`
	AggregateTradeID int64  `json:"a"`
	Symbol           string `json:"s"`
	Price            string `json:"p"`
	Quantity         string `json:"q"`
	FirstTradeID     int64  `json:"f"`
	LastTradeID      int64  `json:"l"`
	TradeTime        int64  `json:"T"`
	Maker            bool   `json:"m"`
}

WsAggTradeEvent define websocket aggTrde event.

type WsAggTradeHandler

type WsAggTradeHandler func(event *WsAggTradeEvent)

WsAggTradeHandler handle websocket that push trade information that is aggregated for a single taker order.

type WsAllMarketTickerEvent

type WsAllMarketTickerEvent []*WsMarketTickerEvent

WsAllMarketTickerEvent define an array of websocket mini ticker events.

type WsAllMarketTickerHandler

type WsAllMarketTickerHandler func(event WsAllMarketTickerEvent)

WsAllMarketTickerHandler handle websocket that pushes price and funding rate for all markets.

type WsAllMiniMarketTickerEvent

type WsAllMiniMarketTickerEvent []*WsMiniMarketTickerEvent

WsAllMiniMarketTickerEvent define an array of websocket mini market ticker events.

type WsAllMiniMarketTickerHandler

type WsAllMiniMarketTickerHandler func(event WsAllMiniMarketTickerEvent)

WsAllMiniMarketTickerHandler handle websocket that pushes price and funding rate for all markets.

type WsBalance

type WsBalance struct {
	Asset              string `json:"a"`
	Balance            string `json:"wb"`
	CrossWalletBalance string `json:"cw"`
	BalanceChange      string `json:"bc"`
}

WsBalance define balance

type WsBookTickerEvent

type WsBookTickerEvent struct {
	Event           string `json:"e"`
	UpdateID        int64  `json:"u"`
	Symbol          string `json:"s"`
	Pair            string `json:"ps"`
	BestBidPrice    string `json:"b"`
	BestBidQty      string `json:"B"`
	BestAskPrice    string `json:"a"`
	BestAskQty      string `json:"A"`
	TransactionTime int64  `json:"T"`
	Time            int64  `json:"E"`
}

WsBookTickerEvent define websocket best book ticker event.

type WsBookTickerHandler

type WsBookTickerHandler func(event *WsBookTickerEvent)

WsBookTickerHandler handle websocket that pushes updates to the best bid or ask price or quantity in real-time for a specified symbol.

type WsConfig

type WsConfig struct {
	Endpoint string
}

WsConfig webservice configuration

type WsContinuousKline

type WsContinuousKline struct {
	StartTime            int64  `json:"t"`
	EndTime              int64  `json:"T"`
	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"`
}

WsContinuousKline define websocket continuous kline

type WsContinuousKlineEvent

type WsContinuousKlineEvent struct {
	Event        string            `json:"e"`
	Time         int64             `json:"E"`
	Pair         string            `json:"ps"`
	ContractType string            `json:"ct"`
	Kline        WsContinuousKline `json:"k"`
}

WsContinuousKlineEvent define websocket continuous kline event

type WsContinuousKlineHandler

type WsContinuousKlineHandler func(event *WsContinuousKlineEvent)

WsContinuousKlineHandler handle websocket continuous kline event

type WsDepthEvent

type WsDepthEvent struct {
	Event            string `json:"e"`
	Time             int64  `json:"E"`
	TransactionTime  int64  `json:"T"`
	Symbol           string `json:"s"`
	Pair             string `json:"ps"`
	FirstUpdateID    int64  `json:"U"`
	LastUpdateID     int64  `json:"u"`
	PrevLastUpdateID int64  `json:"pu"`
	Bids             []Bid  `json:"b"`
	Asks             []Ask  `json:"a"`
}

WsDepthEvent define websocket depth book event

type WsDepthHandler

type WsDepthHandler func(event *WsDepthEvent)

WsDepthHandler handle websocket depth event

type WsHandler

type WsHandler func(message []byte)

WsHandler handle raw websocket message

type WsIndexPriceEvent

type WsIndexPriceEvent struct {
	Event      string `json:"e"`
	Time       int64  `json:"E"`
	Pair       string `json:"i"`
	IndexPrice string `json:"p"`
}

WsIndexPriceEvent define websocket indexPriceUpdate event.

type WsIndexPriceHandler

type WsIndexPriceHandler func(event *WsIndexPriceEvent)

WsIndexPriceHandler handle websocket that push index price for a pair.

type WsIndexPriceKline

type WsIndexPriceKline struct {
	StartTime   int64  `json:"t"`
	EndTime     int64  `json:"T"`
	Interval    string `json:"i"`
	LastTradeId int64  `json:"L"` // LastTradeId Ignore
	Open        string `json:"o"`
	Close       string `json:"c"`
	High        string `json:"h"`
	Low         string `json:"l"`
	TradeNum    int64  `json:"n"`
	IsFinal     bool   `json:"x"`
}

WsIndexPriceKline define websocket index price kline

type WsIndexPriceKlineEvent

type WsIndexPriceKlineEvent struct {
	Event string            `json:"e"`
	Time  int64             `json:"E"`
	Pair  string            `json:"ps"`
	Kline WsIndexPriceKline `json:"k"`
}

WsIndexPriceKlineEvent define websocket index price kline event

type WsIndexPriceKlineHandler

type WsIndexPriceKlineHandler func(event *WsIndexPriceKlineEvent)

WsIndexPriceKlineHandler handle websocket index kline 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 WsLiquidationOrder

type WsLiquidationOrder struct {
	Symbol               string          `json:"s"`
	Pair                 string          `json:"ps"`
	Side                 SideType        `json:"S"`
	OrderType            OrderType       `json:"o"`
	TimeInForce          TimeInForceType `json:"f"`
	OrigQuantity         string          `json:"q"`
	Price                string          `json:"p"`
	AvgPrice             string          `json:"ap"`
	OrderStatus          OrderStatusType `json:"X"`
	LastFilledQty        string          `json:"l"`
	AccumulatedFilledQty string          `json:"z"`
	TradeTime            int64           `json:"T"`
}

WsLiquidationOrder define websocket liquidation order.

type WsLiquidationOrderEvent

type WsLiquidationOrderEvent struct {
	Event            string             `json:"e"`
	Time             int64              `json:"E"`
	LiquidationOrder WsLiquidationOrder `json:"o"`
}

WsLiquidationOrderEvent define websocket liquidation order event.

type WsLiquidationOrderHandler

type WsLiquidationOrderHandler func(event *WsLiquidationOrderEvent)

WsLiquidationOrderHandler handle websocket that pushes force liquidation order information for specific symbol.

type WsMarkPriceEvent

type WsMarkPriceEvent struct {
	Event                string `json:"e"`
	Time                 int64  `json:"E"`
	Symbol               string `json:"s"`
	MarkPrice            string `json:"p"`
	EstimatedSettlePrice string `json:"P"`
	FundingRate          string `json:"r"`
	NextFundingTime      int64  `json:"T"`
}

WsMarkPriceEvent define websocket markPriceUpdate event.

type WsMarkPriceHandler

type WsMarkPriceHandler func(event *WsMarkPriceEvent)

WsMarkPriceHandler handle websocket that pushes price and funding rate for a single symbol.

type WsMarkPriceKline

type WsMarkPriceKline struct {
	StartTime   int64  `json:"t"`
	EndTime     int64  `json:"T"`
	Symbol      string `json:"s"`
	Interval    string `json:"i"`
	LastTradeID int64  `json:"L"` // LastTradeID Ignore
	Open        string `json:"o"`
	Close       string `json:"c"`
	High        string `json:"h"`
	Low         string `json:"l"`
	TradeNum    int64  `json:"n"`
	IsFinal     bool   `json:"x"`
}

WsMarkPriceKline define websocket market price kline

type WsMarkPriceKlineEvent

type WsMarkPriceKlineEvent struct {
	Event string           `json:"e"`
	Time  int64            `json:"E"`
	Pair  string           `json:"ps"`
	Kline WsMarkPriceKline `json:"k"`
}

WsMarkPriceKlineEvent define websocket market price kline event

type WsMarkPriceKlineHandler

type WsMarkPriceKlineHandler func(event *WsMarkPriceKlineEvent)

WsMarkPriceKlineHandler handle websocket market price kline event

type WsMarketTickerEvent

type WsMarketTickerEvent struct {
	Event              string `json:"e"`
	Time               int64  `json:"E"`
	Symbol             string `json:"s"`
	Pair               string `json:"ps"`
	PriceChange        string `json:"p"`
	PriceChangePercent string `json:"P"`
	WeightedAvgPrice   string `json:"w"`
	ClosePrice         string `json:"c"`
	CloseQty           string `json:"Q"`
	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"`
	TradeCount         int64  `json:"n"`
}

WsMarketTickerEvent define websocket market ticker event.

type WsMarketTickerHandler

type WsMarketTickerHandler func(event *WsMarketTickerEvent)

WsMarketTickerHandler handle websocket that pushes 24hr rolling window mini-ticker statistics for a single symbol.

type WsMiniMarketTickerEvent

type WsMiniMarketTickerEvent struct {
	Event       string `json:"e"`
	Time        int64  `json:"E"`
	Symbol      string `json:"s"`
	Pair        string `json:"ps"`
	ClosePrice  string `json:"c"`
	OpenPrice   string `json:"o"`
	HighPrice   string `json:"h"`
	LowPrice    string `json:"l"`
	Volume      string `json:"v"`
	QuoteVolume string `json:"q"`
}

WsMiniMarketTickerEvent define websocket mini market ticker event.

type WsMiniMarketTickerHandler

type WsMiniMarketTickerHandler func(event *WsMiniMarketTickerEvent)

WsMiniMarketTickerHandler handle websocket that pushes 24hr rolling window mini-ticker statistics for a single symbol.

type WsOrderTradeUpdate

type WsOrderTradeUpdate struct {
	Symbol               string             `json:"s"`
	ClientOrderID        string             `json:"c"`
	Side                 SideType           `json:"S"`
	Type                 OrderType          `json:"o"`
	TimeInForce          TimeInForceType    `json:"f"`
	OriginalQty          string             `json:"q"`
	OriginalPrice        string             `json:"p"`
	AveragePrice         string             `json:"ap"`
	StopPrice            string             `json:"sp"`
	ExecutionType        OrderExecutionType `json:"x"`
	Status               OrderStatusType    `json:"X"`
	ID                   int64              `json:"i"`
	LastFilledQty        string             `json:"l"`
	AccumulatedFilledQty string             `json:"z"`
	LastFilledPrice      string             `json:"L"`
	MarginAsset          string             `json:"ma"`
	CommissionAsset      string             `json:"N"`
	Commission           string             `json:"n"`
	TradeTime            int64              `json:"T"`
	TradeID              int64              `json:"t"`
	RealizedPnL          string             `json:"rp"`
	BidsNotional         string             `json:"b"`
	AsksNotional         string             `json:"a"`
	IsMaker              bool               `json:"m"`
	IsReduceOnly         bool               `json:"R"`
	WorkingType          WorkingType        `json:"wt"`
	OriginalType         OrderType          `json:"ot"`
	PositionSide         PositionSideType   `json:"ps"`
	IsClosingPosition    bool               `json:"cp"`
	ActivationPrice      string             `json:"AP"`
	CallbackRate         string             `json:"cr"`
	IsProtected          bool               `json:"pP"`
}

WsOrderTradeUpdate define order trade update

type WsPairMarkPriceEvent

type WsPairMarkPriceEvent []*WsMarkPriceEvent

WsPairMarkPriceEvent defines an array of websocket markPriceUpdate events.

type WsPairMarkPriceHandler

type WsPairMarkPriceHandler func(event WsPairMarkPriceEvent)

WsPairMarkPriceHandler handle websocket that pushes price and funding rate for all symbol.

type WsPosition

type WsPosition struct {
	Symbol                    string           `json:"s"`
	Side                      PositionSideType `json:"ps"`
	Amount                    string           `json:"pa"`
	MarginType                MarginType       `json:"mt"`
	IsolatedWallet            string           `json:"iw"`
	EntryPrice                string           `json:"ep"`
	MarkPrice                 string           `json:"mp"`
	UnrealizedPnL             string           `json:"up"`
	AccumulatedRealized       string           `json:"cr"`
	MaintenanceMarginRequired string           `json:"mm"`
}

WsPosition define position

type WsUserDataEvent

type WsUserDataEvent struct {
	Event               UserDataEventType  `json:"e"`
	Time                int64              `json:"E"`
	Alias               string             `json:"i"`
	CrossWalletBalance  string             `json:"cw"`
	MarginCallPositions []WsPosition       `json:"p"`
	TransactionTime     int64              `json:"T"`
	AccountUpdate       WsAccountUpdate    `json:"a"`
	OrderTradeUpdate    WsOrderTradeUpdate `json:"o"`
}

WsUserDataEvent define user data event

type WsUserDataHandler

type WsUserDataHandler func(event *WsUserDataEvent)

WsUserDataHandler handle WsUserDataEvent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL