Documentation ¶
Index ¶
- Constants
- Variables
- func UmWsPackedUserDataServe(listenKey string, handler WsPackedUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func UmWsPackedUserDataServeWithIP(ip string, listenKey string, handler WsPackedUserDataHandler, ...) (doneC, stopC chan struct{}, err error)
- func WsUserDataServe(listenKey string, handler WsUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- func WsUserDataServeWithIP(ip string, listenKey string, handler WsUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
- type Balance
- type BusinessUnit
- type Client
- func (c *Client) NewCloseUserStreamService() *CloseUserStreamService
- func (c *Client) NewCmCancelAllOpenOrdersService() *CmCancelAllOpenOrdersService
- func (c *Client) NewCmCancelOrderService() *CmCancelOrderService
- func (c *Client) NewCmChangePositionModeService() *CmChangePositionModeService
- func (c *Client) NewCmCommissionRateService() *CmCommissionRateService
- func (c *Client) NewCmCreateOrderService() *CmCreateOrderService
- func (c *Client) NewCmGetAccountService() *CmGetAccountService
- func (c *Client) NewCmGetPositionModeService() *CmGetPositionModeService
- func (c *Client) NewCmListOpenOrdersService() *CmListOpenOrdersService
- func (c *Client) NewCmSetLeverageService() *CmSetLeverageService
- func (c *Client) NewGetAllBalanceService() *GetAllBalanceService
- func (c *Client) NewGetMaxBorrowableService() *GetMaxBorrowableService
- func (c *Client) NewKeepaliveUserStreamService() *KeepaliveUserStreamService
- func (c *Client) NewStartUserStreamService() *StartUserStreamService
- func (c *Client) NewUmCancelAllOpenOrdersService() *UmCancelAllOpenOrdersService
- func (c *Client) NewUmCancelOrderService() *UmCancelOrderService
- func (c *Client) NewUmChangePositionModeService() *UmChangePositionModeService
- func (c *Client) NewUmCommissionRateService() *UmCommissionRateService
- func (c *Client) NewUmCreateOrderService() *UmCreateOrderService
- func (c *Client) NewUmGetAccountService() *UmGetAccountService
- func (c *Client) NewUmGetPositionModeService() *UmGetPositionModeService
- func (c *Client) NewUmListOpenOrdersService() *UmListOpenOrdersService
- func (c *Client) NewUmSetLeverageService() *UmSetLeverageService
- func (c *Client) SetApiEndpoint(url string) *Client
- type CloseUserStreamService
- type CmAccount
- type CmAccountAsset
- type CmAccountPosition
- type CmCancelAllOpenOrdersService
- type CmCancelOrderResponse
- type CmCancelOrderService
- func (s *CmCancelOrderService) ClientOrderID(clientOrderID string) *CmCancelOrderService
- func (s *CmCancelOrderService) Do(ctx context.Context, opts ...RequestOption) (res *CmCancelOrderResponse, err error)
- func (s *CmCancelOrderService) OrderID(orderID int64) *CmCancelOrderService
- func (s *CmCancelOrderService) Symbol(symbol string) *CmCancelOrderService
- type CmChangePositionMode
- type CmChangePositionModeService
- type CmCommissionRateResponse
- type CmCommissionRateService
- type CmCreateOrderResponse
- type CmCreateOrderService
- func (s *CmCreateOrderService) Do(ctx context.Context, opts ...RequestOption) (res *CmCreateOrderResponse, err error)
- func (s *CmCreateOrderService) NewClientOrderID(newClientOrderID string) *CmCreateOrderService
- func (s *CmCreateOrderService) NewOrderResponseType(newOrderResponseType NewOrderRespType) *CmCreateOrderService
- func (s *CmCreateOrderService) PositionSide(positionSide PositionSideType) *CmCreateOrderService
- func (s *CmCreateOrderService) Price(price string) *CmCreateOrderService
- func (s *CmCreateOrderService) Quantity(quantity string) *CmCreateOrderService
- func (s *CmCreateOrderService) ReduceOnly(reduceOnly bool) *CmCreateOrderService
- func (s *CmCreateOrderService) Side(side SideType) *CmCreateOrderService
- func (s *CmCreateOrderService) Symbol(symbol string) *CmCreateOrderService
- func (s *CmCreateOrderService) TimeInForce(timeInForce TimeInForceType) *CmCreateOrderService
- func (s *CmCreateOrderService) Type(orderType OrderType) *CmCreateOrderService
- type CmGetAccountService
- type CmGetPositionMode
- type CmGetPositionModeService
- type CmListOpenOrdersService
- type CmOrder
- type CmSetLeverageResponse
- type CmSetLeverageService
- type ErrHandler
- type GetAllBalanceService
- type GetMaxBorrowableService
- type KeepaliveUserStreamService
- type MaxBorrowable
- type NewOrderRespType
- type OrderExecutionType
- type OrderStatusType
- type OrderType
- type PositionSideType
- type RequestOption
- type SelfTradePreventionMode
- type SideType
- type StartUserStreamService
- type SymbolType
- type TimeInForceType
- type UmAccount
- type UmAccountAsset
- type UmAccountPosition
- type UmCancelAllOpenOrdersService
- type UmCancelOrderResponse
- type UmCancelOrderService
- func (s *UmCancelOrderService) ClientOrderID(clientOrderID string) *UmCancelOrderService
- func (s *UmCancelOrderService) Do(ctx context.Context, opts ...RequestOption) (res *UmCancelOrderResponse, err error)
- func (s *UmCancelOrderService) OrderID(orderID int64) *UmCancelOrderService
- func (s *UmCancelOrderService) Symbol(symbol string) *UmCancelOrderService
- type UmChangePositionMode
- type UmChangePositionModeService
- type UmCommissionRateService
- type UmCreateOrderResponse
- type UmCreateOrderService
- func (s *UmCreateOrderService) Do(ctx context.Context, opts ...RequestOption) (res *UmCreateOrderResponse, err error)
- func (s *UmCreateOrderService) NewClientOrderID(newClientOrderID string) *UmCreateOrderService
- func (s *UmCreateOrderService) NewOrderResponseType(newOrderResponseType NewOrderRespType) *UmCreateOrderService
- func (s *UmCreateOrderService) PositionSide(positionSide PositionSideType) *UmCreateOrderService
- func (s *UmCreateOrderService) Price(price string) *UmCreateOrderService
- func (s *UmCreateOrderService) Quantity(quantity string) *UmCreateOrderService
- func (s *UmCreateOrderService) ReduceOnly(reduceOnly bool) *UmCreateOrderService
- func (s *UmCreateOrderService) SelfTradePrevention(selfTradePreventionMode SelfTradePreventionMode) *UmCreateOrderService
- func (s *UmCreateOrderService) Side(side SideType) *UmCreateOrderService
- func (s *UmCreateOrderService) Symbol(symbol string) *UmCreateOrderService
- func (s *UmCreateOrderService) TimeInForce(timeInForce TimeInForceType) *UmCreateOrderService
- func (s *UmCreateOrderService) Type(orderType OrderType) *UmCreateOrderService
- type UmGetAccountService
- type UmGetPositionMode
- type UmGetPositionModeService
- type UmListOpenOrdersService
- type UmOrder
- type UmSetLeverageResponse
- type UmSetLeverageService
- type UnCommissionRateResponse
- type UserDataEventReasonType
- type UserDataEventType
- type WsAccountUpdate
- type WsBalance
- type WsConfig
- type WsHandler
- type WsOrderTradeUpdate
- type WsPackedUserDataEvent
- type WsPackedUserDataHandler
- type WsPosition
- type WsUserDataEvent
- type WsUserDataHandler
Constants ¶
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" SymbolTypeMargin SymbolType = "MARGIN" SymbolTypeFutures SymbolType = "FUTURES" )
Global enums
Variables ¶
var ( // WebsocketTimeout is an interval for sending ping/pong messages if WebsocketKeepalive is enabled WebsocketTimeout = time.Second * 60 // WebsocketKeepalive enables sending ping/pong messages to check the connection stability WebsocketKeepalive = false // UseTestnet switch all the WS streams from production to the testnet UseTestnet = false )
Functions ¶
func UmWsPackedUserDataServe ¶ added in v0.1.12
func UmWsPackedUserDataServe(listenKey string, handler WsPackedUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
func UmWsPackedUserDataServeWithIP ¶ added in v0.1.12
func UmWsPackedUserDataServeWithIP(ip string, listenKey string, handler WsPackedUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
func WsUserDataServe ¶ added in v0.1.19
func WsUserDataServe(listenKey string, handler WsUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
func WsUserDataServeWithIP ¶ added in v0.1.19
func WsUserDataServeWithIP(ip string, listenKey string, handler WsUserDataHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)
Types ¶
type Balance ¶ added in v0.1.35
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"` UpdateTime int64 `json:"updateTime"` NegativeBalance string `json:"negativeBalance"` }
type Client ¶
type Client struct { APIKey string SecretKey string BaseURL string UserAgent string HTTPClient *http.Client Debug bool Logger *log.Logger TimeOffset int64 // contains filtered or unexported fields }
Client define API client
func NewClient ¶
NewClient initialize an API client instance with API key and secret key. You should always call this function before using this SDK. Services will be created by the form client.NewXXXService().
func NewClientWithIP ¶
NewClientWithIP initialize an API client instance with API key, secret key and local IP.
func NewProxiedClient ¶
NewProxiedClient passing a proxy url
func (*Client) NewCloseUserStreamService ¶
func (c *Client) NewCloseUserStreamService() *CloseUserStreamService
NewCloseUserStreamService init closing user stream service
func (*Client) NewCmCancelAllOpenOrdersService ¶ added in v0.1.19
func (c *Client) NewCmCancelAllOpenOrdersService() *CmCancelAllOpenOrdersService
NewCmCancelAllOpenOrdersService init cancel all um open orders service
func (*Client) NewCmCancelOrderService ¶ added in v0.1.19
func (c *Client) NewCmCancelOrderService() *CmCancelOrderService
NewCmCancelOrderService init cancel all um open orders service
func (*Client) NewCmChangePositionModeService ¶ added in v0.1.35
func (c *Client) NewCmChangePositionModeService() *CmChangePositionModeService
NewCmChangePositionModeService init cm position side dual service
func (*Client) NewCmCommissionRateService ¶
func (c *Client) NewCmCommissionRateService() *CmCommissionRateService
NewCmCommissionRateService init cm commission rate service
func (*Client) NewCmCreateOrderService ¶ added in v0.1.19
func (c *Client) NewCmCreateOrderService() *CmCreateOrderService
NewCmCreateOrderService init cancel all um open orders service
func (*Client) NewCmGetAccountService ¶ added in v0.1.19
func (c *Client) NewCmGetAccountService() *CmGetAccountService
NewCmGetAccountService init getting account service
func (*Client) NewCmGetPositionModeService ¶ added in v0.1.35
func (c *Client) NewCmGetPositionModeService() *CmGetPositionModeService
NewCmGetPositionModeService init cm position side dual service
func (*Client) NewCmListOpenOrdersService ¶ added in v0.1.19
func (c *Client) NewCmListOpenOrdersService() *CmListOpenOrdersService
NewCmListOpenOrdersService init list open orders service
func (*Client) NewCmSetLeverageService ¶
func (c *Client) NewCmSetLeverageService() *CmSetLeverageService
NewCmSetLeverageService init cm set leverage service
func (*Client) NewGetAllBalanceService ¶ added in v0.1.35
func (c *Client) NewGetAllBalanceService() *GetAllBalanceService
NewGetAllBalanceService init get balances service
func (*Client) NewGetMaxBorrowableService ¶ added in v0.1.35
func (c *Client) NewGetMaxBorrowableService() *GetMaxBorrowableService
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) NewUmChangePositionModeService ¶ added in v0.1.35
func (c *Client) NewUmChangePositionModeService() *UmChangePositionModeService
NewUmChangePositionModeService init um position side dual service
func (*Client) NewUmCommissionRateService ¶
func (c *Client) NewUmCommissionRateService() *UmCommissionRateService
#### um 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) NewUmGetPositionModeService ¶ added in v0.1.35
func (c *Client) NewUmGetPositionModeService() *UmGetPositionModeService
NewUmGetPositionModeService init um position side dual service
func (*Client) NewUmListOpenOrdersService ¶
func (c *Client) NewUmListOpenOrdersService() *UmListOpenOrdersService
NewListOpenOrdersService init list open orders service
func (*Client) NewUmSetLeverageService ¶
func (c *Client) NewUmSetLeverageService() *UmSetLeverageService
NewUmSetLeverageService init um set leverage service
func (*Client) SetApiEndpoint ¶
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 CmAccount ¶ added in v0.1.18
type CmAccount struct { Assets []*UmAccountAsset `json:"assets"` Positions []*UmAccountPosition `json:"positions"` }
CmAccount define account info
type CmAccountAsset ¶ added in v0.1.18
type CmAccountAsset 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"` }
CmAccountAsset define account asset
type CmAccountPosition ¶ added in v0.1.18
type CmAccountPosition 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"` PositionSide PositionSideType `json:"positionSide"` EntryPrice string `json:"entryPrice"` MaxQuantity string `json:"maxQty"` UpdateTime int64 `json:"updateTime"` BreakEvenPrice string `json:"breakEvenPrice"` }
CmAccountPosition define account position
type CmCancelAllOpenOrdersService ¶ added in v0.1.18
type CmCancelAllOpenOrdersService struct {
// contains filtered or unexported fields
}
CmCancelAllOpenOrdersService cancel all open orders
func (*CmCancelAllOpenOrdersService) Do ¶ added in v0.1.18
func (s *CmCancelAllOpenOrdersService) Do(ctx context.Context, opts ...RequestOption) (err error)
Do send request
func (*CmCancelAllOpenOrdersService) Symbol ¶ added in v0.1.18
func (s *CmCancelAllOpenOrdersService) Symbol(symbol string) *CmCancelAllOpenOrdersService
Symbol set symbol
type CmCancelOrderResponse ¶ added in v0.1.18
type CmCancelOrderResponse struct { AvgPrice string `json:"avgPrice"` ClientOrderID string `json:"clientOrderId"` CumQuantity string `json:"cumQty"` 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"` Pair string `json:"pair"` TimeInForce TimeInForceType `json:"timeInForce"` Type OrderType `json:"type"` UpdateTime int64 `json:"updateTime"` // contains filtered or unexported fields }
CmCancelOrderResponse define response of canceling order
type CmCancelOrderService ¶ added in v0.1.18
type CmCancelOrderService struct {
// contains filtered or unexported fields
}
CmCancelOrderService cancel all open orders
func (*CmCancelOrderService) ClientOrderID ¶ added in v0.1.18
func (s *CmCancelOrderService) ClientOrderID(clientOrderID string) *CmCancelOrderService
ClientOrderID set clientOrderID
func (*CmCancelOrderService) Do ¶ added in v0.1.18
func (s *CmCancelOrderService) Do(ctx context.Context, opts ...RequestOption) (res *CmCancelOrderResponse, err error)
func (*CmCancelOrderService) OrderID ¶ added in v0.1.18
func (s *CmCancelOrderService) OrderID(orderID int64) *CmCancelOrderService
OrderID set orderID
func (*CmCancelOrderService) Symbol ¶ added in v0.1.18
func (s *CmCancelOrderService) Symbol(symbol string) *CmCancelOrderService
Symbol set symbol
type CmChangePositionMode ¶ added in v0.1.35
type CmChangePositionModeService ¶ added in v0.1.35
type CmChangePositionModeService struct {
// contains filtered or unexported fields
}
func (*CmChangePositionModeService) Do ¶ added in v0.1.35
func (s *CmChangePositionModeService) Do(ctx context.Context, opts ...RequestOption) (res *CmChangePositionMode, err error)
Do send request
func (*CmChangePositionModeService) DualSidePosition ¶ added in v0.1.35
func (s *CmChangePositionModeService) DualSidePosition(dualSidePosition bool) *CmChangePositionModeService
DualSidePosition set positionSide
type CmCommissionRateService ¶
type CmCommissionRateService struct {
// contains filtered or unexported fields
}
func (*CmCommissionRateService) Do ¶
func (s *CmCommissionRateService) Do(ctx context.Context, opts ...RequestOption) (res *CmCommissionRateResponse, err error)
Do send request
func (*CmCommissionRateService) Symbol ¶
func (s *CmCommissionRateService) Symbol(symbol string) *CmCommissionRateService
Symbol set symbol
type CmCreateOrderResponse ¶ added in v0.1.18
type CmCreateOrderResponse struct { ClientOrderID string `json:"clientOrderId"` // CumQty 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"` // Symbol string `json:"symbol"` // Pair string `json:"pair"` TimeInForce TimeInForceType `json:"timeInForce"` // Type OrderType `json:"type"` // UpdateTime int64 `json:"updateTime"` // update time }
CmCreateOrderResponse define create order response
type CmCreateOrderService ¶ added in v0.1.18
type CmCreateOrderService struct {
// contains filtered or unexported fields
}
CmCreateOrderService create order
func (*CmCreateOrderService) Do ¶ added in v0.1.18
func (s *CmCreateOrderService) Do(ctx context.Context, opts ...RequestOption) (res *CmCreateOrderResponse, err error)
Do send request
func (*CmCreateOrderService) NewClientOrderID ¶ added in v0.1.18
func (s *CmCreateOrderService) NewClientOrderID(newClientOrderID string) *CmCreateOrderService
NewClientOrderID set newClientOrderID
func (*CmCreateOrderService) NewOrderResponseType ¶ added in v0.1.18
func (s *CmCreateOrderService) NewOrderResponseType(newOrderResponseType NewOrderRespType) *CmCreateOrderService
NewOrderResponseType set newOrderResponseType
func (*CmCreateOrderService) PositionSide ¶ added in v0.1.18
func (s *CmCreateOrderService) PositionSide(positionSide PositionSideType) *CmCreateOrderService
PositionSide set side
func (*CmCreateOrderService) Price ¶ added in v0.1.18
func (s *CmCreateOrderService) Price(price string) *CmCreateOrderService
Price set price
func (*CmCreateOrderService) Quantity ¶ added in v0.1.18
func (s *CmCreateOrderService) Quantity(quantity string) *CmCreateOrderService
Quantity set quantity
func (*CmCreateOrderService) ReduceOnly ¶ added in v0.1.18
func (s *CmCreateOrderService) ReduceOnly(reduceOnly bool) *CmCreateOrderService
ReduceOnly set reduceOnly
func (*CmCreateOrderService) Side ¶ added in v0.1.18
func (s *CmCreateOrderService) Side(side SideType) *CmCreateOrderService
Side set side
func (*CmCreateOrderService) Symbol ¶ added in v0.1.18
func (s *CmCreateOrderService) Symbol(symbol string) *CmCreateOrderService
Symbol set symbol
func (*CmCreateOrderService) TimeInForce ¶ added in v0.1.18
func (s *CmCreateOrderService) TimeInForce(timeInForce TimeInForceType) *CmCreateOrderService
TimeInForce set timeInForce
func (*CmCreateOrderService) Type ¶ added in v0.1.18
func (s *CmCreateOrderService) Type(orderType OrderType) *CmCreateOrderService
Type set type
type CmGetAccountService ¶ added in v0.1.18
type CmGetAccountService struct {
// contains filtered or unexported fields
}
CmGetAccountService get account info
func (*CmGetAccountService) Do ¶ added in v0.1.18
func (s *CmGetAccountService) Do(ctx context.Context, opts ...RequestOption) (res *UmAccount, err error)
Do send request
type CmGetPositionMode ¶ added in v0.1.35
type CmGetPositionMode struct {
DualSidePosition bool `json:"dualSidePosition"`
}
type CmGetPositionModeService ¶ added in v0.1.35
type CmGetPositionModeService struct {
// contains filtered or unexported fields
}
func (*CmGetPositionModeService) Do ¶ added in v0.1.35
func (s *CmGetPositionModeService) Do(ctx context.Context, opts ...RequestOption) (res *CmGetPositionMode, err error)
Do send request
type CmListOpenOrdersService ¶ added in v0.1.18
type CmListOpenOrdersService struct {
// contains filtered or unexported fields
}
CmListOpenOrdersService list opened orders
func (*CmListOpenOrdersService) Do ¶ added in v0.1.18
func (s *CmListOpenOrdersService) Do(ctx context.Context, opts ...RequestOption) (res []*CmOrder, err error)
Do send request
func (*CmListOpenOrdersService) Symbol ¶ added in v0.1.18
func (s *CmListOpenOrdersService) Symbol(symbol string) *CmListOpenOrdersService
Symbol set symbol
type CmOrder ¶ added in v0.1.18
type CmOrder 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"` Pair string `json:"pair"` Time int64 `json:"time"` TimeInForce TimeInForceType `json:"timeInForce"` Type OrderType `json:"type"` UpdateTime int64 `json:"updateTime"` }
CmOrder define order info
type CmSetLeverageResponse ¶
type CmSetLeverageService ¶
type CmSetLeverageService struct {
// contains filtered or unexported fields
}
func (*CmSetLeverageService) Do ¶
func (s *CmSetLeverageService) Do(ctx context.Context, opts ...RequestOption) (res *CmSetLeverageResponse, err error)
Do send request
func (*CmSetLeverageService) Leverage ¶
func (s *CmSetLeverageService) Leverage(leverage int64) *CmSetLeverageService
Leverage set leverage
func (*CmSetLeverageService) Symbol ¶
func (s *CmSetLeverageService) Symbol(symbol string) *CmSetLeverageService
Symbol set symbol
type GetAllBalanceService ¶ added in v0.1.35
type GetAllBalanceService struct {
// contains filtered or unexported fields
}
func (*GetAllBalanceService) Do ¶ added in v0.1.35
func (s *GetAllBalanceService) Do(ctx context.Context, opts ...RequestOption) (res []*Balance, err error)
Do send request
type GetMaxBorrowableService ¶ added in v0.1.35
type GetMaxBorrowableService struct {
// contains filtered or unexported fields
}
func (*GetMaxBorrowableService) Asset ¶ added in v0.1.35
func (s *GetMaxBorrowableService) Asset(asset string) *GetMaxBorrowableService
func (*GetMaxBorrowableService) Do ¶ added in v0.1.35
func (s *GetMaxBorrowableService) Do(ctx context.Context, opts ...RequestOption) (res *MaxBorrowable, err error)
Do send request
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 MaxBorrowable ¶ added in v0.1.35
type NewOrderRespType ¶
type NewOrderRespType string
NewOrderRespType define response JSON verbosity
type OrderExecutionType ¶
type OrderExecutionType string
OrderExecutionType define order execution 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 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 UmCancelAllOpenOrdersService ¶
type UmCancelAllOpenOrdersService struct {
// contains filtered or unexported fields
}
UmCancelAllOpenOrdersService cancel all open orders
func (*UmCancelAllOpenOrdersService) Do ¶
func (s *UmCancelAllOpenOrdersService) Do(ctx context.Context, opts ...RequestOption) (err error)
Do send request
func (*UmCancelAllOpenOrdersService) Symbol ¶
func (s *UmCancelAllOpenOrdersService) Symbol(symbol string) *UmCancelAllOpenOrdersService
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 (s *UmCancelOrderService) Do(ctx context.Context, opts ...RequestOption) (res *UmCancelOrderResponse, err error)
func (*UmCancelOrderService) OrderID ¶
func (s *UmCancelOrderService) OrderID(orderID int64) *UmCancelOrderService
OrderID set orderID
func (*UmCancelOrderService) Symbol ¶
func (s *UmCancelOrderService) Symbol(symbol string) *UmCancelOrderService
Symbol set symbol
type UmChangePositionMode ¶ added in v0.1.35
type UmChangePositionModeService ¶ added in v0.1.35
type UmChangePositionModeService struct {
// contains filtered or unexported fields
}
func (*UmChangePositionModeService) Do ¶ added in v0.1.35
func (s *UmChangePositionModeService) Do(ctx context.Context, opts ...RequestOption) (res *UmChangePositionMode, err error)
Do send request
func (*UmChangePositionModeService) DualSidePosition ¶ added in v0.1.35
func (s *UmChangePositionModeService) DualSidePosition(dualSidePosition bool) *UmChangePositionModeService
DualSidePosition set positionSide
type UmCommissionRateService ¶
type UmCommissionRateService struct {
// contains filtered or unexported fields
}
func (*UmCommissionRateService) Do ¶
func (s *UmCommissionRateService) Do(ctx context.Context, opts ...RequestOption) (res *UnCommissionRateResponse, err error)
Do send request
func (*UmCommissionRateService) Symbol ¶
func (s *UmCommissionRateService) Symbol(symbol string) *UmCommissionRateService
Symbol set symbol
type UmCreateOrderResponse ¶ added in v0.1.19
type UmCreateOrderResponse 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 UmCreateOrderService ¶
type UmCreateOrderService struct {
// contains filtered or unexported fields
}
UmCreateOrderService create order
func (*UmCreateOrderService) Do ¶
func (s *UmCreateOrderService) Do(ctx context.Context, opts ...RequestOption) (res *UmCreateOrderResponse, err error)
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 ¶
func (s *UmCreateOrderService) Price(price string) *UmCreateOrderService
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 ¶
func (s *UmCreateOrderService) Side(side SideType) *UmCreateOrderService
Side set side
func (*UmCreateOrderService) Symbol ¶
func (s *UmCreateOrderService) Symbol(symbol string) *UmCreateOrderService
Symbol set symbol
func (*UmCreateOrderService) TimeInForce ¶
func (s *UmCreateOrderService) TimeInForce(timeInForce TimeInForceType) *UmCreateOrderService
TimeInForce set timeInForce
func (*UmCreateOrderService) Type ¶
func (s *UmCreateOrderService) Type(orderType OrderType) *UmCreateOrderService
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 UmGetPositionMode ¶ added in v0.1.35
type UmGetPositionMode struct {
DualSidePosition bool `json:"dualSidePosition"`
}
type UmGetPositionModeService ¶ added in v0.1.35
type UmGetPositionModeService struct {
// contains filtered or unexported fields
}
func (*UmGetPositionModeService) Do ¶ added in v0.1.35
func (s *UmGetPositionModeService) Do(ctx context.Context, opts ...RequestOption) (res *UmGetPositionMode, 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 ¶
func (s *UmListOpenOrdersService) Symbol(symbol string) *UmListOpenOrdersService
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 UmSetLeverageResponse ¶
type UmSetLeverageService ¶
type UmSetLeverageService struct {
// contains filtered or unexported fields
}
func (*UmSetLeverageService) Do ¶
func (s *UmSetLeverageService) Do(ctx context.Context, opts ...RequestOption) (res *UmSetLeverageResponse, err error)
Do send request
func (*UmSetLeverageService) Leverage ¶
func (s *UmSetLeverageService) Leverage(leverage int64) *UmSetLeverageService
Leverage set leverage
func (*UmSetLeverageService) Symbol ¶
func (s *UmSetLeverageService) Symbol(symbol string) *UmSetLeverageService
Symbol set symbol
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 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 WsPackedUserDataEvent ¶ added in v0.1.12
type WsPackedUserDataEvent struct { EventType string `json:"e"` EventContent string `json:"EventContent,omitempty"` }
WsPackedUserDataEvent define user data event
type WsPackedUserDataHandler ¶ added in v0.1.12
type WsPackedUserDataHandler func(event *WsPackedUserDataEvent)
WsPackedUserDataHandler handle WsPackedUserDataEvent
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,omitempty"` AccountUpdate WsAccountUpdate `json:"a,omitempty"` OrderTradeUpdate WsOrderTradeUpdate `json:"o,omitempty"` }
WsUserDataEvent define user data event
type WsUserDataHandler ¶
type WsUserDataHandler func(event *WsUserDataEvent)
WsUserDataHandler handle WsUserDataEvent