portfolio

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 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"
	OrderTypeLiquidation OrderType = "LIQUIDATION"

	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"

	SelfTradePreventionModeNONE SelfTradePreventionMode = "NONE"
	SelfTradePreventionModeET   SelfTradePreventionMode = "EXPIRE_TAKER"
	SelfTradePreventionModeEM   SelfTradePreventionMode = "EXPIRE_MAKER"
	SelfTradePreventionModeEB   SelfTradePreventionMode = "EXPIRE_BOTH"

	OrderExecutionTypeNew        OrderExecutionType = "NEW"
	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"
	OrderStatusTypeExpired         OrderStatusType = "EXPIRED"

	UmBusinessUnit BusinessUnit = "UM"
	CmBusinessUnit BusinessUnit = "CM"

	UserDataEventTypeListenKeyExpired UserDataEventType = "listenKeyExpired"
	UserDataEventTypeAccountUpdate    UserDataEventType = "ACCOUNT_UPDATE"
	UserDataEventTypeOrderTradeUpdate UserDataEventType = "ORDER_TRADE_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 UmWsUserDataServe

func UmWsUserDataServe(listenKey string, handler WsUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

func UmWsUserDataServeWithIP

func UmWsUserDataServeWithIP(ip string, listenKey string, handler WsUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

Types

type BusinessUnit added in v0.1.6

type BusinessUnit string

BusinessUnit define business unit

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 NewClientWithIP

func NewClientWithIP(apiKey, secretKey, ip string) *Client

NewClientWithIP initialize an API client instance with API key, secret key and local IP.

func NewProxiedClient

func NewProxiedClient(apiKey, secretKey, proxyUrl string) *Client

NewProxiedClient passing a proxy url

func (*Client) NewCloseUserStreamService

func (c *Client) NewCloseUserStreamService() *CloseUserStreamService

NewCloseUserStreamService init closing user stream service

func (*Client) NewCmCommissionRateService

func (c *Client) NewCmCommissionRateService() *CmCommissionRateService

NewCmCommissionRateService init cm commission rate service

func (*Client) NewCmPositionSideDualService

func (c *Client) NewCmPositionSideDualService() *CmPositionSideDualService

NewCmPositionSideDualService init cm position side dual service

func (*Client) NewCmSetLeverageService

func (c *Client) NewCmSetLeverageService() *CmSetLeverageService

NewCmSetLeverageService init cm set leverage service

func (*Client) NewKeepaliveUserStreamService

func (c *Client) NewKeepaliveUserStreamService() *KeepaliveUserStreamService

NewKeepaliveUserStreamService init keep alive user stream service

func (*Client) NewStartUserStreamService

func (c *Client) NewStartUserStreamService() *StartUserStreamService

NewStartUserStreamService init starting user stream service

func (*Client) NewUmCancelAllOpenOrdersService

func (c *Client) NewUmCancelAllOpenOrdersService() *UmCancelAllOpenOrdersService

NewUmCancelAllOpenOrdersService init cancel all um open orders service

func (*Client) NewUmCancelOrderService

func (c *Client) NewUmCancelOrderService() *UmCancelOrderService

NewUmCancelAllOpenOrdersService init cancel all um open orders service

func (*Client) NewUmCommissionRateService

func (c *Client) NewUmCommissionRateService() *UmCommissionRateService

NewUmCommissionRateService init um commission rate service

func (*Client) NewUmCreateOrderService

func (c *Client) NewUmCreateOrderService() *UmCreateOrderService

NewUmCreateOrderService init cancel all um open orders service

func (*Client) NewUmGetAccountService

func (c *Client) NewUmGetAccountService() *UmGetAccountService

NewUmGetAccountService init getting account service

func (*Client) NewUmListOpenOrdersService

func (c *Client) NewUmListOpenOrdersService() *UmListOpenOrdersService

NewListOpenOrdersService init list open orders service

func (*Client) NewUmPositionSideDualService

func (c *Client) NewUmPositionSideDualService() *UmPositionSideDualService

NewUmPositionSideDualService init um position side dual service

func (*Client) NewUmSetLeverageService

func (c *Client) NewUmSetLeverageService() *UmSetLeverageService

NewUmSetLeverageService init um set leverage service

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 CmCommissionRateResponse

type CmCommissionRateResponse struct {
	Symbol              string `json:"symbol"`
	MakerCommissionRate string `json:"makerCommissionRate"`
	TakerCommissionRate string `json:"takerCommissionRate"`
}

type CmCommissionRateService

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

func (*CmCommissionRateService) Do

Do send request

func (*CmCommissionRateService) Symbol

Symbol set symbol

type CmPositionSideDualResponse

type CmPositionSideDualResponse struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type CmPositionSideDualService

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

func (*CmPositionSideDualService) Do

Do send request

func (*CmPositionSideDualService) DualSidePosition

func (s *CmPositionSideDualService) DualSidePosition(dualSidePosition string) *CmPositionSideDualService

DualSidePosition set positionSide

type CmSetLeverageResponse

type CmSetLeverageResponse struct {
	Symbol   string `json:"symbol"`
	Leverage int    `json:"leverage"`
	MaxQty   string `json:"maxQty"`
}

type CmSetLeverageService

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

func (*CmSetLeverageService) Do

Do send request

func (*CmSetLeverageService) Leverage

func (s *CmSetLeverageService) Leverage(leverage int64) *CmSetLeverageService

Leverage set leverage

func (*CmSetLeverageService) Symbol

Symbol set symbol

type CreateOrderResponse

type CreateOrderResponse struct {
	ClientOrderID           string                  `json:"clientOrderId"`           //
	CumQty                  string                  `json:"cumQty"`                  //
	CumQuote                string                  `json:"cumQuote"`                //
	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"`                  //
	Symbol                  string                  `json:"symbol"`                  //
	TimeInForce             TimeInForceType         `json:"timeInForce"`             //
	Type                    OrderType               `json:"type"`                    //
	SelfTradePreventionMode SelfTradePreventionMode `json:"selfTradePreventionMode"` // self trading preventation mode
	GoodTillDate            int64                   `json:"goodTillDate"`            // order pre-set auto cancel time for TIF GTD order
	UpdateTime              int64                   `json:"updateTime"`              // update time
}

CreateOrderResponse define create order response

type ErrHandler

type ErrHandler func(err error)

ErrHandler handles errors

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 NewOrderRespType

type NewOrderRespType string

NewOrderRespType define response JSON verbosity

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 PositionSideType

type PositionSideType string

PositionSideType define position side type of order

type RequestOption

type RequestOption func(*request)

RequestOption define option type for request

func WithExtraForm

func WithExtraForm(m map[string]any) RequestOption

WithExtraForm add extra form data of the 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 SelfTradePreventionMode

type SelfTradePreventionMode string

SelfTradePreventionMode define response JSON verbosity

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 TimeInForceType

type TimeInForceType string

TimeInForceType define time in force type of order

type UmAccount

type UmAccount struct {
	Assets    []*UmAccountAsset    `json:"assets"`
	Positions []*UmAccountPosition `json:"positions"`
	// contains filtered or unexported fields
}

UmAccount define account info

type UmAccountAsset

type UmAccountAsset struct {
	Asset                  string `json:"asset"`
	CrossWalletBalance     string `json:"crossWalletBalance"`
	CrossUnPnl             string `json:"crossUnPnl"`
	MaintMargin            string `json:"maintMargin"`
	InitialMargin          string `json:"initialMargin"`
	PositionInitialMargin  string `json:"positionInitialMargin"`
	OpenOrderInitialMargin string `json:"openOrderInitialMargin"`
	UpdateTime             int64  `json:"updateTime"`
}

UmAccountAsset define account asset

type UmAccountPosition

type UmAccountPosition struct {
	Symbol                 string           `json:"symbol"`
	InitialMargin          string           `json:"initialMargin"`
	MaintMargin            string           `json:"maintMargin"`
	UnrealizedProfit       string           `json:"unrealizedProfit"`
	PositionInitialMargin  string           `json:"positionInitialMargin"`
	OpenOrderInitialMargin string           `json:"openOrderInitialMargin"`
	Leverage               string           `json:"leverage"`
	EntryPrice             string           `json:"entryPrice"`
	MaxNotional            string           `json:"maxNotional"`
	BidNotional            string           `json:"bidNotional"`
	AskNotional            string           `json:"askNotional"`
	PositionSide           PositionSideType `json:"positionSide"`
	PositionAmt            string           `json:"positionAmt"`
	UpdateTime             int64            `json:"updateTime"`
	BreakEvenPrice         string           `json:"breakEvenPrice"`
}

UmAccountPosition define account position

type UmBalance

type UmBalance struct {
	AccountAlias       string `json:"accountAlias"`
	Asset              string `json:"asset"`
	Balance            string `json:"balance"`
	CrossWalletBalance string `json:"crossWalletBalance"`
	CrossUnPnl         string `json:"crossUnPnl"`
	AvailableBalance   string `json:"availableBalance"`
	MaxWithdrawAmount  string `json:"maxWithdrawAmount"`
}

UmBalance define user balance of your account

type UmCancelAllOpenOrdersService

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

UmCancelAllOpenOrdersService cancel all open orders

func (*UmCancelAllOpenOrdersService) Do

Do send request

func (*UmCancelAllOpenOrdersService) Symbol

Symbol set symbol

type UmCancelOrderResponse

type UmCancelOrderResponse struct {
	AvgPrice                string                  `json:"avgPrice"`
	ClientOrderID           string                  `json:"clientOrderId"`
	CumQuantity             string                  `json:"cumQty"`
	CumQuote                string                  `json:"cumQuote"`
	ExecutedQuantity        string                  `json:"executedQty"`
	OrderID                 int64                   `json:"orderId"`
	OrigQuantity            string                  `json:"origQty"`
	Price                   string                  `json:"price"`
	ReduceOnly              bool                    `json:"reduceOnly"`
	Side                    SideType                `json:"side"`
	PositionSide            PositionSideType        `json:"positionSide"`
	Status                  OrderStatusType         `json:"status"`
	Symbol                  string                  `json:"symbol"`
	TimeInForce             TimeInForceType         `json:"timeInForce"`
	Type                    OrderType               `json:"type"`
	UpdateTime              int64                   `json:"updateTime"`
	SelfTradePreventionMode SelfTradePreventionMode `json:"selfTradePreventionMode"`
	GoodTillDate            int64                   `json:"goodTillDate"`
}

UmCancelOrderResponse define response of canceling order

type UmCancelOrderService

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

UmCancelOrderService cancel all open orders

func (*UmCancelOrderService) ClientOrderID

func (s *UmCancelOrderService) ClientOrderID(clientOrderID string) *UmCancelOrderService

ClientOrderID set clientOrderID

func (*UmCancelOrderService) Do

func (*UmCancelOrderService) OrderID

func (s *UmCancelOrderService) OrderID(orderID int64) *UmCancelOrderService

OrderID set orderID

func (*UmCancelOrderService) Symbol

Symbol set symbol

type UmCommissionRateService

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

func (*UmCommissionRateService) Do

Do send request

func (*UmCommissionRateService) Symbol

Symbol set symbol

type UmCreateOrderService

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

UmCreateOrderService create order

func (*UmCreateOrderService) Do

Do send request

func (*UmCreateOrderService) NewClientOrderID

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

NewClientOrderID set newClientOrderID

func (*UmCreateOrderService) NewOrderResponseType

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

NewOrderResponseType set newOrderResponseType

func (*UmCreateOrderService) PositionSide

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

PositionSide set side

func (*UmCreateOrderService) Price

Price set price

func (*UmCreateOrderService) Quantity

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

Quantity set quantity

func (*UmCreateOrderService) ReduceOnly

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

ReduceOnly set reduceOnly

func (*UmCreateOrderService) SelfTradePrevention

func (s *UmCreateOrderService) SelfTradePrevention(selfTradePreventionMode SelfTradePreventionMode) *UmCreateOrderService

SelfTradePrevention set selfTradePreventionMode

func (*UmCreateOrderService) Side

Side set side

func (*UmCreateOrderService) Symbol

Symbol set symbol

func (*UmCreateOrderService) TimeInForce

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

TimeInForce set timeInForce

func (*UmCreateOrderService) Type

Type set type

type UmGetAccountService

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

UmGetAccountService get account info

func (*UmGetAccountService) Do

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

Do send request

type UmGetBalanceService

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

UmGetBalanceService get account balance

func (*UmGetBalanceService) Do

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

Do send request

type UmListOpenOrdersService

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

UmListOpenOrdersService list opened orders

func (*UmListOpenOrdersService) Do

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

Do send request

func (*UmListOpenOrdersService) Symbol

Symbol set symbol

type UmOrder

type UmOrder struct {
	AvgPrice                string                  `json:"avgPrice"`
	ClientOrderID           string                  `json:"clientOrderId"`
	CumQuote                string                  `json:"cumQuote"`
	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"`
	Symbol                  string                  `json:"symbol"`
	Time                    int64                   `json:"time"`
	TimeInForce             TimeInForceType         `json:"timeInForce"`
	Type                    OrderType               `json:"type"`
	UpdateTime              int64                   `json:"updateTime"`
	SelfTradePreventionMode SelfTradePreventionMode `json:"selfTradePreventionMode"`
	GoodTillDate            int64                   `json:"goodTillDate"`
}

UmOrder define order info

type UmPositionSideDualResponse

type UmPositionSideDualResponse struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type UmPositionSideDualService

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

func (*UmPositionSideDualService) Do

Do send request

func (*UmPositionSideDualService) DualSidePosition

func (s *UmPositionSideDualService) DualSidePosition(dualSidePosition string) *UmPositionSideDualService

DualSidePosition set positionSide

type UmSetLeverageResponse

type UmSetLeverageResponse struct {
	Symbol           string `json:"symbol"`
	Leverage         int    `json:"leverage"`
	MaxNotionalValue string `json:"maxNotionalValue"`
}

type UmSetLeverageService

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

func (*UmSetLeverageService) Do

Do send request

func (*UmSetLeverageService) Leverage

func (s *UmSetLeverageService) Leverage(leverage int64) *UmSetLeverageService

Leverage set leverage

func (*UmSetLeverageService) Symbol

Symbol set symbol

type UnCommissionRateResponse

type UnCommissionRateResponse struct {
	Symbol              string `json:"symbol"`
	MakerCommissionRate string `json:"makerCommissionRate"`
	TakerCommissionRate string `json:"takerCommissionRate"`
}

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 WsAccountUpdate

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

WsAccountUpdate define account update

type WsBalance

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

WsBalance define balance

type WsConfig

type WsConfig struct {
	Endpoint string
	IP       string
}

WsConfig webservice configuration

func (*WsConfig) WithIP

func (cfg *WsConfig) WithIP(ip string)

type WsHandler

type WsHandler func(message []byte)

WsHandler handle raw websocket message

type WsOrderTradeUpdate

type WsOrderTradeUpdate struct {
	Symbol               string             `json:"s"`   // Symbol
	ClientOrderID        string             `json:"c"`   // Client order ID
	Side                 SideType           `json:"S"`   // Side
	Type                 OrderType          `json:"o"`   // Order type
	TimeInForce          TimeInForceType    `json:"f"`   // Time in force
	OriginalQty          string             `json:"q"`   // Original quantity
	OriginalPrice        string             `json:"p"`   // Original price
	AveragePrice         string             `json:"ap"`  // Average price
	StopPrice            string             `json:"sp"`  // Stop price. Please ignore with TRAILING_STOP_MARKET order
	ExecutionType        OrderExecutionType `json:"x"`   // Execution type
	Status               OrderStatusType    `json:"X"`   // Order status
	ID                   int64              `json:"i"`   // Order ID
	LastFilledQty        string             `json:"l"`   // Order Last Filled Quantity
	AccumulatedFilledQty string             `json:"z"`   // Order Filled Accumulated Quantity
	LastFilledPrice      string             `json:"L"`   // Last Filled Price
	CommissionAsset      string             `json:"N"`   // Commission Asset, will not push if no commission
	Commission           string             `json:"n"`   // Commission, will not push if no commission
	TradeTime            int64              `json:"T"`   // Order Trade Time
	TradeID              int64              `json:"t"`   // Trade ID
	BidsNotional         string             `json:"b"`   // Bids Notional
	AsksNotional         string             `json:"a"`   // Asks Notional
	IsMaker              bool               `json:"m"`   // Is this trade the maker side?
	IsReduceOnly         bool               `json:"R"`   // Is this reduce only
	PositionSide         PositionSideType   `json:"ps"`  // Position Side
	RealizedPnL          string             `json:"rp"`  // Realized Profit of the trade
	StrategyType         string             `json:"st"`  // Strategy type, only pushed with conditional order triggered
	StrategyID           int64              `json:"si"`  // StrategyId,only pushed with conditional order triggered
	STP                  string             `json:"V"`   // STP mode
	GTD                  int64              `json:"gtd"` // TIF GTD order auto cancel time
}

WsOrderTradeUpdate define order trade update

type WsPosition

type WsPosition struct {
	Symbol              string           `json:"s"`
	Amount              string           `json:"pa"`
	EntryPrice          string           `json:"ep"`
	AccumulatedRealized string           `json:"cr"`
	UnrealizedPnL       string           `json:"up"`
	Side                PositionSideType `json:"ps"`
	BreakEvenPrice      float64          `json:"bep"`
}

WsPosition define position

type WsUserDataEvent

type WsUserDataEvent struct {
	Event            UserDataEventType  `json:"e"`
	BusinessUnit     BusinessUnit       `json:"fs"`
	Time             int64              `json:"E"`
	TransactionTime  int64              `json:"T"`
	AccountAlias     string             `json:"i"`
	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