Documentation
¶
Index ¶
- Variables
- func New(opts ...ClientOption) (*Client, Error)
- func NewLimitBuy(symbol string, price float64, quantity float64, timeInForce TimeInForce, ...) orderRequest
- func NewLimitMakerBuy(symbol string, price float64, quantity float64, opts ...LimitMakerOrderParams) orderRequest
- func NewLimitMakerOrder(symbol string, side OrderSide, price float64, quantity float64, ...) orderRequest
- func NewLimitMakerSell(symbol string, price float64, quantity float64, opts ...LimitMakerOrderParams) orderRequest
- func NewLimitOrder(symbol string, side OrderSide, price float64, quantity float64, ...) orderRequest
- func NewLimitSell(symbol string, price float64, quantity float64, timeInForce TimeInForce, ...) orderRequest
- func NewMarketBuy(symbol string, quantity float64, opts ...MarketOrderParams) orderRequest
- func NewMarketOrder(symbol string, side OrderSide, quantity float64, opts ...MarketOrderParams) orderRequest
- func NewMarketSell(symbol string, quantity float64, opts ...MarketOrderParams) orderRequest
- func NewStopLossBuy(symbol string, quantity float64, opts ...StopOrderParams) orderRequest
- func NewStopLossLimitBuy(symbol string, price float64, quantity float64, timeInForce TimeInForce, ...) orderRequest
- func NewStopLossLimitOrder(symbol string, side OrderSide, price float64, quantity float64, ...) orderRequest
- func NewStopLossLimitSell(symbol string, price float64, quantity float64, timeInForce TimeInForce, ...) orderRequest
- func NewStopLossOrder(symbol string, side OrderSide, quantity float64, opts ...StopOrderParams) orderRequest
- func NewStopLossSell(symbol string, quantity float64, opts ...StopOrderParams) orderRequest
- func NewTakeProfitBuy(symbol string, quantity float64, opts ...StopOrderParams) orderRequest
- func NewTakeProfitLimitBuy(symbol string, price float64, quantity float64, timeInForce TimeInForce, ...) orderRequest
- func NewTakeProfitLimitOrder(symbol string, side OrderSide, price float64, quantity float64, ...) orderRequest
- func NewTakeProfitLimitSell(symbol string, price float64, quantity float64, timeInForce TimeInForce, ...) orderRequest
- func NewTakeProfitOrder(symbol string, side OrderSide, quantity float64, opts ...StopOrderParams) orderRequest
- func NewTakeProfitSell(symbol string, quantity float64, opts ...StopOrderParams) orderRequest
- type Account
- type AccountCommission
- type AccountCommissionParams
- type AccountFilters
- type AccountFiltersParams
- type AccountParams
- type AccountTradesParam
- type AggTrade
- type AggTradeParams
- type AggTradeWebsocket
- type AllOrderListsParams
- type AllOrdersParams
- type Allocation
- type AllocationType
- type AllocationsParams
- type AssetFilterMaxAsset
- type AssetFilterType
- type AssetFilters
- type AveragePrice
- type AveragePriceWebsocket
- func (s AveragePriceWebsocket) Close()
- func (s AveragePriceWebsocket) ListSubscriptions() ([]string, Error)
- func (s AveragePriceWebsocket) ReadSubscriptions() []string
- func (apws *AveragePriceWebsocket) Subscribe(symbols ...string) Error
- func (apws *AveragePriceWebsocket) Unsubscribe(symbols ...string) Error
- type Balance
- type BalanceUpdateEvent
- type CancelOpenOrdersParams
- type CancelOrderParams
- type CancelOrderResult
- type CancelRestrictions
- type Candlestick
- type CandlestickParams
- type CandlesticksWebsocket
- func (s CandlesticksWebsocket) Close()
- func (s CandlesticksWebsocket) ListSubscriptions() ([]string, Error)
- func (s CandlesticksWebsocket) ReadSubscriptions() []string
- func (rpws *CandlesticksWebsocket) Subscribe(params ...WsCandlesticksParams) Error
- func (rpws *CandlesticksWebsocket) Unsubscribe(params ...WsCandlesticksParams) Error
- type Client
- func (c *Client) Account(opts ...AccountParams) (*Account, Response, Error)
- func (c *Client) AccountCommission(symbol string, opts ...AccountCommissionParams) (*AccountCommission, Response, Error)
- func (c *Client) AccountFilters(symbol string, opts ...AccountFiltersParams) (*AccountFilters, Response, Error)
- func (c *Client) AggTrade(symbol string, opts ...AggTradeParams) ([]*AggTrade, Response, Error)
- func (c *Client) AllOrderLists(opts ...AllOrderListsParams) ([]*OrderList, Response, Error)
- func (c *Client) AllOrders(symbol string, opts ...AllOrdersParams) ([]*Order, Response, Error)
- func (c *Client) Allocations(symbol string, opts ...AllocationsParams) ([]*Allocation, Response, Error)
- func (c *Client) AveragePrice(symbol string) (*AveragePrice, Response, Error)
- func (c *Client) CancelOpenOrders(symbol string, opts ...CancelOpenOrdersParams) ([]*Order, Response, Error)
- func (c *Client) CancelOrder(symbol string, orderId int64, opts ...CancelOrderParams) (*Order, Response, Error)
- func (c *Client) Candlesticks(symbol string, interval Interval, opts ...CandlestickParams) ([]*Candlestick, Response, Error)
- func (c *Client) ExchangeInfo(opts ...ExchangeInfoOption) (*ExchangeInfo, Response, Error)
- func (c *Client) HistoricalTrades(symbol string, opts ...HistoricalTradesParams) ([]*Trade, Response, Error)
- func (c *Client) MakeRequest(method RequestMethod, path string, params map[string]interface{}, ...) (Response, Error)
- func (c *Client) MiniTicker24h(symbol string, opts ...MiniTicker24hParams) (*MiniTicker24h, Response, Error)
- func (c *Client) MiniTickers24h(opts ...MiniTickers24hParams) ([]*MiniTicker24h, Response, Error)
- func (c *Client) OpenOrderLists(opts ...OpenOrderListsParams) ([]*OrderList, Response, Error)
- func (c *Client) OpenOrders(opts ...OpenOrdersParams) ([]*Order, Response, Error)
- func (c *Client) OpenOrdersBySymbol(symbol string, opts ...OpenOrdersBySymbolParams) ([]*Order, Response, Error)
- func (c *Client) Order(req orderRequest) (*Order, Response, Error)
- func (c *Client) OrderAmendments(symbol string, orderID int64, opts ...OrderAmendmentsParams) ([]*OrderAmendment, Response, Error)
- func (c *Client) OrderBook(symbol string, opts ...OrderBookParams) (*OrderBook, Response, Error)
- func (c *Client) OrderBookTicker(symbol string, opts ...OrderBookTickerParams) (*OrderBookTicker, Response, Error)
- func (c *Client) OrderBookTickers(opts ...OrderBookTickersParams) ([]*OrderBookTicker, Response, Error)
- func (c *Client) OrderListByClientOrderId(clientOrderId string, opts ...OrderListByClientOrderIDParams) (*OrderList, Response, Error)
- func (c *Client) OrderListByOrderListId(orderListID int64, opts ...OrderListByOrderIdParams) (*OrderList, Response, Error)
- func (c *Client) OrderSor(req orderRequest) (*Order, Response, Error)
- func (c *Client) OrderSorTest(req orderRequest, computeCommissionRates bool) (*OrderTest, Response, Error)
- func (c *Client) OrderTest(req orderRequest, computeCommissionRates bool) (*OrderTest, Response, Error)
- func (c *Client) Ping() (*Ping, Response, Error)
- func (c *Client) PreventedMatches(symbol string, opts ...PreventedMatchesParams) ([]*PreventedMatch, Response, Error)
- func (c *Client) PriceTicker(symbol string, opts ...PriceTickerParams) (*PriceTicker, Response, Error)
- func (c *Client) PriceTickers(opts ...PriceTickersParams) ([]*PriceTicker, Response, Error)
- func (c *Client) QueryExecutionRules(opts ...QueryExecutionRulesParams) (*QueryExecutionRules, Response, Error)
- func (c *Client) QueryOrder(symbol string, opts ...QueryOrderParams) (*Order, Response, Error)
- func (c *Client) RecentTrades(symbol string, opts ...RecentTradesParams) ([]*Trade, Response, Error)
- func (c *Client) ReferencePrice(symbol string) (*ReferencePrice, Response, Error)
- func (c *Client) ReferencePriceCalculation(symbol string, opts ...ReferencePriceCalculationParams) (*ReferencePriceCalculation, Response, Error)
- func (c *Client) RollingWindowMiniTicker(symbol string, opts ...RollingWindowTickerMiniParams) (*RollingWindowMiniTicker, Response, Error)
- func (c *Client) RollingWindowMiniTickers(opts ...RollingWindowMiniTickersParams) ([]*RollingWindowMiniTicker, Response, Error)
- func (c *Client) RollingWindowTicker(symbol string, opts ...RollingWindowTickerParams) (*RollingWindowTicker, Response, Error)
- func (c *Client) RollingWindowTickers(opts ...RollingWindowTickersParams) ([]*RollingWindowTicker, Response, Error)
- func (c *Client) ServerTime() (*ServerTime, Response, Error)
- func (c *Client) Ticker24h(symbol string, opts ...Ticker24hParams) (*Ticker24h, Response, Error)
- func (c *Client) Tickers24h(opts ...Tickers24hParams) ([]*Ticker24h, Response, Error)
- func (c *Client) Trades(symbol string, opts ...AccountTradesParam) ([]*Trade, Response, Error)
- func (c *Client) TradingDayMiniTicker(symbol string, opts ...TradingDayTickerParams) (*TradingDayMiniTicker, Response, Error)
- func (c *Client) TradingDayMiniTickers(opts ...TradingDayTickersParams) ([]*TradingDayMiniTicker, Response, Error)
- func (c *Client) TradingDayTicker(symbol string, opts ...TradingDayTickerParams) (*TradingDayTicker, Response, Error)
- func (c *Client) TradingDayTickers(opts ...TradingDayTickersParams) ([]*TradingDayTicker, Response, Error)
- func (c *Client) UIKlines(symbol string, interval Interval, opts ...CandlestickParams) ([]*Candlestick, Response, Error)
- func (c *Client) UnfilledOrderCount(opts ...UnfilledOrderCountParams) ([]*UnfilledOrderCount, Response, Error)
- func (c *Client) UserDataStream(cb func(ud UserDataEvent)) (*UserDataWebsocket, Error)
- func (c *Client) WebsocketAPI() (*WebsocketAPI, Error)
- type ClientOption
- type CommissionDiscount
- type CommissionRates
- type ContingencyType
- type DiffDepthWebsocket
- func (s DiffDepthWebsocket) Close()
- func (s DiffDepthWebsocket) ListSubscriptions() ([]string, Error)
- func (s DiffDepthWebsocket) ReadSubscriptions() []string
- func (dws *DiffDepthWebsocket) Subscribe(params ...WsDiffDepthParams) Error
- func (dws *DiffDepthWebsocket) Unsubscribe(params ...WsDiffDepthParams) Error
- type Error
- type EventStreamTerminatedEvent
- type EventType
- type ExchangeFilterMaxNumAlgoOrders
- type ExchangeFilterMaxNumIcebergOrders
- type ExchangeFilterMaxNumOrderLists
- type ExchangeFilterMaxNumOrders
- type ExchangeFilterType
- type ExchangeFilters
- type ExchangeInfo
- func (ei *ExchangeInfo) IsAlgoOrdersLimitHit(value int) bool
- func (ei *ExchangeInfo) IsIcebergOrdersLimitHit(value int) bool
- func (ei *ExchangeInfo) IsMaxNumOrderLists(value int) bool
- func (ei *ExchangeInfo) IsOrdersLimitHit(value int) bool
- func (ei *ExchangeInfo) IsRateLimitHit(value int, rateLimitType RateLimitType, interval RateLimitInterval, ...) bool
- type ExchangeInfoOption
- type ExecutionReportEvent
- type ExecutionRule
- type ExecutionType
- type ExternalLockUpdateEvent
- type Fill
- type HistoricalTradesParams
- type Interval
- type KeyPair
- type LimitMakerOrderParams
- type LimitMakerOrderRequest
- type LimitOrderParams
- type LimitOrderRequest
- type ListOrderStatus
- type ListStatusEvent
- type ListStatusOrder
- type ListStatusType
- type ManagedOrderBook
- type ManagedOrderBookHandler
- func (h *ManagedOrderBookHandler) Asks() []PriceLevel
- func (h *ManagedOrderBookHandler) AsksSorted(ascending bool) []PriceLevel
- func (h *ManagedOrderBookHandler) BestAsk() (PriceLevel, bool)
- func (h *ManagedOrderBookHandler) BestBid() (PriceLevel, bool)
- func (h *ManagedOrderBookHandler) Bids() []PriceLevel
- func (h *ManagedOrderBookHandler) BidsSorted(ascending bool) []PriceLevel
- func (h *ManagedOrderBookHandler) LastUpdateID() int64
- func (h *ManagedOrderBookHandler) RLock()
- func (h *ManagedOrderBookHandler) RUnlock()
- func (h *ManagedOrderBookHandler) Snapshot(sorted bool) ManagedOrderBook
- func (h *ManagedOrderBookHandler) SortPriceLevels(levels []PriceLevel, ascending bool)
- func (h *ManagedOrderBookHandler) Symbol() string
- type MarketOrderParams
- type MarketOrderRequest
- type MiniTicker24h
- type MiniTicker24hParams
- type MiniTickerWebsocket
- type MiniTickers24hParams
- type MiniTradingDayTickerParams
- type MiniTradingDayTickersParams
- type NewOrderResult
- type OpenOrderListsParams
- type OpenOrdersBySymbolParams
- type OpenOrdersParams
- type Order
- type OrderAmendment
- type OrderAmendmentsParams
- type OrderBook
- type OrderBookParams
- type OrderBookTicker
- type OrderBookTickerParams
- type OrderBookTickersParams
- type OrderBookWebsocket
- func (s OrderBookWebsocket) Close()
- func (s OrderBookWebsocket) ListSubscriptions() ([]string, Error)
- func (s OrderBookWebsocket) ReadSubscriptions() []string
- func (ows *OrderBookWebsocket) Subscribe(params ...WsOrderBookParams) Error
- func (ows *OrderBookWebsocket) Unsubscribe(params ...WsOrderBookParams) Error
- type OrderList
- type OrderListByClientOrderIDParams
- type OrderListByOrderIdParams
- type OrderListItem
- type OrderResponseType
- type OrderSide
- type OrderStatus
- type OrderTest
- type OrderType
- type OutboundAccountPositionEvent
- type PegOffsetType
- type PegPriceType
- type Permission
- type Ping
- type PreventedMatch
- type PreventedMatchesParams
- type PriceLevel
- type PriceTicker
- type PriceTickerParams
- type PriceTickersParams
- type QueryExecutionRules
- type QueryExecutionRulesParams
- type QueryOrderParams
- type RateLimit
- type RateLimitInterval
- type RateLimitType
- type RecentTradesParams
- type ReferencePrice
- type ReferencePriceCalculation
- type ReferencePriceCalculationParams
- type ReferencePriceCalculationType
- type ReferencePriceWebsocket
- func (s ReferencePriceWebsocket) Close()
- func (s ReferencePriceWebsocket) ListSubscriptions() ([]string, Error)
- func (s ReferencePriceWebsocket) ReadSubscriptions() []string
- func (rpws *ReferencePriceWebsocket) Subscribe(symbols ...string) Error
- func (rpws *ReferencePriceWebsocket) Unsubscribe(symbols ...string) Error
- type RequestMethod
- type Response
- type RollingWindowMiniTicker
- type RollingWindowMiniTickersParams
- type RollingWindowTicker
- type RollingWindowTickerMiniParams
- type RollingWindowTickerParams
- type RollingWindowTickerWebsocket
- func (s RollingWindowTickerWebsocket) Close()
- func (s RollingWindowTickerWebsocket) ListSubscriptions() ([]string, Error)
- func (s RollingWindowTickerWebsocket) ReadSubscriptions() []string
- func (rtws *RollingWindowTickerWebsocket) Subscribe(params ...WsRollingWindowParams) Error
- func (rtws *RollingWindowTickerWebsocket) Unsubscribe(params ...WsRollingWindowParams) Error
- type RollingWindowTickersParams
- type SORS
- type STPMode
- type SecurityType
- type ServerTime
- type StopLimitOrderParams
- type StopLimitOrderRequest
- type StopOrderParams
- type StopOrderRequest
- type Symbol
- type SymbolFilterIcebergParts
- type SymbolFilterLotSize
- type SymbolFilterMarketLotSize
- type SymbolFilterMaxNumAlgoOrders
- type SymbolFilterMaxNumIcebergOrders
- type SymbolFilterMaxNumOrderAmends
- type SymbolFilterMaxNumOrderLists
- type SymbolFilterMaxNumOrders
- type SymbolFilterMaxPosition
- type SymbolFilterMinNotional
- type SymbolFilterNotional
- type SymbolFilterPercentPrice
- type SymbolFilterPercentPriceBySide
- type SymbolFilterPriceFilter
- type SymbolFilterTrailingDelta
- type SymbolFilterType
- type SymbolFilters
- type SymbolRule
- type SymbolRulePriceRange
- type SymbolRules
- type SymbolStatus
- type Ticker24h
- type Ticker24hParams
- type TickerWebsocket
- type Tickers24hParams
- type TimeInForce
- type Trade
- type TradeWebsocket
- type TradingDayMiniTicker
- type TradingDayTicker
- type TradingDayTickerParams
- type TradingDayTickersParams
- type UnfilledOrderCount
- type UnfilledOrderCountParams
- type UserDataBalance
- type UserDataEvent
- type UserDataEventType
- type UserDataRawEvent
- type UserDataSubscribeResponse
- type UserDataWebsocket
- type WebsocketAPI
- func (wsapi *WebsocketAPI) Account(opts ...AccountParams) (*Account, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) AccountCommission(symbol string, opts ...AccountCommissionParams) (*AccountCommission, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) AggTrades(symbol string, opts ...AggTradeParams) ([]*AggTrade, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) AllOrders(symbol string, opts ...AllOrdersParams) ([]*Order, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) AveragePrice(symbol string) (*AveragePrice, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) BookTicker(symbol string, opts ...OrderBookTickerParams) (*OrderBookTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) BookTickers(opts ...OrderBookTickersParams) ([]*OrderBookTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) CancelOpenOrders(symbol string, opts ...CancelOpenOrdersParams) ([]*Order, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) CancelOrder(symbol string, orderId int64, opts ...CancelOrderParams) (*Order, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) Candlesticks(symbol string, interval Interval, opts ...CandlestickParams) ([]*Candlestick, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) Close()
- func (wsapi *WebsocketAPI) HistoricalTrades(symbol string, opts ...HistoricalTradesParams) ([]*Trade, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) MiniTicker24h(symbol string, opts ...MiniTicker24hParams) (*MiniTicker24h, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) MiniTickers24h(opts ...MiniTickers24hParams) ([]*MiniTicker24h, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) OpenOrders(opts ...OpenOrdersParams) ([]*Order, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) OrderBook(symbol string, opts ...OrderBookParams) (*OrderBook, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) PlaceOrder(req orderRequest) (*Order, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) PlaceSorOrder(req orderRequest) (*Order, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) PriceTicker(symbol string, opts ...PriceTickerParams) (*PriceTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) PriceTickers(opts ...PriceTickersParams) ([]*PriceTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) QueryOrder(symbol string, opts ...QueryOrderParams) (*Order, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) RecentTrades(symbol string, opts ...RecentTradesParams) ([]*Trade, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) ReferencePrice(symbol string) (*ReferencePrice, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) ReferencePriceCalculation(symbol string, opts ...ReferencePriceCalculationParams) (*ReferencePriceCalculation, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) RollingWindowMiniTicker(symbol string, opts ...RollingWindowTickerMiniParams) (*RollingWindowMiniTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) RollingWindowMiniTickers(opts ...RollingWindowMiniTickersParams) ([]*RollingWindowMiniTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) RollingWindowTicker(symbol string, opts ...RollingWindowTickerParams) (*RollingWindowTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) RollingWindowTickers(opts ...RollingWindowTickersParams) ([]*RollingWindowTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) TestOrder(req orderRequest, computeCommissionRates bool) (*OrderTest, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) TestSorOrder(req orderRequest, computeCommissionRates bool) (*OrderTest, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) Ticker24h(symbol string, opts ...Ticker24hParams) (*Ticker24h, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) Tickers24h(opts ...Tickers24hParams) ([]*Ticker24h, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) Trades(symbol string, opts ...AccountTradesParam) ([]*Trade, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) TradingDayMiniTicker(symbol string, opts ...TradingDayTickerParams) (*TradingDayMiniTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) TradingDayMiniTickers(opts ...TradingDayTickersParams) ([]*TradingDayMiniTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) TradingDayTicker(symbol string, opts ...TradingDayTickerParams) (*TradingDayTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) TradingDayTickers(opts ...TradingDayTickersParams) ([]*TradingDayTicker, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) UIKlines(symbol string, interval Interval, opts ...CandlestickParams) ([]*Candlestick, *WsApiResponse, Error)
- func (wsapi *WebsocketAPI) UnfilledOrderCount(opts ...UnfilledOrderCountParams) ([]*UnfilledOrderCount, *WsApiResponse, Error)
- type WorkingFloor
- type WsAggTrade
- type WsApiError
- type WsApiResponse
- type WsAveragePrice
- type WsCandlestick
- type WsCandlesticksInterval
- type WsCandlesticksParams
- type WsDiffDepth
- type WsDiffDepthInterval
- type WsDiffDepthParams
- type WsKline
- type WsMiniTicker
- type WsOrderBook
- type WsOrderBookParams
- type WsReferencePrice
- type WsRollingWindowParams
- type WsRollingWindowTicker
- type WsTicker
- type WsTrade
Constants ¶
This section is empty.
Variables ¶
var ( UNKNOWN = newErrorCode(-1000, []string{"An unknown error occurred while processing the request."}) DISCONNECTED = newErrorCode(-1001, []string{"Internal error; unable to process your request. Please try again."}) UNAUTHORIZED = newErrorCode(-1002, []string{"You are not authorized to execute this request."}) TOO_MANY_REQUESTS = newErrorCode(-1003, []string{"Too many requests queued.", "Too much request weight used; current limit is %s request weight per %s. Please use WebSocket Streams for live updates to avoid polling the API.", "Way too much request weight used; IP banned until %s. Please use WebSocket Streams for live updates to avoid bans."}) UNEXPECTED_RESP = newErrorCode(-1006, []string{"An unexpected response was received from the message bus. Execution status unknown."}) TIMEOUT = newErrorCode(-1007, []string{"Timeout waiting for response from backend server. Send status unknown; execution status unknown."}) SERVER_BUSY = newErrorCode(-1008, []string{"Server is currently overloaded with other requests. Please try again in a few minutes."}) INVALID_MESSAGE = newErrorCode(-1013, []string{"The request is rejected by the API. (i.e. The request didn't reach the Matching Engine.)", "Potential error messages can be found in Filter Failures or Failures during order placement."}) UNKNOWN_ORDER_COMPOSITION = newErrorCode(-1014, []string{"Unsupported order combination."}) TOO_MANY_ORDERS = newErrorCode(-1015, []string{"Too many new orders.", "Too many new orders; current limit is %s orders per %s."}) SERVICE_SHUTTING_DOWN = newErrorCode(-1016, []string{"This service is no longer available."}) UNSUPPORTED_OPERATION = newErrorCode(-1020, []string{"This operation is not supported."}) INVALID_TIMESTAMP = newErrorCode(-1021, []string{"Timestamp for this request is outside of the recvWindow.", "Timestamp for this request was 1000ms ahead of the server's time."}) INVALID_SIGNATURE = newErrorCode(-1022, []string{"Signature for this request is not valid."}) COMP_ID_IN_USE = newErrorCode(-1033, []string{"SenderCompId(49) is currently in use. Concurrent use of the same SenderCompId within one account is not allowed."}) TOO_MANY_CONNECTIONS = newErrorCode(-1034, []string{"Too many concurrent connections; current limit is '%s'.", "Too many connection attempts for account; current limit is %s per '%s'.", "Too many connection attempts from IP; current limit is %s per '%s'."}) LOGGED_OUT = newErrorCode(-1035, []string{"Please send Logout<5> message to close the session."}) ILLEGAL_CHARS = newErrorCode(-1100, []string{"Illegal characters found in a parameter.", "Illegal characters found in parameter '%s'; legal range is '%s'."}) TOO_MANY_PARAMETERS = newErrorCode(-1101, []string{"Too many parameters sent for this endpoint.", "Too many parameters; expected '%s' and received '%s'.", "Duplicate values for a parameter detected."}) MANDATORY_PARAM_EMPTY_OR_MALFORMED = newErrorCode(-1102, []string{"A mandatory parameter was not sent, was empty/null, or malformed.", "Mandatory parameter '%s' was not sent, was empty/null, or malformed.", "Param '%s' or '%s' must be sent, but both were empty/null!", "Required tag '%s' missing.", "Field value was empty or malformed.", "'%s' contains unexpected value. Cannot be greater than %s."}) UNKNOWN_PARAM = newErrorCode(-1103, []string{"An unknown parameter was sent.", "Undefined Tag."}) UNREAD_PARAMETERS = newErrorCode(-1104, []string{"Not all sent parameters were read.", "Not all sent parameters were read; read '%s' parameter(s) but was sent '%s'."}) PARAM_EMPTY = newErrorCode(-1105, []string{"A parameter was empty.", "Parameter '%s' was empty."}) PARAM_NOT_REQUIRED = newErrorCode(-1106, []string{"A parameter was sent when not required.", "Parameter '%s' sent when not required.", "A tag '%s' was sent when not required."}) PARAM_OVERFLOW = newErrorCode(-1108, []string{"Parameter '%s' overflowed."}) BAD_PRECISION = newErrorCode(-1111, []string{"Parameter '%s' has too much precision."}) NO_DEPTH = newErrorCode(-1112, []string{"No orders on book for symbol."}) TIF_NOT_REQUIRED = newErrorCode(-1114, []string{"TimeInForce parameter sent when not required."}) INVALID_TIF = newErrorCode(-1115, []string{"Invalid timeInForce."}) INVALID_ORDER_TYPE = newErrorCode(-1116, []string{"Invalid orderType."}) INVALID_SIDE = newErrorCode(-1117, []string{"Invalid side."}) EMPTY_NEW_CL_ORD_ID = newErrorCode(-1118, []string{"New client order ID was empty."}) EMPTY_ORG_CL_ORD_ID = newErrorCode(-1119, []string{"Original client order ID was empty."}) BAD_INTERVAL = newErrorCode(-1120, []string{"Invalid interval."}) BAD_SYMBOL = newErrorCode(-1121, []string{"Invalid symbol."}) INVALID_SYMBOLSTATUS = newErrorCode(-1122, []string{"Invalid symbolStatus."}) INVALID_LISTEN_KEY = newErrorCode(-1125, []string{"This listenKey does not exist."}) MORE_THAN_XX_HOURS = newErrorCode(-1127, []string{"Lookup interval is too big.", "More than %s hours between startTime and endTime."}) OPTIONAL_PARAMS_BAD_COMBO = newErrorCode(-1128, []string{"Combination of optional parameters invalid.", "Combination of optional fields invalid. Recommendation: '%s' and '%s' must both be sent.", "Fields [%s] must be sent together or omitted entirely.", "Invalid MDEntryType (269) combination. BID and OFFER must be requested together."}) INVALID_PARAMETER = newErrorCode(-1130, []string{"Invalid data sent for a parameter.", "Data sent for parameter '%s' is not valid."}) BAD_STRATEGY_TYPE = newErrorCode(-1134, []string{"strategyType was less than 1000000.", "TargetStrategy (847) was less than 1000000."}) INVALID_JSON = newErrorCode(-1135, []string{"Invalid JSON Request", "JSON sent for parameter '%s' is not valid"}) INVALID_TICKER_TYPE = newErrorCode(-1139, []string{"Invalid ticker type."}) INVALID_CANCEL_RESTRICTIONS = newErrorCode(-1145, []string{"cancelRestrictions has to be either ONLY_NEW or ONLY_PARTIALLY_FILLED."}) DUPLICATE_SYMBOLS = newErrorCode(-1151, []string{"Symbol is present multiple times in the list."}) INVALID_SBE_HEADER = newErrorCode(-1152, []string{"Invalid X-MBX-SBE header; expected <SCHEMA_ID>:<VERSION>."}) UNSUPPORTED_SCHEMA_ID = newErrorCode(-1153, []string{"Unsupported SBE schema ID or version specified in the X-MBX-SBE header."}) SBE_DISABLED = newErrorCode(-1155, []string{"SBE is not enabled."}) OCO_ORDER_TYPE_REJECTED = newErrorCode(-1158, []string{"Order type not supported in OCO.", "If the order type provided in the aboveType and/or belowType is not supported."}) OCO_ICEBERGQTY_TIMEINFORCE = newErrorCode(-1160, []string{"Parameter '%s' is not supported if aboveTimeInForce/belowTimeInForce is not GTC.", "If the order type for the above or below leg is STOP_LOSS_LIMIT, and icebergQty is provided for that leg, the timeInForce has to be GTC else it will throw an error.", "TimeInForce (59) must be GTC (1) when MaxFloor (111) is used."}) DEPRECATED_SCHEMA = newErrorCode(-1161, []string{"Unable to encode the response in SBE schema 'x'. Please use schema 'y' or higher."}) BUY_OCO_LIMIT_MUST_BE_BELOW = newErrorCode(-1165, []string{"A limit order in a buy OCO must be below."}) SELL_OCO_LIMIT_MUST_BE_ABOVE = newErrorCode(-1166, []string{"A limit order in a sell OCO must be above."}) BOTH_OCO_ORDERS_CANNOT_BE_LIMIT = newErrorCode(-1168, []string{"At least one OCO order must be contingent."}) INVALID_TAG_NUMBER = newErrorCode(-1169, []string{"Invalid tag number."}) TAG_NOT_DEFINED_IN_MESSAGE = newErrorCode(-1170, []string{"Tag '%s' not defined for this message type."}) TAG_APPEARS_MORE_THAN_ONCE = newErrorCode(-1171, []string{"Tag '%s' appears more than once."}) TAG_OUT_OF_ORDER = newErrorCode(-1172, []string{"Tag '%s' specified out of required order."}) GROUP_FIELDS_OUT_OF_ORDER = newErrorCode(-1173, []string{"Repeating group '%s' fields out of order."}) INVALID_COMPONENT = newErrorCode(-1174, []string{"Component '%s' is incorrectly populated on '%s' order. Recommendation: '%s'"}) RESET_SEQ_NUM_SUPPORT = newErrorCode(-1175, []string{"Continuation of sequence numbers to new session is currently unsupported. Sequence numbers must be reset for each new session."}) ALREADY_LOGGED_IN = newErrorCode(-1176, []string{"Logon<A> should only be sent once."}) GARBLED_MESSAGE = newErrorCode(-1177, []string{"CheckSum(10) contains an incorrect value.", "BeginString (8) is not the first tag in a message.", "MsgType (35) is not the third tag in a message.", "BodyLength (9) does not contain the correct byte count.", "Only printable ASCII characters and SOH (Start of Header) are allowed."}) BAD_SENDER_COMPID = newErrorCode(-1178, []string{"SenderCompId(49) contains an incorrect value. The SenderCompID value should not change throughout the lifetime of a session."}) BAD_SEQ_NUM = newErrorCode(-1179, []string{"MsgSeqNum(34) contains an unexpected value. Expected: '%d'."}) EXPECTED_LOGON = newErrorCode(-1180, []string{"Logon<A> must be the first message in the session."}) TOO_MANY_MESSAGES = newErrorCode(-1181, []string{"Too many messages; current limit is '%d' messages per '%s'."}) PARAMS_BAD_COMBO = newErrorCode(-1182, []string{"Conflicting fields: [%s]"}) NOT_ALLOWED_IN_DROP_COPY_SESSIONS = newErrorCode(-1183, []string{"Requested operation is not allowed in DropCopy sessions."}) DROP_COPY_SESSION_NOT_ALLOWED = newErrorCode(-1184, []string{"DropCopy sessions are not supported on this server. Please reconnect to a drop copy server."}) DROP_COPY_SESSION_REQUIRED = newErrorCode(-1185, []string{"Only DropCopy sessions are supported on this server. Either reconnect to order entry server or send DropCopyFlag (9406) field."}) NOT_ALLOWED_IN_ORDER_ENTRY_SESSIONS = newErrorCode(-1186, []string{"Requested operation is not allowed in order entry sessions."}) NOT_ALLOWED_IN_MARKET_DATA_SESSIONS = newErrorCode(-1187, []string{"Requested operation is not allowed in market data sessions."}) INCORRECT_NUM_IN_GROUP_COUNT = newErrorCode(-1188, []string{"Incorrect NumInGroup count for repeating group '%s'."}) DUPLICATE_ENTRIES_IN_A_GROUP = newErrorCode(-1189, []string{"Group '%s' contains duplicate entries."}) INVALID_REQUEST_ID = newErrorCode(-1190, []string{"MDReqID (262) contains a subscription request id that is already in use on this connection.", "MDReqID (262) contains an unsubscription request id that does not match any active subscription."}) TOO_MANY_SUBSCRIPTIONS = newErrorCode(-1191, []string{"Too many subscriptions. Connection may create up to '%s' subscriptions at a time.", "Similar subscription is already active on this connection. Symbol='%s', active subscription id: '%s'."}) INVALID_TIME_UNIT = newErrorCode(-1194, []string{"Invalid value for time unit; expected either MICROSECOND or MILLISECOND."}) BUY_OCO_STOP_LOSS_MUST_BE_ABOVE = newErrorCode(-1196, []string{"A stop loss order in a buy OCO must be above."}) SELL_OCO_STOP_LOSS_MUST_BE_BELOW = newErrorCode(-1197, []string{"A stop loss order in a sell OCO must be below."}) BUY_OCO_TAKE_PROFIT_MUST_BE_BELOW = newErrorCode(-1198, []string{"A take profit order in a buy OCO must be below."}) SELL_OCO_TAKE_PROFIT_MUST_BE_ABOVE = newErrorCode(-1199, []string{"A take profit order in a sell OCO must be above."}) NEW_ORDER_REJECTED = newErrorCode(-2010, []string{"NEW_ORDER_REJECTED"}) CANCEL_REJECTED = newErrorCode(-2011, []string{"CANCEL_REJECTED"}) NO_SUCH_ORDER = newErrorCode(-2013, []string{"Order does not exist."}) BAD_API_KEY_FMT = newErrorCode(-2014, []string{"API-key format invalid."}) REJECTED_MBX_KEY = newErrorCode(-2015, []string{"Invalid API-key, IP, or permissions for action."}) NO_TRADING_WINDOW = newErrorCode(-2016, []string{"No trading window could be found for the symbol. Try ticker/24hrs instead."}) ORDER_ARCHIVED = newErrorCode(-2026, []string{"Order was canceled or expired with no executed qty over 90 days ago and has been archived."}) SUBSCRIPTION_ACTIVE = newErrorCode(-2035, []string{"User Data Stream subscription already active."}) SUBSCRIPTION_INACTIVE = newErrorCode(-2036, []string{"User Data Stream subscription not active."}) )
var APIKEY = apikey.Builder
APIKEY provides helper constructors for creating different types of Binance API authentication key pairs.
Binance supports multiple authentication schemes depending on the API features being used. The builder exposes convenience methods to create the appropriate KeyPair implementation for each supported scheme.
Each method returns a type implementing the KeyPair interface, which is later used by the client to sign authenticated requests.
var Constants = constants{
BaseUrls: baseUrls{
Api: "https://api.binance.com",
Api_gcp: "https://api-gcp.binance.com",
Api1: "https://api1.binance.com",
Api2: "https://api2.binance.com",
Api3: "https://api3.binance.com",
Api4: "https://api4.binance.com",
Testnet: "https://testnet.binance.vision",
Testnet1: "https://api1.testnet.binance.vision",
Demo: "https://demo-api.binance.com",
},
BaseUrlsMarketData: baseUrlsMarketData{
DataApiVision: "https://data-api.binance.vision",
},
WssBaseUrlsMarketData: wssBaseUrlsMarketData{
DataStreamBinanceVision: "wss://data-stream.binance.vision",
},
WssBaseUrls: wssBaseUrls{
Stream443: "wss://stream.binance.com:443",
Stream9443: "wss://stream.binance.com:9443",
Testnet: "wss://stream.testnet.binance.vision",
Testnet9443: "wss://stream.testnet.binance.vision:9443",
},
WssApiBaseUrls: wssApiBaseUrls{
WsApi: "wss://ws-api.binance.com:443/ws-api/v3",
WsApi9443: "wss://ws-api.binance.com:9443/ws-api/v3",
},
}
var ErrorCodes = errorCodeNames{ UNKNOWN: UNKNOWN, DISCONNECTED: DISCONNECTED, UNAUTHORIZED: UNAUTHORIZED, TOO_MANY_REQUESTS: TOO_MANY_REQUESTS, UNEXPECTED_RESP: UNEXPECTED_RESP, TIMEOUT: TIMEOUT, SERVER_BUSY: SERVER_BUSY, INVALID_MESSAGE: INVALID_MESSAGE, UNKNOWN_ORDER_COMPOSITION: UNKNOWN_ORDER_COMPOSITION, TOO_MANY_ORDERS: TOO_MANY_ORDERS, SERVICE_SHUTTING_DOWN: SERVICE_SHUTTING_DOWN, UNSUPPORTED_OPERATION: UNSUPPORTED_OPERATION, INVALID_TIMESTAMP: INVALID_TIMESTAMP, INVALID_SIGNATURE: INVALID_SIGNATURE, COMP_ID_IN_USE: COMP_ID_IN_USE, TOO_MANY_CONNECTIONS: TOO_MANY_CONNECTIONS, LOGGED_OUT: LOGGED_OUT, ILLEGAL_CHARS: ILLEGAL_CHARS, TOO_MANY_PARAMETERS: TOO_MANY_PARAMETERS, MANDATORY_PARAM_EMPTY_OR_MALFORMED: MANDATORY_PARAM_EMPTY_OR_MALFORMED, UNKNOWN_PARAM: UNKNOWN_PARAM, UNREAD_PARAMETERS: UNREAD_PARAMETERS, PARAM_EMPTY: PARAM_EMPTY, PARAM_NOT_REQUIRED: PARAM_NOT_REQUIRED, PARAM_OVERFLOW: PARAM_OVERFLOW, BAD_PRECISION: BAD_PRECISION, NO_DEPTH: NO_DEPTH, TIF_NOT_REQUIRED: TIF_NOT_REQUIRED, INVALID_TIF: INVALID_TIF, INVALID_ORDER_TYPE: INVALID_ORDER_TYPE, INVALID_SIDE: INVALID_SIDE, EMPTY_NEW_CL_ORD_ID: EMPTY_NEW_CL_ORD_ID, EMPTY_ORG_CL_ORD_ID: EMPTY_ORG_CL_ORD_ID, BAD_INTERVAL: BAD_INTERVAL, BAD_SYMBOL: BAD_SYMBOL, INVALID_SYMBOLSTATUS: INVALID_SYMBOLSTATUS, INVALID_LISTEN_KEY: INVALID_LISTEN_KEY, MORE_THAN_XX_HOURS: MORE_THAN_XX_HOURS, OPTIONAL_PARAMS_BAD_COMBO: OPTIONAL_PARAMS_BAD_COMBO, INVALID_PARAMETER: INVALID_PARAMETER, BAD_STRATEGY_TYPE: BAD_STRATEGY_TYPE, INVALID_JSON: INVALID_JSON, INVALID_TICKER_TYPE: INVALID_TICKER_TYPE, INVALID_CANCEL_RESTRICTIONS: INVALID_CANCEL_RESTRICTIONS, DUPLICATE_SYMBOLS: DUPLICATE_SYMBOLS, INVALID_SBE_HEADER: INVALID_SBE_HEADER, UNSUPPORTED_SCHEMA_ID: UNSUPPORTED_SCHEMA_ID, SBE_DISABLED: SBE_DISABLED, OCO_ORDER_TYPE_REJECTED: OCO_ORDER_TYPE_REJECTED, OCO_ICEBERGQTY_TIMEINFORCE: OCO_ICEBERGQTY_TIMEINFORCE, DEPRECATED_SCHEMA: DEPRECATED_SCHEMA, BUY_OCO_LIMIT_MUST_BE_BELOW: BUY_OCO_LIMIT_MUST_BE_BELOW, SELL_OCO_LIMIT_MUST_BE_ABOVE: SELL_OCO_LIMIT_MUST_BE_ABOVE, BOTH_OCO_ORDERS_CANNOT_BE_LIMIT: BOTH_OCO_ORDERS_CANNOT_BE_LIMIT, INVALID_TAG_NUMBER: INVALID_TAG_NUMBER, TAG_NOT_DEFINED_IN_MESSAGE: TAG_NOT_DEFINED_IN_MESSAGE, TAG_APPEARS_MORE_THAN_ONCE: TAG_APPEARS_MORE_THAN_ONCE, TAG_OUT_OF_ORDER: TAG_OUT_OF_ORDER, GROUP_FIELDS_OUT_OF_ORDER: GROUP_FIELDS_OUT_OF_ORDER, INVALID_COMPONENT: INVALID_COMPONENT, RESET_SEQ_NUM_SUPPORT: RESET_SEQ_NUM_SUPPORT, ALREADY_LOGGED_IN: ALREADY_LOGGED_IN, GARBLED_MESSAGE: GARBLED_MESSAGE, BAD_SENDER_COMPID: BAD_SENDER_COMPID, BAD_SEQ_NUM: BAD_SEQ_NUM, EXPECTED_LOGON: EXPECTED_LOGON, TOO_MANY_MESSAGES: TOO_MANY_MESSAGES, PARAMS_BAD_COMBO: PARAMS_BAD_COMBO, NOT_ALLOWED_IN_DROP_COPY_SESSIONS: NOT_ALLOWED_IN_DROP_COPY_SESSIONS, DROP_COPY_SESSION_NOT_ALLOWED: DROP_COPY_SESSION_NOT_ALLOWED, DROP_COPY_SESSION_REQUIRED: DROP_COPY_SESSION_REQUIRED, NOT_ALLOWED_IN_ORDER_ENTRY_SESSIONS: NOT_ALLOWED_IN_ORDER_ENTRY_SESSIONS, NOT_ALLOWED_IN_MARKET_DATA_SESSIONS: NOT_ALLOWED_IN_MARKET_DATA_SESSIONS, INCORRECT_NUM_IN_GROUP_COUNT: INCORRECT_NUM_IN_GROUP_COUNT, DUPLICATE_ENTRIES_IN_A_GROUP: DUPLICATE_ENTRIES_IN_A_GROUP, INVALID_REQUEST_ID: INVALID_REQUEST_ID, TOO_MANY_SUBSCRIPTIONS: TOO_MANY_SUBSCRIPTIONS, INVALID_TIME_UNIT: INVALID_TIME_UNIT, BUY_OCO_STOP_LOSS_MUST_BE_ABOVE: BUY_OCO_STOP_LOSS_MUST_BE_ABOVE, SELL_OCO_STOP_LOSS_MUST_BE_BELOW: SELL_OCO_STOP_LOSS_MUST_BE_BELOW, BUY_OCO_TAKE_PROFIT_MUST_BE_BELOW: BUY_OCO_TAKE_PROFIT_MUST_BE_BELOW, SELL_OCO_TAKE_PROFIT_MUST_BE_ABOVE: SELL_OCO_TAKE_PROFIT_MUST_BE_ABOVE, NEW_ORDER_REJECTED: NEW_ORDER_REJECTED, CANCEL_REJECTED: CANCEL_REJECTED, NO_SUCH_ORDER: NO_SUCH_ORDER, BAD_API_KEY_FMT: BAD_API_KEY_FMT, REJECTED_MBX_KEY: REJECTED_MBX_KEY, NO_TRADING_WINDOW: NO_TRADING_WINDOW, ORDER_ARCHIVED: ORDER_ARCHIVED, SUBSCRIPTION_ACTIVE: SUBSCRIPTION_ACTIVE, SUBSCRIPTION_INACTIVE: SUBSCRIPTION_INACTIVE, }
var Methods = requests.Methods
Functions ¶
func New ¶
func New(opts ...ClientOption) (*Client, Error)
func NewLimitBuy ¶
func NewLimitBuy(symbol string, price float64, quantity float64, timeInForce TimeInForce, opts ...LimitOrderParams) orderRequest
func NewLimitMakerBuy ¶
func NewLimitMakerBuy(symbol string, price float64, quantity float64, opts ...LimitMakerOrderParams) orderRequest
func NewLimitMakerOrder ¶
func NewLimitMakerOrder(symbol string, side OrderSide, price float64, quantity float64, opts ...LimitMakerOrderParams) orderRequest
func NewLimitMakerSell ¶
func NewLimitMakerSell(symbol string, price float64, quantity float64, opts ...LimitMakerOrderParams) orderRequest
func NewLimitOrder ¶
func NewLimitOrder(symbol string, side OrderSide, price float64, quantity float64, timeInForce TimeInForce, opts ...LimitOrderParams) orderRequest
func NewLimitSell ¶
func NewLimitSell(symbol string, price float64, quantity float64, timeInForce TimeInForce, opts ...LimitOrderParams) orderRequest
func NewMarketBuy ¶
func NewMarketBuy(symbol string, quantity float64, opts ...MarketOrderParams) orderRequest
func NewMarketOrder ¶
func NewMarketOrder(symbol string, side OrderSide, quantity float64, opts ...MarketOrderParams) orderRequest
func NewMarketSell ¶
func NewMarketSell(symbol string, quantity float64, opts ...MarketOrderParams) orderRequest
func NewStopLossBuy ¶
func NewStopLossBuy(symbol string, quantity float64, opts ...StopOrderParams) orderRequest
func NewStopLossLimitBuy ¶
func NewStopLossLimitBuy(symbol string, price float64, quantity float64, timeInForce TimeInForce, opts ...StopLimitOrderParams) orderRequest
func NewStopLossLimitOrder ¶
func NewStopLossLimitOrder(symbol string, side OrderSide, price float64, quantity float64, timeInForce TimeInForce, opts ...StopLimitOrderParams) orderRequest
func NewStopLossLimitSell ¶
func NewStopLossLimitSell(symbol string, price float64, quantity float64, timeInForce TimeInForce, opts ...StopLimitOrderParams) orderRequest
func NewStopLossOrder ¶
func NewStopLossOrder(symbol string, side OrderSide, quantity float64, opts ...StopOrderParams) orderRequest
func NewStopLossSell ¶
func NewStopLossSell(symbol string, quantity float64, opts ...StopOrderParams) orderRequest
func NewTakeProfitBuy ¶
func NewTakeProfitBuy(symbol string, quantity float64, opts ...StopOrderParams) orderRequest
func NewTakeProfitLimitBuy ¶
func NewTakeProfitLimitBuy(symbol string, price float64, quantity float64, timeInForce TimeInForce, opts ...StopLimitOrderParams) orderRequest
func NewTakeProfitLimitOrder ¶
func NewTakeProfitLimitOrder(symbol string, side OrderSide, price float64, quantity float64, timeInForce TimeInForce, opts ...StopLimitOrderParams) orderRequest
func NewTakeProfitLimitSell ¶
func NewTakeProfitLimitSell(symbol string, price float64, quantity float64, timeInForce TimeInForce, opts ...StopLimitOrderParams) orderRequest
func NewTakeProfitOrder ¶
func NewTakeProfitOrder(symbol string, side OrderSide, quantity float64, opts ...StopOrderParams) orderRequest
func NewTakeProfitSell ¶
func NewTakeProfitSell(symbol string, quantity float64, opts ...StopOrderParams) orderRequest
Types ¶
type Account ¶
type Account struct {
MakerCommission int64 `json:"makerCommission"`
TakerCommission int64 `json:"takerCommission"`
BuyerCommission int64 `json:"buyerCommission"`
SellerCommission int64 `json:"sellerCommission"`
CommissionRates CommissionRates `json:"commissionRates"`
CanTrade bool `json:"canTrade"`
CanWithdraw bool `json:"canWithdraw"`
CanDeposit bool `json:"canDeposit"`
Brokered bool `json:"brokered"`
RequireSelfTradePrevention bool `json:"requireSelfTradePrevention"`
PreventSor bool `json:"preventSor"`
UpdateTime int64 `json:"updateTime"`
AccountType string `json:"accountType"`
Balances []Balance `json:"balances"`
Permissions []Permission `json:"permissions"`
UID int64 `json:"uid"`
}
Account
type AccountCommission ¶
type AccountCommission struct {
Symbol string `json:"symbol"`
StandardCommission CommissionRates `json:"standardCommission"`
SpecialCommission CommissionRates `json:"specialCommission"`
TaxCommission CommissionRates `json:"taxCommission"`
Discount CommissionDiscount `json:"discount"`
}
func (AccountCommission) EffectiveMakerRate ¶
func (a AccountCommission) EffectiveMakerRate() float64
EffectiveMakerRate calculates the effective maker rate by applying the discounts if applied
func (AccountCommission) EffectiveTakerRate ¶
func (a AccountCommission) EffectiveTakerRate() float64
EffectiveTakerRate calculates the effective maker rate by applying the discounts if applied
type AccountCommissionParams ¶
type AccountCommissionParams struct {
RecvWindow int
}
type AccountFilters ¶
type AccountFilters struct {
ExchangeFilters ExchangeFilters `json:"exchangeFilters"`
SymbolFilters SymbolFilters `json:"symbolFilters"`
AssetFilters AssetFilters `json:"assetFilters"`
}
type AccountFiltersParams ¶
type AccountFiltersParams struct {
RecvWindow int
}
type AccountParams ¶
type AccountTradesParam ¶
type AggTrade ¶
type AggTrade struct {
// Aggregate tradeId
AggTradeId int64 `json:"a"`
// Price
Price float64 `json:"p,string"`
// Quantity
Quantity float64 `json:"q,string"`
// First tradeId
FirstTradeId int64 `json:"f"`
// Last tradeId
LastTradeId int64 `json:"l"`
// Timestamp
Timestamp int64 `json:"T"`
// Was the buyer the maker?
IsMaker bool `json:"m"`
// Was the trade the best price match?
IsBestMatch bool `json:"M"`
}
type AggTradeParams ¶
type AggTradeWebsocket ¶
type AggTradeWebsocket struct {
// contains filtered or unexported fields
}
func (AggTradeWebsocket) ListSubscriptions ¶
func (AggTradeWebsocket) ReadSubscriptions ¶
func (s AggTradeWebsocket) ReadSubscriptions() []string
func (*AggTradeWebsocket) Subscribe ¶
func (rpws *AggTradeWebsocket) Subscribe(symbols ...string) Error
func (*AggTradeWebsocket) Unsubscribe ¶
func (rpws *AggTradeWebsocket) Unsubscribe(symbols ...string) Error
type AllOrderListsParams ¶
type AllOrderListsParams struct {
FromID int64
StartTime int64
EndTime int64
Limit int
RecvWindow int
}
func (AllOrderListsParams) Validate ¶
func (p AllOrderListsParams) Validate() error
type AllOrdersParams ¶
type Allocation ¶
type Allocation struct {
Symbol string `json:"symbol"`
AllocationID int64 `json:"allocationId"`
AllocationType AllocationType `json:"allocationType"`
OrderID int64 `json:"orderId"`
OrderListID int64 `json:"orderListId"`
Price float64 `json:"price,string"`
Qty float64 `json:"qty,string"`
QuoteQty float64 `json:"quoteQty,string"`
Commission float64 `json:"commission,string"`
CommissionAsset string `json:"commissionAsset"`
Time int64 `json:"time"`
IsBuyer bool `json:"isBuyer"`
IsMaker bool `json:"isMaker"`
IsAllocator bool `json:"isAllocator"`
}
type AllocationsParams ¶
type AssetFilterMaxAsset ¶
type AssetFilterType ¶
type AssetFilterType string
const (
MAX_ASSET AssetFilterType = "MAX_ASSET"
)
type AssetFilters ¶
type AssetFilters struct {
MAX_ASSET *AssetFilterMaxAsset
}
func (*AssetFilters) UnmarshalJSON ¶
func (assetFilters *AssetFilters) UnmarshalJSON(data []byte) error
type AveragePrice ¶
type AveragePriceWebsocket ¶
type AveragePriceWebsocket struct {
// contains filtered or unexported fields
}
func (AveragePriceWebsocket) ListSubscriptions ¶
func (AveragePriceWebsocket) ReadSubscriptions ¶
func (s AveragePriceWebsocket) ReadSubscriptions() []string
func (*AveragePriceWebsocket) Subscribe ¶
func (apws *AveragePriceWebsocket) Subscribe(symbols ...string) Error
func (*AveragePriceWebsocket) Unsubscribe ¶
func (apws *AveragePriceWebsocket) Unsubscribe(symbols ...string) Error
type BalanceUpdateEvent ¶
type BalanceUpdateEvent struct {
EventType UserDataEventType `json:"e"`
EventTime int64 `json:"E"`
Asset string `json:"a"`
Delta string `json:"d"`
ClearTime int64 `json:"T"`
}
type CancelOpenOrdersParams ¶
type CancelOpenOrdersParams struct {
RecvWindow int
}
type CancelOrderParams ¶
type CancelOrderParams struct {
OrigClientOrderId string
NewClientOrderId string
CancelRestrictions CancelRestrictions
RecvWindow int
}
type CancelOrderResult ¶
type CancelOrderResult string
const ( CANCEL_SUCCESS CancelOrderResult = "SUCCESS" CANCEL_FAILURE CancelOrderResult = "FAILURE" )
type CancelRestrictions ¶
type CancelRestrictions string
const ( ONLY_NEW CancelRestrictions = "ONLY_NEW" ONLY_PARTIALLY_FILLED CancelRestrictions = "ONLY_PARTIALLY_FILLED" )
type Candlestick ¶
type Candlestick struct {
OpenTime int64
Open float64
High float64
Low float64
Close float64
Volume float64
CloseTime int64
QuoteAssetVolume float64
TradeCount int64
TakerBuyBaseAssetVolume float64
TakerBuyQuoteAssetVolume float64
Unused string
}
func (*Candlestick) UnmarshalJSON ¶
func (c *Candlestick) UnmarshalJSON(data []byte) error
type CandlestickParams ¶
type CandlesticksWebsocket ¶
type CandlesticksWebsocket struct {
// contains filtered or unexported fields
}
func (CandlesticksWebsocket) ListSubscriptions ¶
func (CandlesticksWebsocket) ReadSubscriptions ¶
func (s CandlesticksWebsocket) ReadSubscriptions() []string
func (*CandlesticksWebsocket) Subscribe ¶
func (rpws *CandlesticksWebsocket) Subscribe(params ...WsCandlesticksParams) Error
func (*CandlesticksWebsocket) Unsubscribe ¶
func (rpws *CandlesticksWebsocket) Unsubscribe(params ...WsCandlesticksParams) Error
type Client ¶
type Client struct {
Websocket *wsEndpoints
// contains filtered or unexported fields
}
func NewReadClient ¶
func NewReadClient() *Client
func (*Client) Account ¶
func (c *Client) Account(opts ...AccountParams) (*Account, Response, Error)
func (*Client) AccountCommission ¶
func (c *Client) AccountCommission(symbol string, opts ...AccountCommissionParams) (*AccountCommission, Response, Error)
func (*Client) AccountFilters ¶
func (c *Client) AccountFilters(symbol string, opts ...AccountFiltersParams) (*AccountFilters, Response, Error)
AccountFilters retrieves the list of filters relevant to an account on a given symbol.
This is the only endpoint that shows if an account has MAX_ASSET filters applied to it.
func (*Client) AllOrderLists ¶
func (c *Client) AllOrderLists(opts ...AllOrderListsParams) ([]*OrderList, Response, Error)
func (*Client) Allocations ¶
func (c *Client) Allocations(symbol string, opts ...AllocationsParams) ([]*Allocation, Response, Error)
func (*Client) AveragePrice ¶
func (c *Client) AveragePrice(symbol string) (*AveragePrice, Response, Error)
func (*Client) CancelOpenOrders ¶
func (*Client) CancelOrder ¶
func (*Client) Candlesticks ¶
func (c *Client) Candlesticks(symbol string, interval Interval, opts ...CandlestickParams) ([]*Candlestick, Response, Error)
func (*Client) ExchangeInfo ¶
func (c *Client) ExchangeInfo(opts ...ExchangeInfoOption) (*ExchangeInfo, Response, Error)
Current exchange trading rules and symbol information ¶
Weight: 20
func (*Client) HistoricalTrades ¶
func (*Client) MakeRequest ¶
func (c *Client) MakeRequest(method RequestMethod, path string, params map[string]interface{}, payload map[string]interface{}, securityType SecurityType) (Response, Error)
Used to execute client requests. The Base URL used is the Spot Client's URL. If the securityType is `NONE`, it will default to the special URL provided by binance (currently `https://data-api.binance.vision`) to speed up query speed. Can be overridden via the `.SetBaseUrlMarketData()`
func (*Client) MiniTicker24h ¶
func (c *Client) MiniTicker24h(symbol string, opts ...MiniTicker24hParams) (*MiniTicker24h, Response, Error)
func (*Client) MiniTickers24h ¶
func (c *Client) MiniTickers24h(opts ...MiniTickers24hParams) ([]*MiniTicker24h, Response, Error)
func (*Client) OpenOrderLists ¶
func (c *Client) OpenOrderLists(opts ...OpenOrderListsParams) ([]*OrderList, Response, Error)
func (*Client) OpenOrders ¶
func (c *Client) OpenOrders(opts ...OpenOrdersParams) ([]*Order, Response, Error)
func (*Client) OpenOrdersBySymbol ¶
func (*Client) Order ¶
Order sends a new order request to Binance (/api/v3/order).
This method accepts any orderRequest implementation (e.g. NewLimitBuy, NewMarketSell, NewStopLossLimitOrder, etc.) and submits it to the exchange.
Response type: - Controlled by newOrderRespType:
- ACK (minimal)
- RESULT (execution info)
- FULL (includes fills)
This method is a thin wrapper over Binance and does not enforce validation. Invalid parameter combinations will be rejected by the API.
func (*Client) OrderAmendments ¶
func (c *Client) OrderAmendments(symbol string, orderID int64, opts ...OrderAmendmentsParams) ([]*OrderAmendment, Response, Error)
func (*Client) OrderBookTicker ¶
func (c *Client) OrderBookTicker(symbol string, opts ...OrderBookTickerParams) (*OrderBookTicker, Response, Error)
func (*Client) OrderBookTickers ¶
func (c *Client) OrderBookTickers(opts ...OrderBookTickersParams) ([]*OrderBookTicker, Response, Error)
func (*Client) OrderListByClientOrderId ¶
func (*Client) OrderListByOrderListId ¶
func (*Client) OrderSorTest ¶
func (*Client) OrderTest ¶
func (c *Client) OrderTest(req orderRequest, computeCommissionRates bool) (*OrderTest, Response, Error)
OrderTest sends a new test order request to Binance.
NOTE: If computeCommissionRates is false, Binance returns an empty JSON object `{}`. In that case, all fields in this struct will remain zero values. Users must explicitly enable computeCommissionRates to populate these fields.
func (*Client) PreventedMatches ¶
func (c *Client) PreventedMatches(symbol string, opts ...PreventedMatchesParams) ([]*PreventedMatch, Response, Error)
func (*Client) PriceTicker ¶
func (c *Client) PriceTicker(symbol string, opts ...PriceTickerParams) (*PriceTicker, Response, Error)
func (*Client) PriceTickers ¶
func (c *Client) PriceTickers(opts ...PriceTickersParams) ([]*PriceTicker, Response, Error)
func (*Client) QueryExecutionRules ¶
func (c *Client) QueryExecutionRules(opts ...QueryExecutionRulesParams) (*QueryExecutionRules, Response, Error)
func (*Client) QueryOrder ¶
func (*Client) RecentTrades ¶
func (*Client) ReferencePrice ¶
func (c *Client) ReferencePrice(symbol string) (*ReferencePrice, Response, Error)
func (*Client) ReferencePriceCalculation ¶
func (c *Client) ReferencePriceCalculation(symbol string, opts ...ReferencePriceCalculationParams) (*ReferencePriceCalculation, Response, Error)
func (*Client) RollingWindowMiniTicker ¶
func (c *Client) RollingWindowMiniTicker(symbol string, opts ...RollingWindowTickerMiniParams) (*RollingWindowMiniTicker, Response, Error)
func (*Client) RollingWindowMiniTickers ¶
func (c *Client) RollingWindowMiniTickers(opts ...RollingWindowMiniTickersParams) ([]*RollingWindowMiniTicker, Response, Error)
func (*Client) RollingWindowTicker ¶
func (c *Client) RollingWindowTicker(symbol string, opts ...RollingWindowTickerParams) (*RollingWindowTicker, Response, Error)
func (*Client) RollingWindowTickers ¶
func (c *Client) RollingWindowTickers(opts ...RollingWindowTickersParams) ([]*RollingWindowTicker, Response, Error)
func (*Client) ServerTime ¶
func (c *Client) ServerTime() (*ServerTime, Response, Error)
Check server time ¶
Test connectivity to the Rest API and get the current server time.
Weight: 1
Data Source: Memory
func (*Client) Tickers24h ¶
func (c *Client) Tickers24h(opts ...Tickers24hParams) ([]*Ticker24h, Response, Error)
func (*Client) TradingDayMiniTicker ¶
func (c *Client) TradingDayMiniTicker(symbol string, opts ...TradingDayTickerParams) (*TradingDayMiniTicker, Response, Error)
func (*Client) TradingDayMiniTickers ¶
func (c *Client) TradingDayMiniTickers(opts ...TradingDayTickersParams) ([]*TradingDayMiniTicker, Response, Error)
func (*Client) TradingDayTicker ¶
func (c *Client) TradingDayTicker(symbol string, opts ...TradingDayTickerParams) (*TradingDayTicker, Response, Error)
func (*Client) TradingDayTickers ¶
func (c *Client) TradingDayTickers(opts ...TradingDayTickersParams) ([]*TradingDayTicker, Response, Error)
func (*Client) UIKlines ¶
func (c *Client) UIKlines(symbol string, interval Interval, opts ...CandlestickParams) ([]*Candlestick, Response, Error)
func (*Client) UnfilledOrderCount ¶
func (c *Client) UnfilledOrderCount(opts ...UnfilledOrderCountParams) ([]*UnfilledOrderCount, Response, Error)
func (*Client) UserDataStream ¶
func (c *Client) UserDataStream(cb func(ud UserDataEvent)) (*UserDataWebsocket, Error)
func (*Client) WebsocketAPI ¶
func (c *Client) WebsocketAPI() (*WebsocketAPI, Error)
type ClientOption ¶
// Client builder //
func WithAPIKey ¶
func WithAPIKey(keypair KeyPair) ClientOption
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
func WithLogger ¶
func WithLogger(logger logging.Logger) ClientOption
func WithMarketDataURL ¶
func WithMarketDataURL(url string) ClientOption
func WithWebsocketBaseUrl ¶
func WithWebsocketBaseUrl(url string) ClientOption
func WithWebsocketMarketDataUrl ¶
func WithWebsocketMarketDataUrl(url string) ClientOption
type CommissionDiscount ¶
type CommissionRates ¶
type ContingencyType ¶
type ContingencyType string
const ( OCO ContingencyType = "OCO" OTO ContingencyType = "OTO" )
type DiffDepthWebsocket ¶
type DiffDepthWebsocket struct {
// contains filtered or unexported fields
}
func (DiffDepthWebsocket) ListSubscriptions ¶
func (DiffDepthWebsocket) ReadSubscriptions ¶
func (s DiffDepthWebsocket) ReadSubscriptions() []string
func (*DiffDepthWebsocket) Subscribe ¶
func (dws *DiffDepthWebsocket) Subscribe(params ...WsDiffDepthParams) Error
func (*DiffDepthWebsocket) Unsubscribe ¶
func (dws *DiffDepthWebsocket) Unsubscribe(params ...WsDiffDepthParams) Error
type EventStreamTerminatedEvent ¶
type EventStreamTerminatedEvent struct {
EventType UserDataEventType `json:"e"`
EventTime int64 `json:"E"`
}
type EventType ¶
type EventType string
const ( // Reference price EventReferencePrice EventType = "referencePrice" // Trades EventAggTrade EventType = "aggTrade" EventTrade EventType = "trade" // Kline / Candlestick EventKline EventType = "kline" // Mini ticker Event24hrMiniTicker EventType = "24hrMiniTicker" // Full ticker Event24hrTicker EventType = "24hrTicker" // Rolling window ticker (dynamic: 1hTicker, 4hTicker, 1dTicker) Event1hTicker EventType = "1hTicker" Event4hTicker EventType = "4hTicker" Event1dTicker EventType = "1dTicker" // Average price EventAvgPrice EventType = "avgPrice" // Order book depth updates EventDepthUpdate EventType = "depthUpdate" )
type ExchangeFilterMaxNumAlgoOrders ¶
type ExchangeFilterMaxNumAlgoOrders struct {
FilterType ExchangeFilterType `json:"filterType"`
MaxNumAlgoOrders int `json:"maxNumAlgoOrders"`
}
type ExchangeFilterMaxNumIcebergOrders ¶
type ExchangeFilterMaxNumIcebergOrders struct {
FilterType ExchangeFilterType `json:"filterType"`
MaxNumIcebergOrders int `json:"maxNumIcebergOrders"`
}
type ExchangeFilterMaxNumOrderLists ¶
type ExchangeFilterMaxNumOrderLists struct {
FilterType ExchangeFilterType `json:"filterType"`
MaxNumOrderLists int `json:"maxNumOrderLists"`
}
type ExchangeFilterMaxNumOrders ¶
type ExchangeFilterMaxNumOrders struct {
FilterType ExchangeFilterType `json:"filterType"`
MaxNumOrders int `json:"maxNumOrders"`
}
type ExchangeFilterType ¶
type ExchangeFilterType string
const ( EXCHANGE_MAX_NUM_ORDERS ExchangeFilterType = "EXCHANGE_MAX_NUM_ORDERS" EXCHANGE_MAX_NUM_ALGO_ORDERS ExchangeFilterType = "EXCHANGE_MAX_NUM_ALGO_ORDERS" EXCHANGE_MAX_NUM_ICEBERG_ORDERS ExchangeFilterType = "EXCHANGE_MAX_NUM_ICEBERG_ORDERS" EXCHANGE_MAX_NUM_ORDER_LISTS ExchangeFilterType = "EXCHANGE_MAX_NUM_ORDER_LISTS" )
type ExchangeFilters ¶
type ExchangeFilters struct {
MAX_NUM_ORDERS *ExchangeFilterMaxNumOrders
MAX_NUM_ALGO_ORDERS *ExchangeFilterMaxNumAlgoOrders
MAX_NUM_ICEBERG_ORDERS *ExchangeFilterMaxNumIcebergOrders
MAX_NUM_ORDER_LISTS *ExchangeFilterMaxNumOrderLists
}
func (*ExchangeFilters) UnmarshalJSON ¶
func (exchangeFilters *ExchangeFilters) UnmarshalJSON(data []byte) error
type ExchangeInfo ¶
type ExchangeInfo struct {
Timezone string `json:"timezone"`
ServerTime int64 `json:"serverTime"`
RateLimits []*RateLimit `json:"rateLimits"`
ExchangeFilters ExchangeFilters
Symbols_arr []*Symbol `json:"symbols"`
Symbols struct {
Mu sync.Mutex
Map map[string]*Symbol
}
Sors []*SORS `json:"sors"`
}
func (*ExchangeInfo) IsAlgoOrdersLimitHit ¶
func (ei *ExchangeInfo) IsAlgoOrdersLimitHit(value int) bool
func (*ExchangeInfo) IsIcebergOrdersLimitHit ¶
func (ei *ExchangeInfo) IsIcebergOrdersLimitHit(value int) bool
func (*ExchangeInfo) IsMaxNumOrderLists ¶
func (ei *ExchangeInfo) IsMaxNumOrderLists(value int) bool
func (*ExchangeInfo) IsOrdersLimitHit ¶
func (ei *ExchangeInfo) IsOrdersLimitHit(value int) bool
func (*ExchangeInfo) IsRateLimitHit ¶
func (ei *ExchangeInfo) IsRateLimitHit(value int, rateLimitType RateLimitType, interval RateLimitInterval, intervalNum int) bool
IsRateLimitHit reports whether the specified rate limit rule has been reached.
The method searches ExchangeInfo.RateLimits for a RateLimit rule matching the provided parameters (rateLimitType, interval, and intervalNum). If a matching rule is found, its Limit is compared against the provided value. If value is greater than or equal to the rule's limit, the method returns true.
Parameters:
- value: the current usage value to compare against the rate limit
- rateLimitType: the type of rate limit to check (e.g., REQUEST_WEIGHT)
- interval: the time interval unit for the rule (e.g., SECOND, MINUTE)
- intervalNum: the number of interval units defining the rate window
Returns true if the rate limit has been reached or exceeded, otherwise false.
type ExchangeInfoOption ¶
type ExchangeInfoOption func(exchangeInfoParams) Error
func WithPermissions ¶
func WithPermissions(perms []Permission) ExchangeInfoOption
func WithShowPermissionSets ¶
func WithShowPermissionSets(value bool) ExchangeInfoOption
func WithSymbolStatus ¶
func WithSymbolStatus(s SymbolStatus) ExchangeInfoOption
func WithSymbols ¶
func WithSymbols(s []string) ExchangeInfoOption
type ExecutionReportEvent ¶
type ExecutionReportEvent struct {
EventType UserDataEventType `json:"e"`
EventTime int64 `json:"E"`
Symbol string `json:"s"`
ClientOrderID string `json:"c"`
Side string `json:"S"`
OrderType string `json:"o"`
TimeInForce string `json:"f"`
Quantity string `json:"q"`
Price string `json:"p"`
StopPrice string `json:"P"`
IcebergQuantity string `json:"F"`
OrderListID int64 `json:"g"`
OriginalClientOrderID string `json:"C"`
ExecutionType string `json:"x"`
OrderStatus string `json:"X"`
RejectReason string `json:"r"`
OrderID int64 `json:"i"`
LastExecutedQuantity string `json:"l"`
CumulativeFilledQty string `json:"z"`
LastExecutedPrice string `json:"L"`
CommissionAmount string `json:"n"`
CommissionAsset *string `json:"N"`
TransactionTime int64 `json:"T"`
TradeID int64 `json:"t"`
PreventedMatchID *int64 `json:"v,omitempty"`
ExecutionID int64 `json:"I"`
IsOnBook bool `json:"w"`
IsMaker bool `json:"m"`
Ignore bool `json:"M"`
OrderCreationTime int64 `json:"O"`
CumulativeQuoteQty string `json:"Z"`
LastQuoteQty string `json:"Y"`
QuoteOrderQty string `json:"Q"`
WorkingTime *int64 `json:"W,omitempty"`
SelfTradePrevention string `json:"V"`
// --- Conditional fields ---
TrailingDelta *int64 `json:"d,omitempty"`
TrailingTime *int64 `json:"D,omitempty"`
StrategyID *int64 `json:"j,omitempty"`
StrategyType *int64 `json:"J,omitempty"`
PreventedQuantity *string `json:"A,omitempty"`
LastPreventedQuantity *string `json:"B,omitempty"`
TradeGroupID *int64 `json:"u,omitempty"`
CounterOrderID *int64 `json:"U,omitempty"`
CounterSymbol *string `json:"Cs,omitempty"`
PreventedExecQuantity *string `json:"pl,omitempty"`
PreventedExecPrice *string `json:"pL,omitempty"`
PreventedExecQuoteQty *string `json:"pY,omitempty"`
MatchType *string `json:"b,omitempty"`
AllocationID *int64 `json:"a,omitempty"`
WorkingFloor *string `json:"k,omitempty"`
UsedSor *bool `json:"uS,omitempty"`
PeggedPriceType *string `json:"gP,omitempty"`
PeggedOffsetType *string `json:"gOT,omitempty"`
PeggedOffsetValue *int64 `json:"gOV,omitempty"`
PeggedPrice *string `json:"gp,omitempty"`
ExpiryReason *string `json:"eR,omitempty"`
}
type ExecutionType ¶
type ExecutionType string
const ( // The order has been accepted into the engine. ExecNew ExecutionType = "NEW" // The order has been canceled by the user. ExecCanceled ExecutionType = "CANCELED" // The order has been amended. ExecReplaced ExecutionType = "REPLACED" // The order has been rejected and was not processed (e.g. `Cancel Replace Orders` wherein the new order placement is rejected but the request to cancel request succeeds.) ExecRejected ExecutionType = "REJECTED" // Part of the order or all of the order's quantity has filled. ExecTrade ExecutionType = "TRADE" // The order was canceled according to the order type's rules (e.g. `LIMIT FOK` orders with no fill, `LIMIT IOC` or `MARKET` orders that partially fill) or by the exchange, (e.g. orders canceled during liquidation, orders canceled during maintenance). ExecExpired ExecutionType = "EXPIRED" // The order has expired due to STP. ExecTradePrevention ExecutionType = "TRADE_PREVENTION" )
type ExternalLockUpdateEvent ¶
type ExternalLockUpdateEvent struct {
EventType UserDataEventType `json:"e"`
EventTime int64 `json:"E"`
Asset string `json:"a"`
Delta string `json:"d"`
TransactionTime int64 `json:"T"`
}
type Fill ¶
type Fill struct {
// Price is the execution price of this trade.
// Returned for all fills.
Price float64 `json:"price,string"`
// Qty is the quantity executed in this specific fill.
// Returned for all fills.
Qty float64 `json:"qty,string"`
// Commission is the fee charged for this fill.
// Returned for all fills.
Commission float64 `json:"commission,string"`
// CommissionAsset is the asset in which the commission was paid
// (e.g., USDT, BNB, BTC).
// Returned for all fills.
CommissionAsset string `json:"commissionAsset"`
// TradeId is the unique identifier of the trade execution.
// May be -1 for certain execution types (e.g., SOR internal matches).
// Returned for all fills.
TradeId int64 `json:"tradeId"`
// MatchType indicates how the trade was matched.
// Only returned for SOR (Smart Order Routing) orders.
// Example: "ONE_PARTY_TRADE_REPORT".
MatchType string `json:"matchType"`
// AllocId is an internal allocation identifier used by Binance.
// Only returned for SOR orders.
AllocId int64 `json:"allocId"`
}
Fill represents an individual trade execution within an order.
It is only populated when the order response type is FULL (newOrderRespType = FULL). Each entry corresponds to a partial or complete fill of the order.
type HistoricalTradesParams ¶
type Interval ¶
type Interval string
const ( // seconds Interval1s Interval = "1s" // minutes Interval1m Interval = "1m" Interval3m Interval = "3m" Interval5m Interval = "5m" Interval15m Interval = "15m" Interval30m Interval = "30m" // hours Interval1h Interval = "1h" Interval2h Interval = "2h" Interval4h Interval = "4h" Interval6h Interval = "6h" Interval8h Interval = "8h" Interval12h Interval = "12h" // days Interval1d Interval = "1d" Interval3d Interval = "3d" // weeks Interval1w Interval = "1w" // months Interval1M Interval = "1M" )
type KeyPair ¶
KeyPair represents an authentication credential used by the client to authenticate requests against the Binance API.
Different Binance endpoints require different authentication schemes. Implementations of KeyPair encapsulate the logic required to attach authentication information to outgoing requests and, when necessary, sign them.
The library provides multiple built-in KeyPair implementations covering all supported Binance authentication methods:
API Key only Used for endpoints that require the API key header but do not require request signing (for example User Data Stream management).
HMAC-SHA256 The most common authentication method used by Binance REST APIs. Requests are signed using the API secret and the signature is appended to the query string.
RSA Asymmetric request signing using an RSA private key. The corresponding public key must be registered with Binance.
Ed25519 Modern asymmetric signing using an Ed25519 key pair. Like RSA, the public key must be registered with Binance.
A KeyPair is passed to the client during initialization and is used internally whenever an endpoint requires authenticated access.
Users typically do not implement this interface themselves; instead, they construct a KeyPair using the helper functions provided in the apikey package.
type LimitMakerOrderParams ¶
type LimitMakerOrderParams struct {
NewClientOrderId string
StrategyId int64
StrategyType int
IcebergQty float64
NewOrderRespType OrderResponseType
SelfTradePreventionMode STPMode
PegPriceType PegPriceType
PegOffsetValue int
PegOffsetType PegOffsetType
RecvWindow int
}
type LimitMakerOrderRequest ¶
type LimitMakerOrderRequest struct {
Symbol string
Side OrderSide
Quantity float64
Price float64
Params LimitMakerOrderParams
}
type LimitOrderParams ¶
type LimitOrderParams struct {
NewClientOrderId string
StrategyId int64
StrategyType int
IcebergQty float64
NewOrderRespType OrderResponseType
SelfTradePreventionMode STPMode
PegPriceType PegPriceType
PegOffsetValue int
PegOffsetType PegOffsetType
RecvWindow int
}
type LimitOrderRequest ¶
type LimitOrderRequest struct {
Symbol string
Side OrderSide
TimeInForce TimeInForce
Quantity float64
Price float64
Params LimitOrderParams
}
type ListOrderStatus ¶
type ListOrderStatus string
const ( // The order list is currently executing or has an active update. Executing ListOrderStatus = "EXECUTING" // The order list has completed execution and is no longer active. ListOrderAllDone ListOrderStatus = "ALL_DONE" // The order list action failed during placement or cancellation. ListOrderReject ListOrderStatus = "REJECT" )
type ListStatusEvent ¶
type ListStatusEvent struct {
EventType UserDataEventType `json:"e"`
EventTime int64 `json:"E"`
Symbol string `json:"s"`
OrderListID int64 `json:"g"`
ContingencyType string `json:"c"`
ListStatusType string `json:"l"`
ListOrderStatus string `json:"L"`
ListRejectReason string `json:"r"`
ListClientOrderID string `json:"C"`
TransactionTime int64 `json:"T"`
Orders []ListStatusOrder `json:"O"`
}
type ListStatusOrder ¶
type ListStatusType ¶
type ListStatusType string
const ( // Returned when the list status responds to a failed action such as order list placement or cancellation. ListResponse ListStatusType = "RESPONSE" // Indicates the order list has been placed or updated. ExecStarted ListStatusType = "EXEC_STARTED" // Indicates a clientOrderId in the list has changed. Updated ListStatusType = "UPDATED" // Indicates the order list has completed execution and is no longer active. ListAllDone ListStatusType = "ALL_DONE" )
type ManagedOrderBook ¶
type ManagedOrderBook struct {
Symbol string
LastUpdateID int64
Bids []PriceLevel
Asks []PriceLevel
}
type ManagedOrderBookHandler ¶
type ManagedOrderBookHandler struct {
// contains filtered or unexported fields
}
func (*ManagedOrderBookHandler) Asks ¶
func (h *ManagedOrderBookHandler) Asks() []PriceLevel
func (*ManagedOrderBookHandler) AsksSorted ¶
func (h *ManagedOrderBookHandler) AsksSorted(ascending bool) []PriceLevel
func (*ManagedOrderBookHandler) BestAsk ¶
func (h *ManagedOrderBookHandler) BestAsk() (PriceLevel, bool)
func (*ManagedOrderBookHandler) BestBid ¶
func (h *ManagedOrderBookHandler) BestBid() (PriceLevel, bool)
func (*ManagedOrderBookHandler) Bids ¶
func (h *ManagedOrderBookHandler) Bids() []PriceLevel
Bids return copies of the internal state. They are safe to use without additional locking.
If you need multiple fields atomically (e.g. bids + asks + updateID), use RLock()/RUnlock() manually.
func (*ManagedOrderBookHandler) BidsSorted ¶
func (h *ManagedOrderBookHandler) BidsSorted(ascending bool) []PriceLevel
func (*ManagedOrderBookHandler) LastUpdateID ¶
func (h *ManagedOrderBookHandler) LastUpdateID() int64
func (*ManagedOrderBookHandler) RLock ¶
func (h *ManagedOrderBookHandler) RLock()
func (*ManagedOrderBookHandler) RUnlock ¶
func (h *ManagedOrderBookHandler) RUnlock()
func (*ManagedOrderBookHandler) Snapshot ¶
func (h *ManagedOrderBookHandler) Snapshot(sorted bool) ManagedOrderBook
Snapshot returns a copy of the ManagedOrderBook
If sorted is `true`. Bids are sorted in descending order Asks are sorted in ascending order
func (*ManagedOrderBookHandler) SortPriceLevels ¶
func (h *ManagedOrderBookHandler) SortPriceLevels(levels []PriceLevel, ascending bool)
SortPriceLevels sorts the array in place.
func (*ManagedOrderBookHandler) Symbol ¶
func (h *ManagedOrderBookHandler) Symbol() string
type MarketOrderParams ¶
type MarketOrderParams struct {
TimeInForce TimeInForce
// If set, `quantity` will be ignored
QuoteOrderQty float64
NewClientOrderId string
StrategyId int64
StrategyType int
NewOrderRespType OrderResponseType
SelfTradePreventionMode STPMode
RecvWindow int
}
type MarketOrderRequest ¶
type MarketOrderRequest struct {
Symbol string
Side OrderSide
Quantity float64
Params MarketOrderParams
}
type MiniTicker24h ¶
type MiniTicker24h struct {
Symbol string `json:"symbol"`
OpenPrice float64 `json:"openPrice,string"`
HighPrice float64 `json:"highPrice,string"`
LowPrice float64 `json:"lowPrice,string"`
LastPrice float64 `json:"lastPrice,string"`
Volume float64 `json:"volume,string"`
QuoteVolume float64 `json:"quoteVolume,string"`
OpenTime int64 `json:"openTime"`
CloseTime int64 `json:"closeTime"`
FirstID int64 `json:"firstId"`
LastID int64 `json:"lastId"`
Count int64 `json:"count"`
}
type MiniTicker24hParams ¶
type MiniTicker24hParams struct {
SymbolStatus SymbolStatus
}
type MiniTickerWebsocket ¶
type MiniTickerWebsocket struct {
// contains filtered or unexported fields
}
func (MiniTickerWebsocket) ListSubscriptions ¶
func (MiniTickerWebsocket) ReadSubscriptions ¶
func (s MiniTickerWebsocket) ReadSubscriptions() []string
func (*MiniTickerWebsocket) Subscribe ¶
func (mtws *MiniTickerWebsocket) Subscribe(symbols ...string) Error
func (*MiniTickerWebsocket) Unsubscribe ¶
func (mtws *MiniTickerWebsocket) Unsubscribe(symbols ...string) Error
type MiniTickers24hParams ¶
type MiniTickers24hParams struct {
Symbols []string
SymbolStatus SymbolStatus
}
type MiniTradingDayTickerParams ¶
type MiniTradingDayTickerParams struct {
SymbolStatus SymbolStatus
TimeZone string
}
type MiniTradingDayTickersParams ¶
type MiniTradingDayTickersParams struct {
Symbols []string
SymbolStatus SymbolStatus
TimeZone string
}
type NewOrderResult ¶
type NewOrderResult string
const ( NEWORDER_SUCCESS NewOrderResult = "SUCCESS" NEWORDER_NOT_ATTEMPTED NewOrderResult = "NOT_ATTEMPTED" NEWORDER_FAILURE NewOrderResult = "FAILURE" )
type OpenOrderListsParams ¶
type OpenOrderListsParams struct {
RecvWindow int
}
type OpenOrdersBySymbolParams ¶
type OpenOrdersBySymbolParams struct {
RecvWindow int
}
type OpenOrdersParams ¶
type Order ¶
type Order struct {
// Symbol is the trading pair (e.g., BTCUSDT).
Symbol string `json:"symbol"`
// OrderId is the unique identifier assigned by Binance.
OrderId int64 `json:"orderId"`
// OrderListId identifies an order list (OCO). -1 if not part of a list.
OrderListId int64 `json:"orderListId"`
// ClientOrderId is the client-provided or auto-generated unique ID.
ClientOrderId string `json:"clientOrderId"`
// Price is the order price. May be "0.00000000" for MARKET orders.
Price float64 `json:"price,string"`
// OrigQty is the original quantity of the order.
OrigQty float64 `json:"origQty,string"`
// ExecutedQty is the quantity that has been filled.
ExecutedQty float64 `json:"executedQty,string"`
// CummulativeQuoteQty is the total quote asset spent/received.
CummulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"`
// OrigQuoteOrderQty is the original quote quantity for MARKET orders using quoteOrderQty.
OrigQuoteOrderQty float64 `json:"origQuoteOrderQty,string"`
// Status represents the current order status (e.g., NEW, FILLED, CANCELED).
Status OrderStatus `json:"status"`
// TimeInForce defines how long the order remains active (e.g., GTC, IOC).
TimeInForce TimeInForce `json:"timeInForce"`
// Type is the order type (e.g., LIMIT, MARKET, STOP_LOSS).
Type OrderType `json:"type"`
// Side indicates BUY or SELL.
Side OrderSide `json:"side"`
// StopPrice is the trigger price for STOP_LOSS and TAKE_PROFIT orders.
// Only present for trigger-based orders.
StopPrice float64 `json:"stopPrice,string"`
// IcebergQty is the visible portion of an iceberg order.
// Only present if icebergQty was used.
IcebergQty float64 `json:"icebergQty,string"`
// TrailingDelta is the price delta required to activate a trailing stop.
//
// Only present for trailing stop orders.
TrailingDelta int64 `json:"trailingDelta"`
// TrailingTime is the timestamp when the trailing order became active.
//
// Only present for trailing stop orders.
TrailingTime int64 `json:"trailingTime"`
// StrategyId is a user-defined identifier for grouping orders.
StrategyId int64 `json:"strategyId"`
// StrategyType is a user-defined strategy type (must be >= 1000000).
StrategyType int `json:"strategyType"`
// SelfTradePreventionMode indicates the STP mode used for this order.
SelfTradePreventionMode STPMode `json:"selfTradePreventionMode"`
// PreventedMatchId identifies a prevented match due to STP.
// Only present if the order expired due to STP.
PreventedMatchId int64 `json:"preventedMatchId"`
// PreventedQuantity is the quantity prevented from matching due to STP.
PreventedQuantity float64 `json:"preventedQuantity,string"`
// UsedSor indicates whether Smart Order Routing was used.
UsedSor bool `json:"usedSor"`
// WorkingFloor indicates where the order is being executed (e.g., SOR or order book).
WorkingFloor string `json:"workingFloor"`
// PegPriceType defines the peg type (PRIMARY_PEG or MARKET_PEG).
// Only present for pegged orders.
PegPriceType PegPriceType `json:"pegPriceType"`
// PegOffsetType defines the peg offset type (currently PRICE_LEVEL).
//
// Only present for pegged orders.
PegOffsetType PegOffsetType `json:"pegOffsetType"`
// PegOffsetValue defines the offset level from the pegged price.
PegOffsetValue int `json:"pegOffsetValue"`
// PeggedPrice is the current dynamically adjusted pegged price.
PeggedPrice float64 `json:"peggedPrice,string"`
// ExpiryReason indicates why the order expired (e.g., insufficient liquidity).
ExpiryReason string `json:"expiryReason"`
// IsWorking indicates whether the order is currently active on the book.
IsWorking bool `json:"isWorking"`
// WorkingTime is the timestamp when the order started working on the book.
WorkingTime int64 `json:"workingTime"`
// Time is the order creation timestamp (ms).
Time int64 `json:"time"`
// UpdateTime is the last update timestamp (ms).
UpdateTime int64 `json:"updateTime"`
// Fills contains trade breakdowns for the order.
//
// Only present when newOrderRespType = FULL.
Fills []Fill `json:"fills"`
}
This struct includes all known fields, including those that are conditionally returned depending on order type, execution, and advanced features.
NOTE: - Binance encodes numeric values as strings; these are parsed into float64. - Many fields are optional and will remain zero values if not returned. - Presence of fields depends on order type, response type, and exchange features.
type OrderAmendment ¶
type OrderAmendment struct {
Symbol string `json:"symbol"`
OrderID int64 `json:"orderId"`
ExecutionID int64 `json:"executionId"`
OrigClientOrderID string `json:"origClientOrderId"`
NewClientOrderID string `json:"newClientOrderId"`
OrigQty float64 `json:"origQty,string"`
NewQty float64 `json:"newQty,string"`
Time int64 `json:"time"`
}
type OrderAmendmentsParams ¶
type OrderBook ¶
type OrderBook struct {
LastUpdateId int64 `json:"lastUpdateId"`
//"bids": [
// [
// "4.00000000", // PRICE
// "431.00000000" // QTY
// ]
// ]
Bids []PriceLevel `json:"bids"`
// "asks": [
// [
// "4.00000200",
// "12.00000000"
// ]
// ]
Asks []PriceLevel `json:"asks"`
}
Market Order
type OrderBookParams ¶
type OrderBookParams struct {
Limit int
SymbolStatus SymbolStatus
}
type OrderBookTicker ¶
type OrderBookTickerParams ¶
type OrderBookTickerParams struct {
SymbolStatus SymbolStatus
}
type OrderBookTickersParams ¶
type OrderBookTickersParams struct {
Symbols []string
SymbolStatus SymbolStatus
}
type OrderBookWebsocket ¶
type OrderBookWebsocket struct {
// contains filtered or unexported fields
}
func (OrderBookWebsocket) ListSubscriptions ¶
func (OrderBookWebsocket) ReadSubscriptions ¶
func (s OrderBookWebsocket) ReadSubscriptions() []string
func (*OrderBookWebsocket) Subscribe ¶
func (ows *OrderBookWebsocket) Subscribe(params ...WsOrderBookParams) Error
func (*OrderBookWebsocket) Unsubscribe ¶
func (ows *OrderBookWebsocket) Unsubscribe(params ...WsOrderBookParams) Error
type OrderList ¶
type OrderList struct {
OrderListID int64 `json:"orderListId"`
ContingencyType ContingencyType `json:"contingencyType"`
ListStatusType ListStatusType `json:"listStatusType"`
ListOrderStatus ListOrderStatus `json:"listOrderStatus"`
ListClientOrderID string `json:"listClientOrderId"`
TransactionTime int64 `json:"transactionTime"`
Symbol string `json:"symbol"`
Orders []OrderListItem `json:"orders"`
}
type OrderListByClientOrderIDParams ¶
type OrderListByClientOrderIDParams struct {
RecvWindow int
}
type OrderListByOrderIdParams ¶
type OrderListByOrderIdParams struct {
RecvWindow int
}
type OrderListItem ¶
type OrderResponseType ¶
type OrderResponseType string
const ( Ack OrderResponseType = "ACK" // Provides the final state of the order after execution. Result OrderResponseType = "RESULT" // Provides full order information including fills. Full OrderResponseType = "FULL" )
type OrderStatus ¶
type OrderStatus string
const ( // The order has been accepted by the engine. OrderStatusNew OrderStatus = "NEW" // The order is pending until the working order of an order list has been fully filled. PendingNew OrderStatus = "PENDING_NEW" // A part of the order has been filled. PartiallyFilled OrderStatus = "PARTIALLY_FILLED" // The order has been completely filled. Filled OrderStatus = "FILLED" // The order has been canceled by the user. Canceled OrderStatus = "CANCELED" // Currently unused. PendingCancel OrderStatus = "PENDING_CANCEL" // The order was rejected by the engine and not processed. Rejected OrderStatus = "REJECTED" // The order expired due to order rules or exchange conditions. Expired OrderStatus = "EXPIRED" // The order expired due to Self Trade Prevention (STP). ExpiredInMatch OrderStatus = "EXPIRED_IN_MATCH" )
type OrderTest ¶
type OrderTest struct {
StandardCommissionForOrder CommissionRates `json:"standardCommissionForOrder"`
SpecialCommissionForOrder CommissionRates `json:"specialCommissionForOrder"`
TaxCommissionForOrder CommissionRates `json:"taxCommissionForOrder"`
Discount CommissionDiscount `json:"discount"`
}
type OutboundAccountPositionEvent ¶
type OutboundAccountPositionEvent struct {
EventType UserDataEventType `json:"e"`
EventTime int64 `json:"E"`
LastUpdateTime int64 `json:"u"`
Balances []UserDataBalance `json:"B"`
}
type PegPriceType ¶
type PegPriceType string
const ( PRIMARY_PEG PegPriceType = "PRIMARY_PEG" MARKET_PEG PegPriceType = "MARKET_PEG" )
type Permission ¶
type Permission string
const ( SPOT Permission = "SPOT" MARGIN Permission = "MARGIN" LEVERAGED Permission = "LEVERAGED" TRD_GRP_002 Permission = "TRD_GRP_002" TRD_GRP_003 Permission = "TRD_GRP_003" TRD_GRP_004 Permission = "TRD_GRP_004" TRD_GRP_005 Permission = "TRD_GRP_005" TRD_GRP_006 Permission = "TRD_GRP_006" TRD_GRP_007 Permission = "TRD_GRP_007" TRD_GRP_008 Permission = "TRD_GRP_008" TRD_GRP_009 Permission = "TRD_GRP_009" TRD_GRP_010 Permission = "TRD_GRP_010" TRD_GRP_011 Permission = "TRD_GRP_011" TRD_GRP_012 Permission = "TRD_GRP_012" TRD_GRP_013 Permission = "TRD_GRP_013" TRD_GRP_014 Permission = "TRD_GRP_014" TRD_GRP_015 Permission = "TRD_GRP_015" TRD_GRP_016 Permission = "TRD_GRP_016" TRD_GRP_017 Permission = "TRD_GRP_017" TRD_GRP_018 Permission = "TRD_GRP_018" TRD_GRP_019 Permission = "TRD_GRP_019" TRD_GRP_020 Permission = "TRD_GRP_020" TRD_GRP_021 Permission = "TRD_GRP_021" TRD_GRP_022 Permission = "TRD_GRP_022" TRD_GRP_023 Permission = "TRD_GRP_023" TRD_GRP_024 Permission = "TRD_GRP_024" TRD_GRP_025 Permission = "TRD_GRP_025" )
type PreventedMatch ¶
type PreventedMatch struct {
Symbol string `json:"symbol"`
PreventedMatchID int64 `json:"preventedMatchId"`
TakerOrderID int64 `json:"takerOrderId"`
MakerSymbol string `json:"makerSymbol"`
MakerOrderID int64 `json:"makerOrderId"`
TradeGroupID int64 `json:"tradeGroupId"`
SelfTradePreventionMode STPMode `json:"selfTradePreventionMode"`
Price float64 `json:"price,string"`
MakerPreventedQuantity float64 `json:"makerPreventedQuantity,string"`
TransactTime int64 `json:"transactTime"`
}
type PreventedMatchesParams ¶
type PriceLevel ¶
func (*PriceLevel) UnmarshalJSON ¶
func (p *PriceLevel) UnmarshalJSON(data []byte) error
type PriceTicker ¶
type PriceTickerParams ¶
type PriceTickerParams struct {
SymbolStatus SymbolStatus
}
type PriceTickersParams ¶
type PriceTickersParams struct {
Symbols []string
SymbolStatus SymbolStatus
}
type QueryExecutionRules ¶
type QueryExecutionRules struct {
SymbolRules []SymbolRule
}
type QueryExecutionRulesParams ¶
type QueryExecutionRulesParams struct {
Symbols []string
SymbolStatus SymbolStatus
}
type QueryOrderParams ¶
Order
type RateLimit ¶
type RateLimit struct {
RateLimitType RateLimitType `json:"rateLimitType"`
Interval RateLimitInterval `json:"interval"`
IntervalNum int `json:"intervalNum"`
Limit int `json:"limit"`
}
type RateLimitInterval ¶
type RateLimitInterval string
const ( Second RateLimitInterval = "SECOND" Minute RateLimitInterval = "MINUTE" Day RateLimitInterval = "DAY" )
type RateLimitType ¶
type RateLimitType string
const ( RequestWeight RateLimitType = "REQUEST_WEIGHT" Orders RateLimitType = "ORDERS" RawRequests RateLimitType = "RAW_REQUESTS" )
type RecentTradesParams ¶
type RecentTradesParams struct {
Limit int
}
type ReferencePrice ¶
type ReferencePrice struct {
Symbol string `json:"symbol"`
ReferencePrice *float64 `json:"referencePrice,string"`
Timestamp int64 `json:"timestamp"`
}
func (ReferencePrice) HasPrice ¶
func (r ReferencePrice) HasPrice() bool
type ReferencePriceCalculation ¶
type ReferencePriceCalculation struct {
Symbol string `json:"symbol"`
CalculationType ReferencePriceCalculationType `json:"calculationType"`
// ARITHMETIC_MEAN
BucketCount *int64 `json:"bucketCount,omitempty"`
BucketWidthMs *int64 `json:"bucketWidthMs,omitempty"`
// EXTERNAL
ExternalCalculationID *int64 `json:"externalCalculationId,omitempty"`
}
func (ReferencePriceCalculation) ArithmeticMeanParams ¶
func (r ReferencePriceCalculation) ArithmeticMeanParams() (bucketCount, bucketWidthMs int64, ok bool)
func (ReferencePriceCalculation) ExternalID ¶
func (r ReferencePriceCalculation) ExternalID() (int64, bool)
func (ReferencePriceCalculation) IsArithmeticMean ¶
func (r ReferencePriceCalculation) IsArithmeticMean() bool
func (ReferencePriceCalculation) IsExternal ¶
func (r ReferencePriceCalculation) IsExternal() bool
type ReferencePriceCalculationParams ¶
type ReferencePriceCalculationParams struct {
SymbolStatus SymbolStatus
}
type ReferencePriceCalculationType ¶
type ReferencePriceCalculationType string
const ( ArithmeticMean ReferencePriceCalculationType = "ARITHMETIC_MEAN" External ReferencePriceCalculationType = "EXTERNAL" )
type ReferencePriceWebsocket ¶
type ReferencePriceWebsocket struct {
// contains filtered or unexported fields
}
func (ReferencePriceWebsocket) ListSubscriptions ¶
func (ReferencePriceWebsocket) ReadSubscriptions ¶
func (s ReferencePriceWebsocket) ReadSubscriptions() []string
func (*ReferencePriceWebsocket) Subscribe ¶
func (rpws *ReferencePriceWebsocket) Subscribe(symbols ...string) Error
func (*ReferencePriceWebsocket) Unsubscribe ¶
func (rpws *ReferencePriceWebsocket) Unsubscribe(symbols ...string) Error
type RequestMethod ¶
type RollingWindowMiniTicker ¶
type RollingWindowMiniTicker struct {
Symbol string `json:"symbol"`
OpenPrice float64 `json:"openPrice,string"`
HighPrice float64 `json:"highPrice,string"`
LowPrice float64 `json:"lowPrice,string"`
LastPrice float64 `json:"lastPrice,string"`
Volume float64 `json:"volume,string"`
QuoteVolume float64 `json:"quoteVolume,string"`
OpenTime int64 `json:"openTime"`
CloseTime int64 `json:"closeTime"`
FirstID int64 `json:"firstId"`
LastID int64 `json:"lastId"`
Count int64 `json:"count"`
}
type RollingWindowMiniTickersParams ¶
type RollingWindowMiniTickersParams struct {
Symbols []string
SymbolStatus SymbolStatus
WindowSize string
}
type RollingWindowTicker ¶
type RollingWindowTicker struct {
Symbol string `json:"symbol"`
PriceChange float64 `json:"priceChange,string"`
PriceChangePercent float64 `json:"priceChangePercent,string"`
WeightedAvgPrice float64 `json:"weightedAvgPrice,string"`
OpenPrice float64 `json:"openPrice,string"`
HighPrice float64 `json:"highPrice,string"`
LowPrice float64 `json:"lowPrice,string"`
LastPrice float64 `json:"lastPrice,string"`
Volume float64 `json:"volume,string"`
QuoteVolume float64 `json:"quoteVolume,string"`
OpenTime int64 `json:"openTime"`
CloseTime int64 `json:"closeTime"`
FirstID int64 `json:"firstId"`
LastID int64 `json:"lastId"`
Count int64 `json:"count"`
}
type RollingWindowTickerMiniParams ¶
type RollingWindowTickerMiniParams struct {
SymbolStatus SymbolStatus
WindowSize string
}
type RollingWindowTickerParams ¶
type RollingWindowTickerParams struct {
SymbolStatus SymbolStatus
WindowSize string
}
type RollingWindowTickerWebsocket ¶
type RollingWindowTickerWebsocket struct {
// contains filtered or unexported fields
}
func (RollingWindowTickerWebsocket) ListSubscriptions ¶
func (RollingWindowTickerWebsocket) ReadSubscriptions ¶
func (s RollingWindowTickerWebsocket) ReadSubscriptions() []string
func (*RollingWindowTickerWebsocket) Subscribe ¶
func (rtws *RollingWindowTickerWebsocket) Subscribe(params ...WsRollingWindowParams) Error
func (*RollingWindowTickerWebsocket) Unsubscribe ¶
func (rtws *RollingWindowTickerWebsocket) Unsubscribe(params ...WsRollingWindowParams) Error
type RollingWindowTickersParams ¶
type RollingWindowTickersParams struct {
Symbols []string
SymbolStatus SymbolStatus
WindowSize string
}
type SecurityType ¶
type SecurityType string
const ( NONE SecurityType = "NONE" TRADE SecurityType = "TRADE" USER_DATA SecurityType = "USER_DATA" USER_STREAM SecurityType = "USER_STREAM" )
type ServerTime ¶
type StopLimitOrderParams ¶
type StopLimitOrderParams struct {
NewClientOrderId string
StrategyId int64
StrategyType int
StopPrice float64
TrailingDelta int64
IcebergQty float64
NewOrderRespType OrderResponseType
SelfTradePreventionMode STPMode
PegPriceType PegPriceType
PegOffsetValue int
PegOffsetType PegOffsetType
RecvWindow int
}
type StopLimitOrderRequest ¶
type StopLimitOrderRequest struct {
Symbol string
Side OrderSide
Price float64
Quantity float64
TimeInForce TimeInForce
StopPrice float64
TrailingDelta int64
IcebergQty float64
Type OrderType // StopLossLimit or TakeProfitLimit
Params StopLimitOrderParams
}
type StopOrderParams ¶
type StopOrderRequest ¶
type Symbol ¶
type Symbol struct {
Symbol string `json:"symbol"`
Status SymbolStatus `json:"status"`
BaseAsset string `json:"baseAsset"`
BaseAssetPrecision int `json:"baseAssetPrecision"`
QuoteAsset string `json:"quoteAsset"`
QuotePrecision int `json:"quotePrecision"`
BaseCommissionPrecision int `json:"baseCommissionPrecision"`
QuoteCommissionPrecision int `json:"quoteCommissionPrecision"`
OrderTypes []OrderType `json:"orderTypes"`
IcebergAllowed bool `json:"icebergAllowed"`
OcoAllowed bool `json:"ocoAllowed"`
OtoAllowed bool `json:"otoAllowed"`
QuoteOrderQtyMarketAllowed bool `json:"quoteOrderQtyMarketAllowed"`
AllowTrailingStop bool `json:"allowTrailingStop"`
CancelReplaceAllowedbool bool `json:"cancelReplaceAllowedbool"`
IsSpotTradingAllowed bool `json:"isSpotTradingAllowed"`
IsMarginTradingAllowed bool `json:"isMarginTradingAllowed"`
Filters SymbolFilters
Permissions []Permission `json:"permissions"`
PermissionSets [][]Permission `json:"permissionSets"`
DefaultSelfTradePreventionMode string `json:"defaultSelfTradePreventionMode"`
AllowedSelfTradePreventionModes []string `json:"allowedSelfTradePreventionModes"`
}
type SymbolFilterIcebergParts ¶
type SymbolFilterIcebergParts struct {
FilterType SymbolFilterType `json:"filterType"`
Limit int `json:"limit"`
}
type SymbolFilterLotSize ¶
type SymbolFilterLotSize struct {
FilterType SymbolFilterType `json:"filterType"`
MinQty float64 `json:"minQty,string"`
MaxQty float64 `json:"maxQty,string"`
StepSize float64 `json:"stepSize,string"`
}
type SymbolFilterMarketLotSize ¶
type SymbolFilterMarketLotSize struct {
FilterType SymbolFilterType `json:"filterType"`
MinQty float64 `json:"minQty,string"`
MaxQty float64 `json:"maxQty,string"`
StepSize float64 `json:"stepSize,string"`
}
type SymbolFilterMaxNumAlgoOrders ¶
type SymbolFilterMaxNumAlgoOrders struct {
FilterType SymbolFilterType `json:"filterType"`
MaxNumAlgoOrders int `json:"maxNumAlgoOrders"`
}
type SymbolFilterMaxNumIcebergOrders ¶
type SymbolFilterMaxNumIcebergOrders struct {
FilterType SymbolFilterType `json:"filterType"`
MaxNumIcebergOrders int `json:"maxNumIcebergOrders"`
}
type SymbolFilterMaxNumOrderAmends ¶
type SymbolFilterMaxNumOrderAmends struct {
FilterType SymbolFilterType `json:"filterType"`
MaxNumOrderAmends int `json:"maxNumOrderAmends"`
}
type SymbolFilterMaxNumOrderLists ¶
type SymbolFilterMaxNumOrderLists struct {
FilterType SymbolFilterType `json:"filterType"`
MaxNumOrderLists int `json:"maxNumOrderLists"`
}
type SymbolFilterMaxNumOrders ¶
type SymbolFilterMaxNumOrders struct {
FilterType SymbolFilterType `json:"filterType"`
MaxNumOrders int `json:"maxNumOrders"`
}
type SymbolFilterMaxPosition ¶
type SymbolFilterMaxPosition struct {
FilterType SymbolFilterType `json:"filterType"`
MaxPosition float64 `json:"maxPosition,string"`
}
type SymbolFilterMinNotional ¶
type SymbolFilterMinNotional struct {
FilterType SymbolFilterType `json:"filterType"`
MinNotional float64 `json:"minNotional"`
ApplyToMarket bool `json:"applyToMarket"`
AvgPriceMins int `json:"avgPriceMins"`
}
type SymbolFilterNotional ¶
type SymbolFilterNotional struct {
FilterType SymbolFilterType `json:"filterType"`
MinNotional float64 `json:"minNotional,string"`
ApplyMinToMarket bool `json:"applyMinToMarket"`
MaxNotional float64 `json:"maxNotional,string"`
ApplyMaxToMarket bool `json:"applyMaxToMarket"`
AvgPriceMins int `json:"avgPriceMins"`
}
type SymbolFilterPercentPrice ¶
type SymbolFilterPercentPrice struct {
FilterType SymbolFilterType `json:"filterType"`
MultiplierUp float64 `json:"multiplierUp,string"`
MultiplierDown float64 `json:"multiplierDown,string"`
AvgPriceMins int `json:"avgPriceMins"`
}
type SymbolFilterPercentPriceBySide ¶
type SymbolFilterPercentPriceBySide struct {
FilterType SymbolFilterType `json:"filterType"`
BidMultiplierUp float64 `json:"bidMultiplierUp,string"`
BidMultiplierDown float64 `json:"bidMultiplierDown,string"`
AskMultiplierUp float64 `json:"askMultiplierUp,string"`
AskMultiplierDown float64 `json:"askMultiplierDown,string"`
AvgPriceMins int `json:"avgPriceMins"`
}
type SymbolFilterPriceFilter ¶
type SymbolFilterPriceFilter struct {
FilterType SymbolFilterType `json:"filterType"`
MinPrice float64 `json:"minPrice,string"`
MaxPrice float64 `json:"maxPrice,string"`
TickSize float64 `json:"tickSize,string"`
}
type SymbolFilterTrailingDelta ¶
type SymbolFilterTrailingDelta struct {
FilterType SymbolFilterType `json:"filterType"`
MinTrailingAboveDelta int `json:"minTrailingAboveDelta"`
MaxTrailingAboveDelta int `json:"maxTrailingAboveDelta"`
MinTrailingBelowDelta int `json:"minTrailingBelowDelta"`
MaxTrailingBelowDelta int `json:"maxTrailingBelowDelta"`
}
type SymbolFilterType ¶
type SymbolFilterType string
const ( PRICE_FILTER SymbolFilterType = "PRICE_FILTER" PERCENT_PRICE SymbolFilterType = "PERCENT_PRICE" PERCENT_PRICE_BY_SIDE SymbolFilterType = "PERCENT_PRICE_BY_SIDE" LOT_SIZE SymbolFilterType = "LOT_SIZE" MIN_NOTIONAL SymbolFilterType = "MIN_NOTIONAL" NOTIONAL SymbolFilterType = "NOTIONAL" ICEBERG_PARTS SymbolFilterType = "ICEBERG_PARTS" MARKET_LOT_SIZE SymbolFilterType = "MARKET_LOT_SIZE" MAX_NUM_ORDERS SymbolFilterType = "MAX_NUM_ORDERS" MAX_NUM_ALGO_ORDERS SymbolFilterType = "MAX_NUM_ALGO_ORDERS" MAX_NUM_ICEBERG_ORDERS SymbolFilterType = "MAX_NUM_ICEBERG_ORDERS" MAX_POSITION SymbolFilterType = "MAX_POSITION" TRAILING_DELTA SymbolFilterType = "TRAILING_DELTA" MAX_NUM_ORDER_AMENDS SymbolFilterType = "MAX_NUM_ORDER_AMENDS" MAX_NUM_ORDER_LISTS SymbolFilterType = "MAX_NUM_ORDER_LISTS" )
type SymbolFilters ¶
type SymbolFilters struct {
PRICE_FILTER *SymbolFilterPriceFilter
PERCENT_PRICE *SymbolFilterPercentPrice
PERCENT_PRICE_BY_SIDE *SymbolFilterPercentPriceBySide
LOT_SIZE *SymbolFilterLotSize
MIN_NOTIONAL *SymbolFilterMinNotional
NOTIONAL *SymbolFilterNotional
ICEBERG_PARTS *SymbolFilterIcebergParts
MARKET_LOT_SIZE *SymbolFilterMarketLotSize
MAX_NUM_ORDERS *SymbolFilterMaxNumOrders
MAX_NUM_ALGO_ORDERS *SymbolFilterMaxNumAlgoOrders
MAX_NUM_ICEBERG_ORDERS *SymbolFilterMaxNumIcebergOrders
MAX_POSITION *SymbolFilterMaxPosition
TRAILING_DELTA *SymbolFilterTrailingDelta
MAX_NUM_ORDER_AMENDS *SymbolFilterMaxNumOrderAmends
MAX_NUM_ORDER_LISTS *SymbolFilterMaxNumOrderLists
}
func (*SymbolFilters) UnmarshalJSON ¶
func (symbolFilters *SymbolFilters) UnmarshalJSON(data []byte) error
type SymbolRule ¶
type SymbolRule struct {
Symbol string `json:"symbol"`
Rules SymbolRules `json:"rules"`
}
type SymbolRulePriceRange ¶
type SymbolRulePriceRange struct {
RuleType ExecutionRule `json:"ruleType"`
BidLimitMultUp float64 `json:"bidLimitMultUp,string"`
BidLimitMultDown float64 `json:"bidLimitMultDown,string"`
AskLimitMultUp float64 `json:"askLimitMultUp,string"`
AskLimitMultDown float64 `json:"askLimitMultDown,string"`
}
type SymbolRules ¶
type SymbolRules struct {
PRICE_RANGE *SymbolRulePriceRange
}
func (*SymbolRules) UnmarshalJSON ¶
func (symbolRules *SymbolRules) UnmarshalJSON(data []byte) error
type SymbolStatus ¶
type SymbolStatus string
const ( // Trading is active for the symbol. Trading SymbolStatus = "TRADING" // Trading has ended for the current trading day. EndOfDay SymbolStatus = "END_OF_DAY" // Trading is halted for the symbol. Halt SymbolStatus = "HALT" // Trading is paused for a scheduled break. Break SymbolStatus = "BREAK" )
type Ticker24h ¶
type Ticker24h struct {
Symbol string `json:"symbol"`
PriceChange float64 `json:"priceChange,string"`
PriceChangePercent float64 `json:"priceChangePercent,string"`
WeightedAvgPrice float64 `json:"weightedAvgPrice,string"`
PrevClosePrice float64 `json:"prevClosePrice,string"`
LastPrice float64 `json:"lastPrice,string"`
LastQty float64 `json:"lastQty,string"`
BidPrice float64 `json:"bidPrice,string"`
BidQty float64 `json:"bidQty,string"`
AskPrice float64 `json:"askPrice,string"`
AskQty float64 `json:"askQty,string"`
OpenPrice float64 `json:"openPrice,string"`
HighPrice float64 `json:"highPrice,string"`
LowPrice float64 `json:"lowPrice,string"`
Volume float64 `json:"volume,string"`
QuoteVolume float64 `json:"quoteVolume,string"`
OpenTime int64 `json:"openTime"`
CloseTime int64 `json:"closeTime"`
FirstID int64 `json:"firstId"`
LastID int64 `json:"lastId"`
Count int64 `json:"count"`
}
type Ticker24hParams ¶
type Ticker24hParams struct {
SymbolStatus SymbolStatus
}
type TickerWebsocket ¶
type TickerWebsocket struct {
// contains filtered or unexported fields
}
func (TickerWebsocket) ListSubscriptions ¶
func (TickerWebsocket) ReadSubscriptions ¶
func (s TickerWebsocket) ReadSubscriptions() []string
func (*TickerWebsocket) Subscribe ¶
func (tws *TickerWebsocket) Subscribe(symbols ...string) Error
func (*TickerWebsocket) Unsubscribe ¶
func (tws *TickerWebsocket) Unsubscribe(symbols ...string) Error
type Tickers24hParams ¶
type Tickers24hParams struct {
Symbols []string
SymbolStatus SymbolStatus
}
type TimeInForce ¶
type TimeInForce string
const ( // Good Til Canceled — order remains on the book until canceled. GTC TimeInForce = "GTC" // Immediate Or Cancel — order executes immediately and any unfilled portion is canceled. IOC TimeInForce = "IOC" // Fill Or Kill — order must be completely filled immediately or canceled. FOK TimeInForce = "FOK" )
type Trade ¶
type Trade struct {
Id int64 `json:"id"`
Price float64 `json:"price,string"`
Qty float64 `json:"qty,string"`
QuoteQty float64 `json:"quoteQty,string"`
Time int64 `json:"time"`
IsBuyerMaker bool `json:"isBuyerMaker"`
IsBestMatch bool `json:"isBestMatch"`
}
Trade
type TradeWebsocket ¶
type TradeWebsocket struct {
// contains filtered or unexported fields
}
func (TradeWebsocket) ListSubscriptions ¶
func (TradeWebsocket) ReadSubscriptions ¶
func (s TradeWebsocket) ReadSubscriptions() []string
func (*TradeWebsocket) Subscribe ¶
func (rpws *TradeWebsocket) Subscribe(symbols ...string) Error
func (*TradeWebsocket) Unsubscribe ¶
func (rpws *TradeWebsocket) Unsubscribe(symbols ...string) Error
type TradingDayMiniTicker ¶
type TradingDayMiniTicker struct {
Symbol string `json:"symbol"`
OpenPrice float64 `json:"openPrice,string"`
HighPrice float64 `json:"highPrice,string"`
LowPrice float64 `json:"lowPrice,string"`
LastPrice float64 `json:"lastPrice,string"`
Volume float64 `json:"volume,string"`
QuoteVolume float64 `json:"quoteVolume,string"`
OpenTime int64 `json:"openTime"`
CloseTime int64 `json:"closeTime"`
FirstID int64 `json:"firstId"`
LastID int64 `json:"lastId"`
Count int64 `json:"count"`
}
type TradingDayTicker ¶
type TradingDayTicker struct {
Symbol string `json:"symbol"`
PriceChange float64 `json:"priceChange,string"`
PriceChangePercent float64 `json:"priceChangePercent,string"`
WeightedAvgPrice float64 `json:"weightedAvgPrice,string"`
OpenPrice float64 `json:"openPrice,string"`
HighPrice float64 `json:"highPrice,string"`
LowPrice float64 `json:"lowPrice,string"`
LastPrice float64 `json:"lastPrice,string"`
Volume float64 `json:"volume,string"`
QuoteVolume float64 `json:"quoteVolume,string"`
OpenTime int64 `json:"openTime"`
CloseTime int64 `json:"closeTime"`
FirstID int64 `json:"firstId"`
LastID int64 `json:"lastId"`
Count int64 `json:"count"`
}
type TradingDayTickerParams ¶
type TradingDayTickerParams struct {
SymbolStatus SymbolStatus
TimeZone string
}
type TradingDayTickersParams ¶
type TradingDayTickersParams struct {
Symbols []string
SymbolStatus SymbolStatus
TimeZone string
}
type UnfilledOrderCount ¶
type UnfilledOrderCount struct {
RateLimitType RateLimitType `json:"rateLimitType"`
Interval RateLimitInterval `json:"interval"`
IntervalNum int64 `json:"intervalNum"`
Limit int `json:"limit"`
Count int `json:"count"`
}
type UnfilledOrderCountParams ¶
type UnfilledOrderCountParams struct {
RecvWindow int
}
type UserDataBalance ¶
type UserDataEvent ¶
type UserDataEvent struct {
SubscriptionID int `json:"subscriptionId"`
EventType UserDataEventType `json:"-"`
EventTime int64 `json:"-"`
// Exactly one of these will be non-nil
AccountPosition *OutboundAccountPositionEvent `json:"-"`
BalanceUpdate *BalanceUpdateEvent `json:"-"`
ExecutionReport *ExecutionReportEvent `json:"-"`
ListStatus *ListStatusEvent `json:"-"`
StreamTerminated *EventStreamTerminatedEvent `json:"-"`
ExternalLock *ExternalLockUpdateEvent `json:"-"`
}
func (*UserDataEvent) UnmarshalJSON ¶
func (u *UserDataEvent) UnmarshalJSON(data []byte) error
type UserDataEventType ¶
type UserDataEventType string
const ( EventOutboundAccountPosition UserDataEventType = "outboundAccountPosition" EventBalanceUpdate UserDataEventType = "balanceUpdate" EventExecutionReport UserDataEventType = "executionReport" EventListStatus UserDataEventType = "listStatus" EventStreamTerminated UserDataEventType = "eventStreamTerminated" EventExternalLockUpdate UserDataEventType = "externalLockUpdate" )
func (UserDataEventType) IsValid ¶
func (e UserDataEventType) IsValid() bool
type UserDataRawEvent ¶
type UserDataRawEvent struct {
SubscriptionID int `json:"subscriptionId"`
Event json.RawMessage `json:"event"`
}
type UserDataSubscribeResponse ¶
type UserDataSubscribeResponse struct {
SubscriptionId int `json:"subscriptionId"`
}
type UserDataWebsocket ¶
type UserDataWebsocket struct {
// contains filtered or unexported fields
}
func (*UserDataWebsocket) Close ¶
func (uws *UserDataWebsocket) Close()
type WebsocketAPI ¶
type WebsocketAPI struct {
// contains filtered or unexported fields
}
func (*WebsocketAPI) Account ¶ added in v0.2.1
func (wsapi *WebsocketAPI) Account(opts ...AccountParams) (*Account, *WsApiResponse, Error)
func (*WebsocketAPI) AccountCommission ¶ added in v0.2.1
func (wsapi *WebsocketAPI) AccountCommission(symbol string, opts ...AccountCommissionParams) (*AccountCommission, *WsApiResponse, Error)
func (*WebsocketAPI) AggTrades ¶
func (wsapi *WebsocketAPI) AggTrades(symbol string, opts ...AggTradeParams) ([]*AggTrade, *WsApiResponse, Error)
func (*WebsocketAPI) AllOrders ¶ added in v0.2.1
func (wsapi *WebsocketAPI) AllOrders(symbol string, opts ...AllOrdersParams) ([]*Order, *WsApiResponse, Error)
func (*WebsocketAPI) AveragePrice ¶
func (wsapi *WebsocketAPI) AveragePrice(symbol string) (*AveragePrice, *WsApiResponse, Error)
func (*WebsocketAPI) BookTicker ¶
func (wsapi *WebsocketAPI) BookTicker(symbol string, opts ...OrderBookTickerParams) (*OrderBookTicker, *WsApiResponse, Error)
func (*WebsocketAPI) BookTickers ¶
func (wsapi *WebsocketAPI) BookTickers(opts ...OrderBookTickersParams) ([]*OrderBookTicker, *WsApiResponse, Error)
func (*WebsocketAPI) CancelOpenOrders ¶ added in v0.2.1
func (wsapi *WebsocketAPI) CancelOpenOrders(symbol string, opts ...CancelOpenOrdersParams) ([]*Order, *WsApiResponse, Error)
func (*WebsocketAPI) CancelOrder ¶ added in v0.2.1
func (wsapi *WebsocketAPI) CancelOrder(symbol string, orderId int64, opts ...CancelOrderParams) (*Order, *WsApiResponse, Error)
func (*WebsocketAPI) Candlesticks ¶
func (wsapi *WebsocketAPI) Candlesticks(symbol string, interval Interval, opts ...CandlestickParams) ([]*Candlestick, *WsApiResponse, Error)
func (*WebsocketAPI) Close ¶
func (wsapi *WebsocketAPI) Close()
func (*WebsocketAPI) HistoricalTrades ¶
func (wsapi *WebsocketAPI) HistoricalTrades(symbol string, opts ...HistoricalTradesParams) ([]*Trade, *WsApiResponse, Error)
func (*WebsocketAPI) MiniTicker24h ¶
func (wsapi *WebsocketAPI) MiniTicker24h(symbol string, opts ...MiniTicker24hParams) (*MiniTicker24h, *WsApiResponse, Error)
func (*WebsocketAPI) MiniTickers24h ¶
func (wsapi *WebsocketAPI) MiniTickers24h(opts ...MiniTickers24hParams) ([]*MiniTicker24h, *WsApiResponse, Error)
func (*WebsocketAPI) OpenOrders ¶ added in v0.2.1
func (wsapi *WebsocketAPI) OpenOrders(opts ...OpenOrdersParams) ([]*Order, *WsApiResponse, Error)
func (*WebsocketAPI) OrderBook ¶
func (wsapi *WebsocketAPI) OrderBook(symbol string, opts ...OrderBookParams) (*OrderBook, *WsApiResponse, Error)
func (*WebsocketAPI) PlaceOrder ¶ added in v0.2.1
func (wsapi *WebsocketAPI) PlaceOrder(req orderRequest) (*Order, *WsApiResponse, Error)
PlaceOrder sends a new order request over the WebSocket API (method "order.place").
It accepts any orderRequest implementation (e.g. NewLimitBuy, NewMarketSell, NewStopLossLimitOrder, etc.) — the exact same request builders used by the REST Client.Order — and submits it to the exchange over the WebSocket connection.
The response type is controlled by newOrderRespType (ACK, RESULT or FULL), exactly as with the REST endpoint.
func (*WebsocketAPI) PlaceSorOrder ¶ added in v0.2.1
func (wsapi *WebsocketAPI) PlaceSorOrder(req orderRequest) (*Order, *WsApiResponse, Error)
func (*WebsocketAPI) PriceTicker ¶
func (wsapi *WebsocketAPI) PriceTicker(symbol string, opts ...PriceTickerParams) (*PriceTicker, *WsApiResponse, Error)
func (*WebsocketAPI) PriceTickers ¶
func (wsapi *WebsocketAPI) PriceTickers(opts ...PriceTickersParams) ([]*PriceTicker, *WsApiResponse, Error)
func (*WebsocketAPI) QueryOrder ¶ added in v0.2.1
func (wsapi *WebsocketAPI) QueryOrder(symbol string, opts ...QueryOrderParams) (*Order, *WsApiResponse, Error)
func (*WebsocketAPI) RecentTrades ¶
func (wsapi *WebsocketAPI) RecentTrades(symbol string, opts ...RecentTradesParams) ([]*Trade, *WsApiResponse, Error)
func (*WebsocketAPI) ReferencePrice ¶
func (wsapi *WebsocketAPI) ReferencePrice(symbol string) (*ReferencePrice, *WsApiResponse, Error)
func (*WebsocketAPI) ReferencePriceCalculation ¶
func (wsapi *WebsocketAPI) ReferencePriceCalculation(symbol string, opts ...ReferencePriceCalculationParams) (*ReferencePriceCalculation, *WsApiResponse, Error)
func (*WebsocketAPI) RollingWindowMiniTicker ¶
func (wsapi *WebsocketAPI) RollingWindowMiniTicker(symbol string, opts ...RollingWindowTickerMiniParams) (*RollingWindowMiniTicker, *WsApiResponse, Error)
func (*WebsocketAPI) RollingWindowMiniTickers ¶
func (wsapi *WebsocketAPI) RollingWindowMiniTickers(opts ...RollingWindowMiniTickersParams) ([]*RollingWindowMiniTicker, *WsApiResponse, Error)
// Rolling Window MiniTicker/s //
func (*WebsocketAPI) RollingWindowTicker ¶
func (wsapi *WebsocketAPI) RollingWindowTicker(symbol string, opts ...RollingWindowTickerParams) (*RollingWindowTicker, *WsApiResponse, Error)
func (*WebsocketAPI) RollingWindowTickers ¶
func (wsapi *WebsocketAPI) RollingWindowTickers(opts ...RollingWindowTickersParams) ([]*RollingWindowTicker, *WsApiResponse, Error)
func (*WebsocketAPI) TestOrder ¶ added in v0.2.1
func (wsapi *WebsocketAPI) TestOrder(req orderRequest, computeCommissionRates bool) (*OrderTest, *WsApiResponse, Error)
TestOrder validates a new order without sending it to the matching engine (method "order.test").
NOTE: If computeCommissionRates is false, Binance returns an empty JSON object `{}`. In that case, all fields in OrderTest will remain zero values.
func (*WebsocketAPI) TestSorOrder ¶ added in v0.2.1
func (wsapi *WebsocketAPI) TestSorOrder(req orderRequest, computeCommissionRates bool) (*OrderTest, *WsApiResponse, Error)
func (*WebsocketAPI) Ticker24h ¶
func (wsapi *WebsocketAPI) Ticker24h(symbol string, opts ...Ticker24hParams) (*Ticker24h, *WsApiResponse, Error)
func (*WebsocketAPI) Tickers24h ¶
func (wsapi *WebsocketAPI) Tickers24h(opts ...Tickers24hParams) ([]*Ticker24h, *WsApiResponse, Error)
func (*WebsocketAPI) Trades ¶ added in v0.2.1
func (wsapi *WebsocketAPI) Trades(symbol string, opts ...AccountTradesParam) ([]*Trade, *WsApiResponse, Error)
func (*WebsocketAPI) TradingDayMiniTicker ¶
func (wsapi *WebsocketAPI) TradingDayMiniTicker(symbol string, opts ...TradingDayTickerParams) (*TradingDayMiniTicker, *WsApiResponse, Error)
func (*WebsocketAPI) TradingDayMiniTickers ¶
func (wsapi *WebsocketAPI) TradingDayMiniTickers(opts ...TradingDayTickersParams) ([]*TradingDayMiniTicker, *WsApiResponse, Error)
func (*WebsocketAPI) TradingDayTicker ¶
func (wsapi *WebsocketAPI) TradingDayTicker(symbol string, opts ...TradingDayTickerParams) (*TradingDayTicker, *WsApiResponse, Error)
func (*WebsocketAPI) TradingDayTickers ¶
func (wsapi *WebsocketAPI) TradingDayTickers(opts ...TradingDayTickersParams) ([]*TradingDayTicker, *WsApiResponse, Error)
func (*WebsocketAPI) UIKlines ¶
func (wsapi *WebsocketAPI) UIKlines(symbol string, interval Interval, opts ...CandlestickParams) ([]*Candlestick, *WsApiResponse, Error)
func (*WebsocketAPI) UnfilledOrderCount ¶ added in v0.2.1
func (wsapi *WebsocketAPI) UnfilledOrderCount(opts ...UnfilledOrderCountParams) ([]*UnfilledOrderCount, *WsApiResponse, Error)
type WorkingFloor ¶
type WorkingFloor string
const ( // Order executed directly on the exchange order book. Exchange WorkingFloor = "EXCHANGE" // Order executed through Smart Order Routing. Sor WorkingFloor = "SOR" )
type WsAggTrade ¶
type WsAggTrade struct {
Event EventType `json:"e"`
EventTime int64 `json:"E"`
Symbol string `json:"s"`
AggTradeID int64 `json:"a"`
Price float64 `json:"p,string"`
Quantity float64 `json:"q,string"`
FirstTradeID int64 `json:"f"`
LastTradeID int64 `json:"l"`
TradeTime int64 `json:"T"`
IsMaker bool `json:"m"`
}
type WsApiError ¶
type WsApiError struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data json.RawMessage `json:"data"`
}
type WsApiResponse ¶
type WsApiResponse struct {
Id string `json:"id"`
Status int `json:"status"`
Error *WsApiError `json:"error"`
Result json.RawMessage `json:"result"`
RateLimits []RateLimit `json:"rateLimits"`
}
Status codes in the status field are the same as in HTTP. Here are some common status codes that you might encounter:
- 200 indicates a successful response.
- 4XX status codes indicate invalid requests; the issue is on your side.
- 400 – your request failed, see error for the reason.
- 403 – you have been blocked by the Web Application Firewall. This can indicate a rate limit violation or a security block. See https://www.binance.com/en/support/faq/detail/360004492232 for more details.
- 409 – your request partially failed but also partially succeeded, see error for details.
- 418 – you have been auto-banned for repeated violation of rate limits.
- 429 – you have exceeded API request rate limit, please slow down.
- 5XX status codes indicate internal errors; the issue is on Binance's side.
Important: If a response contains 5xx status code, it does not necessarily mean that your request has failed. Execution status is unknown and the request might have actually succeeded. Please use query methods to confirm the status. You might also want to establish a new WebSocket connection for that.
type WsAveragePrice ¶
type WsCandlestick ¶
type WsCandlestick struct {
OpenTime int64 `json:"t"`
CloseTime int64 `json:"T"`
Symbol string `json:"s"`
Interval Interval `json:"i"`
FirstTradeID int64 `json:"f"`
LastTradeID int64 `json:"L"`
Open float64 `json:"o,string"`
Close float64 `json:"c,string"`
High float64 `json:"h,string"`
Low float64 `json:"l,string"`
Volume float64 `json:"v,string"`
TradeCount int64 `json:"n"`
IsClosed bool `json:"x"`
QuoteVolume float64 `json:"q,string"`
TakerBuyBaseVolume float64 `json:"V,string"`
TakerBuyQuoteVolume float64 `json:"Q,string"`
}
type WsCandlesticksInterval ¶
type WsCandlesticksInterval string
const ( WsKlineFast WsCandlesticksInterval = "1000ms" WsKlineSlow WsCandlesticksInterval = "2000ms" )
type WsCandlesticksParams ¶
type WsCandlesticksParams struct {
Symbol string
Interval WsCandlesticksInterval
}
type WsDiffDepth ¶
type WsDiffDepth struct {
Event EventType `json:"e"`
EventTime int64 `json:"E"`
Symbol string `json:"s"`
FirstID int64 `json:"U"`
FinalID int64 `json:"u"`
Bids []PriceLevel `json:"b"`
Asks []PriceLevel `json:"a"`
}
type WsDiffDepthInterval ¶
type WsDiffDepthInterval string
const ( WsDepthFast WsDiffDepthInterval = "100ms" WsDepthSlow WsDiffDepthInterval = "" )
type WsDiffDepthParams ¶
type WsDiffDepthParams struct {
Symbol string
Speed WsDiffDepthInterval
}
type WsKline ¶
type WsKline struct {
Event EventType `json:"e"`
EventTime int64 `json:"E"`
Symbol string `json:"s"`
Kline WsCandlestick `json:"k"`
}
type WsMiniTicker ¶
type WsMiniTicker struct {
Event EventType `json:"e"`
EventTime int64 `json:"E"`
Symbol string `json:"s"`
Open float64 `json:"o,string"`
High float64 `json:"h,string"`
Low float64 `json:"l,string"`
Close float64 `json:"c,string"`
Volume float64 `json:"v,string"`
QuoteVolume float64 `json:"q,string"`
}
type WsOrderBook ¶
type WsOrderBook struct {
LastUpdateID int64 `json:"lastUpdateId"`
Bids []PriceLevel `json:"bids"`
Asks []PriceLevel `json:"asks"`
}
type WsOrderBookParams ¶
type WsOrderBookParams struct {
Symbol string
Speed WsDiffDepthInterval
// 5, 10 or 20
Levels int
}
type WsReferencePrice ¶
type WsRollingWindowParams ¶
type WsRollingWindowTicker ¶
type WsRollingWindowTicker struct {
Event EventType `json:"e"`
EventTime int64 `json:"E"`
Symbol string `json:"s"`
PriceChange float64 `json:"p,string"`
PriceChangePercent float64 `json:"P,string"`
Open float64 `json:"o,string"`
HighPrice float64 `json:"h,string"`
LowPrice float64 `json:"l,string"`
LastPrice float64 `json:"c,string"`
WeightedAvgPrice float64 `json:"w,string"`
Volume float64 `json:"v,string"`
QuoteVolume float64 `json:"q,string"`
OpenTime int64 `json:"O"`
CloseTime int64 `json:"C"`
FirstTradeID int64 `json:"F"`
LastTradeID int64 `json:"L"`
TradeCount int64 `json:"n"`
}
type WsTicker ¶
type WsTicker struct {
Event EventType `json:"e"`
EventTime int64 `json:"E"`
Symbol string `json:"s"`
PriceChange float64 `json:"p,string"`
PriceChangePercent float64 `json:"P,string"`
WeightedAvgPrice float64 `json:"w,string"`
FirstPrice float64 `json:"x,string"`
LastPrice float64 `json:"c,string"`
LastQuantity float64 `json:"Q,string"`
BestBidPrice float64 `json:"b,string"`
BestBidQty float64 `json:"B,string"`
BestAskPrice float64 `json:"a,string"`
BestAskQty float64 `json:"A,string"`
Open float64 `json:"o,string"`
High float64 `json:"h,string"`
Low float64 `json:"l,string"`
Volume float64 `json:"v,string"`
QuoteVolume float64 `json:"q,string"`
OpenTime int64 `json:"O"`
CloseTime int64 `json:"C"`
FirstTradeID int64 `json:"F"`
LastTradeID int64 `json:"L"`
TradeCount int64 `json:"n"`
}