options

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

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

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

	OptionSideTypeCall OptionSideType = "CALL"
	OptionSideTypePut  OptionSideType = "PUT"

	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"

	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"
	OrderStatusTypeNewInsurance    OrderStatusType = "NEW_INSURANCE"
	OrderStatusTypeNewADL          OrderStatusType = "NEW_ADL"
	OrderStatusTypeAccepted        OrderStatusType = "ACCEPTED"

	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"
	SymbolFilterTypeMaxNumAlgoOrders SymbolFilterType = "MAX_NUM_ALGO_ORDERS"
	SymbolFilterTypeMinNotional      SymbolFilterType = "MIN_NOTIONAL"

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

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

	ContractTypePerpetual ContractType = "PERPETUAL"

	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"

	ForceOrderCloseTypeLiquidation ForceOrderCloseType = "LIQUIDATION"
	ForceOrderCloseTypeADL         ForceOrderCloseType = "ADL"
)

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

	ProxyUrl = ""
)

Functions

func SetWsProxyUrl

func SetWsProxyUrl(url string)

func WsCombinedServe

func WsCombinedServe(streamName []string, handler map[string]interface{}, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

reference: https://binance-docs.github.io/apidocs/voptions/en/#websocket-market-streams

streamName: you should collaborate stream names through official documentation or other function above defined,

the legitimacy of parameters needs to be guaranteed by the caller

handler: a map of handler function, its key needs to correspond to the handler of the incoming streamname,

handler's key should be in ["trade", "index", "markPrice", "kline", "ticker", "openInterest", "option_pair", "depth"]

for example:

WsCombinedServe({"ETH-240927-5500-P@depth10"}, map[string]interface{}{"depth": func(*WsDepthEvent) {}}, func(error){})
WsCombinedServe({"ETH-240927-5500-P@depth10", "ETH-240927-5500-P@kline_1m"},
			    map[string]interface{}{"depth": func(*WsDepthEvent) {}, "kline": func(*WsKlineEvent){}}, func(error){})

note: the symbol(underlying) of streamName should be upper.

func WsDepthServe

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

levels: [10, 20, 50, 100, 1000] rate: [100, 500, 100] ms, default 500ms while rate is nil

func WsIndexServe

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

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

func WsKlineServe

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

func WsMarkPriceServe

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

func WsOpenInterestServe

func WsOpenInterestServe(underlying string, expireDate string, handler WsOpenInterestHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

expireDate: for example 220930 underlying: for example ETH

func WsOptionPairServe

func WsOptionPairServe(handler WsOptionPairHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

func WsTickerServe

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

func WsTickerWithExpireServe

func WsTickerWithExpireServe(underlying string, expireDate string, handler WsTickerHandler, errHandler ErrHandler) (doneC, stopC chan struct{}, err error)

expireDate: for example 220930 underlying: for example ETH

func WsTradeServe

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

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

func WsUserDataServe

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

Types

type Account

type Account struct {
	Asset     []*Asset `json:"asset"`
	Greek     []*Greek `json:"greek"`
	RiskLevel string   `json:"riskLevel"`
	Time      uint64   `json:"time"`
}

Account define create order response

type AccountService

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

AccountService create order

func (*AccountService) Do

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

Do send request

type Ask

type Ask = common.PriceLevel

Ask is a type alias for PriceLevel.

type Asset

type Asset struct {
	Asset         string `json:"asset"`
	MarginBalance string `json:"marginBalance"`
	Equity        string `json:"equity"`
	Available     string `json:"available"`
	Locked        string `json:"locked"`
	UnrealizedPNL string `json:"unrealizedPNL"`
}

type Bid

type Bid = common.PriceLevel

Bid is a type alias for PriceLevel.

type Bill

type Bill struct {
	Id         string `json:"id"`
	Asset      string `json:"asset"`
	Amount     string `json:"amount"`
	Type       string `json:"type"`
	CreateDate int64  `json:"createDate"`
}

type BillService

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

func (*BillService) Currency

func (s *BillService) Currency(c string) *BillService

func (*BillService) Do

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

func (*BillService) EndTime

func (s *BillService) EndTime(et uint64) *BillService

func (*BillService) Limit

func (s *BillService) Limit(limit int) *BillService

func (*BillService) RecordId

func (s *BillService) RecordId(ri uint64) *BillService

func (*BillService) StartTime

func (s *BillService) StartTime(st uint64) *BillService

type CancelAllOpenOrdersByUnderlyingRsp

type CancelAllOpenOrdersByUnderlyingRsp struct {
	Code string  `json:"code"`
	Msg  string  `json:"msg"`
	Data *string `json:"data"`
}

type CancelAllOpenOrdersByUnderlyingService

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

func (*CancelAllOpenOrdersByUnderlyingService) Do

func (*CancelAllOpenOrdersByUnderlyingService) Underlying

type CancelAllOpenOrdersRsp

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

type CancelAllOpenOrdersService

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

CancelAllOpenOrdersService cancel all open orders

func (*CancelAllOpenOrdersService) Do

func (*CancelAllOpenOrdersService) Symbol

Symbol set symbol

type CancelBatchOrdersService

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

CancelBatchOrdersService cancel a list of orders

func (*CancelBatchOrdersService) ClientOrderIds

func (s *CancelBatchOrdersService) ClientOrderIds(clientOrderIds []string) *CancelBatchOrdersService

ClientOrderIDList set clientOrderIds

func (*CancelBatchOrdersService) Do

func (s *CancelBatchOrdersService) Do(ctx context.Context, opts ...RequestOption) (res []interface{}, err error)

return: [Order, APIError]

func (*CancelBatchOrdersService) OrderIds

func (s *CancelBatchOrdersService) OrderIds(orderIds []int64) *CancelBatchOrdersService

OrderId set OrderId

func (*CancelBatchOrdersService) Symbol

Symbol set symbol

type CancelOrderService

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

CancelOrderService cancel an order

func (*CancelOrderService) ClientOrderId

func (s *CancelOrderService) ClientOrderId(clientOrderId string) *CancelOrderService

ClientOrderId set clientOrderId

func (*CancelOrderService) Do

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

Do send request

func (*CancelOrderService) OrderId

func (s *CancelOrderService) OrderId(orderId int64) *CancelOrderService

OrderId set OrderId

func (*CancelOrderService) Symbol

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

Symbol set symbol

type Client

type Client struct {
	APIKey     string
	SecretKey  string
	KeyType    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 NewProxiedClient

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

NewProxiedClient passing a proxy url

func (*Client) NewAccountService

func (c *Client) NewAccountService() *AccountService

func (*Client) NewBillService

func (c *Client) NewBillService() *BillService

GET /eapi/v1/bill Obtain account fund flow

func (*Client) NewCancelAllOpenOrdersByUnderlyingService

func (c *Client) NewCancelAllOpenOrdersByUnderlyingService() *CancelAllOpenOrdersByUnderlyingService

DELETE /eapi/v1/allOpenOrdersByUnderlying

func (*Client) NewCancelAllOpenOrdersService

func (c *Client) NewCancelAllOpenOrdersService() *CancelAllOpenOrdersService

NewCancelAllOpenOrdersService init cancel all open orders service DELETE /eapi/v1/allOpenOrders

func (*Client) NewCancelBatchOrdersService

func (c *Client) NewCancelBatchOrdersService() *CancelBatchOrdersService

NewCancelBatchOrdersService init cancel multiple orders service DELETE /eapi/v1/batchOrders

func (*Client) NewCancelOrderService

func (c *Client) NewCancelOrderService() *CancelOrderService

NewCancelOrderService init cancel order service DELETE /eapi/v1/order

func (*Client) NewCloseUserStreamService

func (c *Client) NewCloseUserStreamService() *CloseUserStreamService

func (*Client) NewCreateBatchOrdersService

func (c *Client) NewCreateBatchOrdersService() *CreateBatchOrdersService

NewCreateBatchOrdersService init creating batch order service POST /eapi/v1/batchOrders

func (*Client) NewCreateOrderService

func (c *Client) NewCreateOrderService() *CreateOrderService

NewCreateOrderService init creating order service POST /eapi/v1/order

func (*Client) NewDepthService

func (c *Client) NewDepthService() *DepthService

NewDepthService init depth service

func (*Client) NewExchangeInfoService

func (c *Client) NewExchangeInfoService() *ExchangeInfoService

NewExchangeInfoService init exchange info service

func (*Client) NewExerciseHistoryService

func (c *Client) NewExerciseHistoryService() *ExerciseHistoryService

func (*Client) NewExercistRecordService

func (c *Client) NewExercistRecordService() *ExerciseRecordService

GET /eapi/v1/exerciseRecord

func (*Client) NewGetOrderService

func (c *Client) NewGetOrderService() *GetOrderService

NewGetOrderService init get order service GET /eapi/v1/order

func (*Client) NewHistoricalTradesService

func (c *Client) NewHistoricalTradesService() *HistoricalTradesService

func (*Client) NewHistoryOrdersService

func (c *Client) NewHistoryOrdersService() *HistoryOrdersService

GET /eapi/v1/historyOrders

func (*Client) NewIncomeDownloadIdService

func (c *Client) NewIncomeDownloadIdService() *IncomeDownloadIdService

GET /eapi/v1/income/asyn Get option fund flow download ID

func (*Client) NewIncomeDownloadLinkService

func (c *Client) NewIncomeDownloadLinkService() *IncomeDownloadLinkService

GET /eapi/v1/income/asyn/id Obtain the contract fund flow download link through the download ID

func (*Client) NewIndexService

func (c *Client) NewIndexService() *IndexService

func (*Client) NewKeepaliveUserStreamService

func (c *Client) NewKeepaliveUserStreamService() *KeepaliveUserStreamService

func (*Client) NewKlinesService

func (c *Client) NewKlinesService() *KlinesService

NewKlinesService init klines service

func (*Client) NewListOpenOrdersService

func (c *Client) NewListOpenOrdersService() *ListOpenOrdersService

NewListOpenOrdersService init list open orders service GET /eapi/v1/openOrders

func (*Client) NewMarkService

func (c *Client) NewMarkService() *MarkService

func (*Client) NewOpenInterestService

func (c *Client) NewOpenInterestService() *OpenInterestService

func (*Client) NewPingService

func (c *Client) NewPingService() *PingService

ping server

func (*Client) NewPositionService

func (c *Client) NewPositionService() *PositionService

GET /eapi/v1/position

func (*Client) NewServerTimeService

func (c *Client) NewServerTimeService() *ServerTimeService

get timestamp(ms) of server

func (*Client) NewStartUserStreamService

func (c *Client) NewStartUserStreamService() *StartUserStreamService

func (*Client) NewTickerService

func (c *Client) NewTickerService() *TickerService

func (*Client) NewTradesService

func (c *Client) NewTradesService() *TradesService

func (*Client) NewUserTradesService

func (c *Client) NewUserTradesService() *UserTradesService

GET /eapi/v1/userTrades

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 ContractType

type ContractType string

ContractType define contract type

type CreateBatchOrdersService

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

func (*CreateBatchOrdersService) Do

func (s *CreateBatchOrdersService) Do(ctx context.Context, opts ...RequestOption) (res []interface{}, err error)

return: [Order, APIError]

func (*CreateBatchOrdersService) OrderList

type CreateOrderService

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

CreateOrderService create order

func (*CreateOrderService) ClientOrderId

func (s *CreateOrderService) ClientOrderId(ClientOrderId string) *CreateOrderService

ClientOrderId set clientOrderId

func (*CreateOrderService) Do

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

Do send request

func (*CreateOrderService) IsMmp

func (s *CreateOrderService) IsMmp(isMmp bool) *CreateOrderService

IsMmp set isMmp

func (*CreateOrderService) NewOrderResponseType

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

NewOrderResponseType set newOrderResponseType

func (*CreateOrderService) PostOnly

func (s *CreateOrderService) PostOnly(postOnly bool) *CreateOrderService

PostOnly set postOnly

func (*CreateOrderService) Price

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

Price set price

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

type DepthResponse

type DepthResponse struct {
	TradeTime int64 `json:"T"`
	UpdateID  int64 `json:"u"`
	Bids      []Bid `json:"bids"`
	Asks      []Ask `json:"asks"`
}

DepthResponse define depth info with bids and asks

type DepthService

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

DepthService show depth info

func (*DepthService) Do

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

Do send request

func (*DepthService) Limit

func (s *DepthService) Limit(limit int) *DepthService

Limit set limit

func (*DepthService) Symbol

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

Symbol set symbol

type ErrHandler

type ErrHandler func(err error)

ErrHandler handles errors

type ExchangeInfo

type ExchangeInfo struct {
	Timezone        string           `json:"timezone"`
	ServerTime      int64            `json:"serverTime"`
	OptionContracts []OptionContract `json:"optionContracts"`
	OptionAssets    []OptionAsset    `json:"optionAssets"`
	OptionSymbols   []OptionSymbol   `json:"optionSymbols"`
	RateLimits      []RateLimit      `json:"rateLimits"`
}

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 ExerciseHistory

type ExerciseHistory struct {
	Symbol          string `json:"symbol"`
	StrikePrice     string `json:"strikePrice"`
	RealStrikePrice string `json:"realStrikePrice"`
	ExpiryDate      uint64 `json:"expiryDate"`
	StrikeResult    string `json:"strikeResult"`
}

type ExerciseHistoryService

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

underlying: Spot trading pairs such as BTCUSDT

func (*ExerciseHistoryService) Do

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

Do send request

func (*ExerciseHistoryService) EndTime

func (*ExerciseHistoryService) Limit

func (*ExerciseHistoryService) StartTime

func (s *ExerciseHistoryService) StartTime(startTime uint64) *ExerciseHistoryService

func (*ExerciseHistoryService) Underlying

func (s *ExerciseHistoryService) Underlying(underlying string) *ExerciseHistoryService

Underlying set underlying

type ExerciseRecord

type ExerciseRecord struct {
	Id            string `json:"id"`
	Currency      string `json:"currency"`
	Symbol        string `json:"symbol"`
	ExercisePrice string `json:"exercisePrice"`
	MarkPrice     string `json:"markPrice"`
	Quantity      string `json:"quantity"`
	Amount        string `json:"amount"`
	Fee           string `json:"fee"`
	CreateDate    uint64 `json:"createDate"`
	PriceScale    int    `json:"priceScale"`
	QuantityScale int    `json:"quantityScale"`
	OptionSide    string `json:"optionSide"`
	PositionSide  string `json:"positionSide"`
	QuoteAsset    string `json:"quoteAsset"`
}

type ExerciseRecordService

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

func (*ExerciseRecordService) Do

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

func (*ExerciseRecordService) EndTime

func (*ExerciseRecordService) Limit

func (*ExerciseRecordService) StartTime

func (*ExerciseRecordService) Symbol

type ForceOrderCloseType

type ForceOrderCloseType string

ForceOrderCloseType define reason type for force order

type GetOrderService

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

GetOrderService get an order

func (*GetOrderService) ClientOrderId

func (s *GetOrderService) ClientOrderId(clientOrderId string) *GetOrderService

ClientOrderId set clientOrderId

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

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

Symbol set symbol

type Greek

type Greek struct {
	Underlying string `json:"underlying"`
	Delta      string `json:"delta"`
	Gamma      string `json:"gamma"`
	Theta      string `json:"theta"`
	Vega       string `json:"vega"`
}

type HistoricalTrade

type HistoricalTrade struct {
	Id       uint64 `json:"id"`
	TradeId  int    `json:"tradeId"`
	Price    string `json:"price"`
	Qty      string `json:"qty"`
	QuoteQty string `json:"quoteQty"`
	Side     int    `json:"side"`
	Time     uint64 `json:"time"`
}

HistoricalTrade define historical trade info

type HistoricalTradesService

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

HistoricalTradesService trades

func (*HistoricalTradesService) Do

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

Do send request

func (*HistoricalTradesService) FromID

FromID set fromID

func (*HistoricalTradesService) Limit

Limit set limit

func (*HistoricalTradesService) Symbol

Symbol set symbol

type HistoryOrdersService

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

func (*HistoryOrdersService) Do

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

func (*HistoryOrdersService) EndTime

func (*HistoryOrdersService) Limit

func (*HistoryOrdersService) OrderId

func (s *HistoryOrdersService) OrderId(orderId uint64) *HistoryOrdersService

func (*HistoryOrdersService) StartTime

func (*HistoryOrdersService) Symbol

type IncomeDownloadId

type IncomeDownloadId struct {
	AvgCostTimestampOfLast30d uint64  `json:"avgCostTimestampOfLast30d"`
	DownloadId                string  `json:"downloadId"`
	Error                     *string `json:"error"`
}

type IncomeDownloadIdService

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

func (*IncomeDownloadIdService) Do

func (*IncomeDownloadIdService) EndTime

func (*IncomeDownloadIdService) StartTime

type IncomeDownloadLink struct {
	DownloadId          string `json:"downloadId"`
	Status              string `json:"status"`
	Url                 string `json:"url"`
	Notified            bool   `json:"notified"`
	ExpirationTimestamp int64  `json:"expirationTimestamp"`
	IsExpired           *bool  `json:"isExpired"`
}

type IncomeDownloadLinkService

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

func (*IncomeDownloadLinkService) Do

func (*IncomeDownloadLinkService) DownloadId

type Index

type Index struct {
	Time       uint64 `json:"time"`
	IndexPrice string `json:"indexPrice"`
}

type IndexService

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

underlying: Spot trading pairs such as BTCUSDT

func (*IndexService) Do

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

Do send request

func (*IndexService) Underlying

func (s *IndexService) Underlying(underlying string) *IndexService

Underlying set underlying

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 {
	Open        string `json:"open"`
	High        string `json:"high"`
	Low         string `json:"low"`
	Close       string `json:"close"`
	Volume      string `json:"volume"`
	Amount      string `json:"amount"`
	Interval    string `json:"interval"`
	TradeCount  int64  `json:"tradeCount"`
	TakerVolume string `json:"takerVolume"`
	TakerAmount string `json:"takerAmount"`
	OpenTime    int64  `json:"openTime"`
	CloseTime   int64  `json:"closeTime"`
}

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 LastTrade

type LastTrade struct {
	Id      int64  `json:"id"`
	TradeId int64  `json:"tradeId"`
	Time    int64  `json:"time"`
	Price   string `json:"price"`
	Qty     string `json:"qty"`
}

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

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

EndTime set endTime

func (*ListOpenOrdersService) Limit

Limit set limit

func (*ListOpenOrdersService) OrderId

func (s *ListOpenOrdersService) OrderId(orderId int64) *ListOpenOrdersService

OrderId set orderId

func (*ListOpenOrdersService) StartTime

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

StartTime set startTime

func (*ListOpenOrdersService) Symbol

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 Mark

type Mark struct {
	Symbol           string `json:"symbol"`
	MarkPrice        string `json:"markPrice"`
	BidIV            string `json:"bidIV"`
	AskIV            string `json:"askIV"`
	MarkIV           string `json:"markIV"`
	Delta            string `json:"delta"`
	Theta            string `json:"theta"`
	Gamma            string `json:"gamma"`
	Vega             string `json:"vega"`
	HighPriceLimit   string `json:"highPriceLimit"`
	LowPriceLimit    string `json:"lowPriceLimit"`
	RiskFreeInterest string `json:"riskFreeInterest"`
}

type MarkService

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

MarkService list recent trades in orderbook

func (*MarkService) Do

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

Do send request

func (*MarkService) Symbol

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

Symbol set symbol

type NewOrderRespType

type NewOrderRespType string

NewOrderRespType define response JSON verbosity

type OpenInterest

type OpenInterest struct {
	Symbol             string `json:"symbol"`
	SumOpenInterest    string `json:"sumOpenInterest"`
	SumOpenInterestUsd string `json:"sumOpenInterestUsd"`
	Timestamp          string `json:"timestamp"`
}

type OpenInterestService

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

underlying: Spot trading pairs such as BTCUSDT

func (*OpenInterestService) Do

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

Do send request

func (*OpenInterestService) Expiration

func (s *OpenInterestService) Expiration(expiration string) *OpenInterestService

func (*OpenInterestService) UnderlyingAsset

func (s *OpenInterestService) UnderlyingAsset(underlyingAsset string) *OpenInterestService

Underlying set underlying

type OptionAsset

type OptionAsset struct {
	Id   int64  `json:"id"`
	Name string `json:"name"`
}

Option Asset

type OptionContract

type OptionContract struct {
	Id          int64  `json:"id"`
	BaseAsset   string `json:"baseAsset"`
	QuoteAsset  string `json:"quoteAsset"`
	Underlying  string `json:"underlying"`
	SettleAsset string `json:"settleAsset"`
}

Option Contract

type OptionSideType

type OptionSideType string

OptionSideType define option side type of order

type OptionSymbol

type OptionSymbol struct {
	ContractId           int64                    `json:"contractId"`
	ExpiryDate           int64                    `json:"expiryDate"`
	Filters              []map[string]interface{} `json:"filters"`
	Id                   int64                    `json:"id"`
	Symbol               string                   `json:"symbol"`
	Side                 string                   `json:"side"`
	StrikePrice          string                   `json:"strikePrice"`
	Underlying           string                   `json:"underlying"`
	Unit                 int64                    `json:"unit"`
	MakerFeeRate         string                   `json:"makerFeeRate"`
	TakerFeeRate         string                   `json:"takerFeeRate"`
	MinQty               string                   `json:"minQty"`
	MaxQty               string                   `json:"maxQty"`
	InitialMargin        string                   `json:"initialMargin"`
	MaintenanceMargin    string                   `json:"maintenanceMargin"`
	MinInitialMargin     string                   `json:"minInitialMargin"`
	MinMaintenanceMargin string                   `json:"minMaintenanceMargin"`
	PriceScale           int                      `json:"priceScale"`
	QuantityScale        int                      `json:"quantityScale"`
	QuoteAsset           string                   `json:"quoteAsset"`
}

Option Symbol

func (*OptionSymbol) LotSizeFilter

func (s *OptionSymbol) LotSizeFilter() *LotSizeFilter

LotSizeFilter return lot size filter of symbol

func (*OptionSymbol) PriceFilter

func (s *OptionSymbol) PriceFilter() *PriceFilter

PriceFilter return price filter of symbol

type Order

type Order struct {
	OrderId       int64           `json:"orderId"`
	Symbol        string          `json:"symbol"`
	Price         string          `json:"price"`
	Quantity      string          `json:"quantity"`
	ExecutedQty   string          `json:"executedQty"`
	Fee           string          `json:"fee"`
	Side          SideType        `json:"side"`
	Type          OrderType       `json:"type"`
	TimeInForce   TimeInForceType `json:"timeInForce"`
	ReduceOnly    bool            `json:"reduceOnly"`
	PostOnly      bool            `json:"postOnly"`
	CreateTime    int64           `json:"createTime"`
	UpdateTime    int64           `json:"updateTime"`
	Status        OrderStatusType `json:"status"`
	Reason        *string         `json:"reason"` // set while query history orders.
	AvgPrice      string          `json:"avgPrice"`
	Source        string          `json:"source"`
	ClientOrderId string          `json:"clientOrderId"`
	PriceScale    int             `json:"priceScale"`
	QuantityScale int             `json:"quantityScale"`
	OptionSide    OptionSideType  `json:"optionSide"`
	QuoteAsset    string          `json:"quoteAsset"`
	Mmp           bool            `json:"mmp"`
	LastTrade     *LastTrade      `json:"lastTrade"` // order is immediately filled while calling create order, it will be set.

	RateLimitOrder10s string `json:"rateLimitOrder10s,omitempty"`
	RateLimitOrder1m  string `json:"rateLimitOrder1m,omitempty"`
}

Unified order structure, it would be used in many ways, for example, create order, cancel order, query open orders, query historical order and so on

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 PL

type PL struct {
	Price    string `json:"b"`
	Quantity string `json:"a"`
}

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 Position

type Position struct {
	EntryPrice    string `json:"entryPrice"`
	Symbol        string `json:"symbol"`
	Side          string `json:"side"`
	Quantity      string `json:"quantity"`
	ReducibleQty  string `json:"reducibleQty"`
	MarkValue     string `json:"markValue"`
	Ror           string `json:"ror"`
	UnrealizedPNL string `json:"unrealizedPNL"`
	MarkPrice     string `json:"markPrice"`
	StrikePrice   string `json:"strikePrice"`
	ExpiryDate    uint64 `json:"expiryDate"`
	PositionCost  string `json:"positionCost"`
	PriceScale    int    `json:"priceScale"`
	QuantityScale int    `json:"quantityScale"`
	OptionSide    string `json:"optionSide"`
	QuoteAsset    string `json:"quoteAsset"`
	Time          int64  `json:"time"`
}

type PositionService

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

func (*PositionService) Do

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

func (*PositionService) Symbol

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

type PositionSideType

type PositionSideType string

PositionSideType define position side type of order

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

type SymbolFilterType string

SymbolFilterType define symbol filter type

type SymbolStatusType

type SymbolStatusType string

SymbolStatusType define symbol status type

type SymbolType

type SymbolType string

SymbolType define symbol type

type Ticker

type Ticker struct {
	Symbol             string `json:"symbol"`
	PriceChange        string `json:"priceChange"`
	PriceChangePercent string `json:"priceChangePercent"`
	LastPrice          string `json:"lastPrice"`
	LastQty            string `json:"lastQty"`
	Open               string `json:"open"`
	High               string `json:"high"`
	Low                string `json:"low"`
	Volume             string `json:"volume"`
	Amount             string `json:"amount"`
	BidPrice           string `json:"bidPrice"`
	AskPrice           string `json:"askPrice"`
	OpenTime           int64  `json:"openTime"`
	CloseTime          int64  `json:"closeTime"`
	FirstTradeId       int    `json:"firstTradeId"`
	TradeCount         int    `json:"tradeCount"`
	StrikePrice        string `json:"strikePrice"`
	ExercisePrice      string `json:"exercisePrice"`
}

type TickerService

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

TickerService list recent trades in orderbook

func (*TickerService) Do

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

Do send request

func (*TickerService) Symbol

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

Symbol set symbol

type TimeInForceType

type TimeInForceType string

TimeInForceType define time in force type of order

type Trade

type Trade struct {
	Id       uint64 `json:"id"`
	TradeId  int    `json:"tradeId"`
	Symbol   string `json:"symbol"`
	Price    string `json:"price"`
	Qty      string `json:"qty"`
	QuoteQty string `json:"quoteQty"`
	Side     int    `json:"side"`
	Time     uint64 `json:"time"`
}

type TradesService

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

TradesService list recent trades in orderbook

func (*TradesService) Do

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

Do send request

func (*TradesService) Limit

func (s *TradesService) Limit(limit int) *TradesService

Limit set limit

func (*TradesService) Symbol

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

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 UserTrade

type UserTrade struct {
	Id             uint64 `json:"id"`
	TradeId        uint32 `json:"tradeId"`
	OrderId        uint64 `json:"orderId"`
	Symbol         string `json:"symbol"`
	Price          string `json:"price"`
	Quantity       string `json:"quantity"`
	Fee            string `json:"fee"`
	RealizedProfit string `json:"realizedProfit"`
	Side           string `json:"side"`
	Type           string `json:"type"`
	Volatility     string `json:"volatility"`
	Liquidity      string `json:"liquidity"`
	Time           uint64 `json:"time"`
	PriceScale     int    `json:"priceScale"`
	QuantityScale  int    `json:"quantityScale"`
	OptionSide     string `json:"optionSide"`
	QuoteAsset     string `json:"quoteAsset"`
}

type UserTradesService

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

func (*UserTradesService) Do

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

func (*UserTradesService) EndTime

func (s *UserTradesService) EndTime(et uint64) *UserTradesService

func (*UserTradesService) FromId

func (s *UserTradesService) FromId(fromId uint64) *UserTradesService

func (*UserTradesService) Limit

func (s *UserTradesService) Limit(limit int) *UserTradesService

func (*UserTradesService) StartTime

func (s *UserTradesService) StartTime(st uint64) *UserTradesService

func (*UserTradesService) Symbol

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

type WorkingType

type WorkingType string

WorkingType define working type

type WsBalance

type WsBalance struct {
	Balance           string `json:"b"`
	Merit             string `json:"m"`
	UnrealizedPnL     string `json:"u"`
	MaintenanceMargin string `json:"M"`
	InitialMargin     string `json:"i"`
	Asset             string `json:"a"`
}

WsBalance define balance

type WsConfig

type WsConfig struct {
	Endpoint string
	Proxy    *string
}

WsConfig webservice configuration

type WsDepthEvent

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

type WsDepthHandler

type WsDepthHandler func(events *WsDepthEvent)

type WsFilled

type WsFilled struct {
	TradeId    string `json:"t"`
	Price      string `json:"p"`
	Quantity   string `json:"q"`
	TradedTime int64  `json:"T"`
	Marker     string `json:"m"`
	Fee        string `json:"f"`
}

type WsGreek

type WsGreek struct {
	UnderlyingId string  `json:"ui"`
	Delta        float64 `json:"d"`
	Theta        float64 `json:"t"`
	Gamma        float64 `json:"g"`
	Vega         float64 `json:"v"`
}

type WsHandler

type WsHandler func(message []byte)

WsHandler handle raw websocket message

type WsIndexEvent

type WsIndexEvent struct {
	Event  string `json:"e"`
	Time   int64  `json:"E"`
	Symbol string `json:"s"`
	Price  string `json:"p"`
}

type WsIndexHandler

type WsIndexHandler func(event *WsIndexEvent)

type WsKline

type WsKline struct {
	StartTime        int64  `json:"t"`
	EndTime          int64  `json:"T"`
	Symbol           string `json:"s"`
	Interval         string `json:"i"`
	FirstTradeID     string `json:"F"`
	LastTradeID      string `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"`
	TakerVolume      string `json:"V"`
	TakerQuoteVolume string `json:"Q"`
}

type WsKlineEvent

type WsKlineEvent struct {
	Event  string   `json:"e"`
	Time   int64    `json:"E"`
	Symbol string   `json:"s"`
	Kline  *WsKline `json:"k"`
}

type WsKlineHandler

type WsKlineHandler func(events *WsKlineEvent)

type WsMarkPriceEvent

type WsMarkPriceEvent struct {
	Event     string `json:"e"`
	Time      int64  `json:"E"`
	Symbol    string `json:"s"`
	MarkPrice string `json:"mp"`
}

type WsMarkPriceHandler

type WsMarkPriceHandler func(events []*WsMarkPriceEvent)

type WsOpenInterestEvent

type WsOpenInterestEvent struct {
	Event        string `json:"e"`
	Time         int64  `json:"E"`
	Symbol       string `json:"s"`
	OpenInterest string `json:"o"` // open interest (in number of sheets)
	Hold         string `json:"h"` // hold (in usdt)
}

type WsOpenInterestHandler

type WsOpenInterestHandler func(events []*WsOpenInterestEvent)

type WsOptionPairEvent

type WsOptionPairEvent struct {
	Event        string `json:"e"`
	Time         int64  `json:"E"`
	Id           int    `json:"id"`  // option id
	CId          int    `json:"cid"` // Contract ID
	Underlying   string `json:"u"`
	QuoteAsset   string `json:"qa"`
	Symbol       string `json:"s"`
	Unit         int    `json:"unit"` // The number of targets represented by a contract
	MinQuantity  string `json:"mq"`   // Minimum transaction quantity
	Type         string `json:"d"`    // datatype is better ?
	StrikePrice  string `json:"sp"`
	ExerciseDate int64  `json:"ed"`
}

type WsOptionPairHandler

type WsOptionPairHandler func(events *WsOptionPairEvent)

type WsOrderTradeUpdate

type WsOrderTradeUpdate struct {
	CreateTime    int64      `json:"T"`
	UpdateTime    int64      `json:"t"`
	Symbol        string     `json:"s"`
	ClientOrderID string     `json:"c"`
	OrderId       string     `json:"oid"`
	Price         string     `json:"p"`
	Quantity      string     `json:"q"`
	Stp           int        `json:"stp"` //don't know
	ReduleOnly    bool       `json:"r"`
	PostOnly      bool       `json:"po"`
	Status        string     `json:"S"`
	ExecutedQty   string     `json:"e"`
	ExecutedCost  string     `json:"ec"` // maybe there's a better one word
	Fee           string     `json:"f"`
	TimeInForce   string     `json:"tif"`
	OrderType     string     `json:"oty"`
	Filled        []WsFilled `json:"fi"`
}

WsOrderTradeUpdate define order trade update

type WsPosition

type WsPosition struct {
	Symbol      string `json:"s"`
	CountQty    string `json:"c"`
	ReduleQty   string `json:"r"`
	PositionVal string `json:"p"`
	AvgPrice    string `json:"a"`
}

WsPosition define position

type WsTickerEvent

type WsTickerEvent struct {
	Event              string `json:"e"`
	Time               int64  `json:"E"`
	TradeTime          int64  `json:"T"`
	Symbol             string `json:"s"`
	Open               string `json:"o"`
	High               string `json:"h"`
	Low                string `json:"l"`
	Close              string `json:"c"`
	Volume             string `json:"V"`
	Amount             string `json:"A"`
	PriceChangePercent string `json:"P"`
	PriceChange        string `json:"p"`
	LastQty            string `json:"Q"`
	FirstID            string `json:"F"`
	LastID             string `json:"L"`
	TradeNum           int64  `json:"n"`
	BidOpenPrice       string `json:"bo"`
	AskOpenPrice       string `json:"ao"`
	BidQty             string `json:"bq"`
	AskQty             string `json:"aq"`
	BidIV              string `json:"b"`
	AskIV              string `json:"a"`
	Delta              string `json:"d"`
	Theta              string `json:"t"`
	Gamma              string `json:"g"`
	Vega               string `json:"v"`
	Volatility         string `json:"vo"`
	MarkPrice          string `json:"mp"`
	HighPriceLimit     string `json:"hl"` // highest limit price
	LowPriceLimit      string `json:"ll"`
	ExercisPrice       string `json:"eep"` // Perhaps there is a better one word to express certain meaning
	RiskFreeInterest   string `json:"r"`
}

type WsTickerHandler

type WsTickerHandler func(events []*WsTickerEvent)

type WsTradeEvent

type WsTradeEvent struct {
	Event     string `json:"e"`
	Time      int64  `json:"E"`
	Symbol    string `json:"s"`
	TradeId   string `json:"t"`
	Price     string `json:"p"`
	Quantity  string `json:"q"`
	BuyId     string `json:"b"`
	SellId    string `json:"a"`
	TradeTime int64  `json:"T"`
	Side      string `json:"S"` // -1 active sell, 1 active buy
}

type WsTradeHandler

type WsTradeHandler func(event *WsTradeEvent)

type WsUserDataEvent

type WsUserDataEvent struct {
	Event UserDataEventType `json:"e"`
	Time  int64             `json:"E"`

	RLCStatus            *string `json:"s"` // RLC = RISK_LEVEL_CHANGE
	RLCMarginBalance     *string `json:"mb"`
	RLCMaintenanceMargin *string `json:"mm"`

	AUBalance  []*WsBalance  `json:"B"` // AU = ACCOUNT_UPDATE
	AUGreek    []*WsGreek    `json:"G"`
	AUPosition []*WsPosition `json:"P"`
	AUUid      *int64        `json:"uid"`

	OTU []*WsOrderTradeUpdate `json:"o"` // OTU = ORDER_TRADE_UPDATE
}

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