Documentation
¶
Overview ¶
Package binance provides a lightweight wrapper for the Binance REST API. It is a work in progress. This package focuses on endpoints and functions allowed by the binance.us API, and is based on the specification provided by Binance at https://docs.binance.us. It has not been tested on the binance.com API.
Index ¶
- Constants
- Variables
- func Itot(i int) time.Time
- type Account
- type AggregateTrade
- type AvgPriceResp
- type BaseUrl
- type BookDepth
- type BookTickerResp
- type CancelOrderParams
- type CancellationResp
- type Client
- func (c Client) Account() (Account, error)
- func (c Client) AggregateTrades(symbol string, limit, fromId int, startTime, endTime time.Time) ([]AggregateTrade, error)
- func (c Client) AvgPrice(symbol string) (AvgPriceResp, error)
- func (c Client) BookTicker(symbol string) (BookTickerResp, error)
- func (c Client) BookTickers(symbols []string) ([]BookTickerResp, error)
- func (c Client) CancelAll(symbol string) ([]TradeAck, error)
- func (c Client) CancelOrder(symbol string, orderId int) (CancellationResp, error)
- func (c Client) CancelOrder2(symbol string, clientOrderId string) (CancellationResp, error)
- func (c Client) CancelOrder3(cop CancelOrderParams) (CancellationResp, error)
- func (c Client) CloseUserDataStream(listenKey string) error
- func (c Client) CreateUserDataStream() (string, error)
- func (c Client) DayPriceChange(symbol string) (PriceChange, error)
- func (c Client) DayPriceChanges(symbols []string) ([]PriceChange, error)
- func (c Client) ExchangeInfo() (ExchangeInfoResp, error)
- func (c Client) ExtendUserDataStream(listenKey string) error
- func (c Client) HistoricalTrades(symbol string, limit, fromId int) ([]RecentTradesResp, error)
- func (c Client) Klines(symbol, interval string, limit int, startTime, endTime time.Time) ([]Kline, error)
- func (c Client) OCOCancelOrderList(oc OCOCancelParams) (OCOCancellationResp, error)
- func (c Client) OpenOrders() ([]OpenOrderResp, error)
- func (c Client) OrderBookDepth(symbol string, limit int) (BookDepth, error)
- func (c Client) OrderInfo(symbol string, orderId int) (OrderInfoResp, error)
- func (c Client) OrderInfo2(symbol string, clientOrderId string) (OrderInfoResp, error)
- func (c Client) PermissionsInfo(permission string) (ExchangeInfoResp, error)
- func (c Client) Ping() error
- func (c Client) RecentTrades(symbol string, limit int) ([]RecentTradesResp, error)
- func (c Client) RollingChange(symbol string, windowSize uint, windowSizeUnit IntervalUnit) (PriceChange, error)
- func (c Client) ServerTime() (time.Time, error)
- func (c Client) Sign(s string) string
- func (c Client) SymbolInfo(symbol string) (ExchangeInfoResp, error)
- func (c Client) SymbolsInfo(symbols []string) (ExchangeInfoResp, error)
- func (c Client) SystemStatus() (int, error)
- func (c Client) TestTrade(o Order) (TradeResp, error)
- func (c Client) TickerPrice(symbol string) (TickerResp, error)
- func (c Client) TickerPrices(symbols []string) ([]TickerResp, error)
- func (c Client) Trade(o Order) (TradeResp, error)
- func (c Client) TradeOCO(o OCOOrder) (OCOTradeResp, error)
- func (c Client) UserTrades(u UserTradesParams) ([]UserTradeResp, error)
- type ExchangeInfoResp
- type Filter
- type IntervalUnit
- type Kline
- type LimitMakerOrder
- type LimitOrder
- type MarketOrder
- type OCOCancelParams
- type OCOCancellationResp
- type OCOListStatus
- type OCOOrder
- type OCOOrderStatus
- type OCOTradeResp
- type OpenOrderResp
- type Order
- type OrderInfoResp
- type OrderRespType
- type OrderStatus
- type OrderType
- type Permission
- type PriceChange
- type RateLimit
- type RawFilter
- type RawOrder
- type RecentTradesResp
- type RespErr
- type SelfTradePreventionMode
- type Side
- type StopLossLimitOrder
- type StopLossOrder
- type Symbol
- type TakeProfitLimitOrder
- type TakeProfitOrder
- type TickerResp
- type TimeInForce
- type TradeAck
- type TradeFull
- type TradeResp
- type TradeResult
- type UserTradeResp
- type UserTradesParams
Constants ¶
const ( ACCT = "/api/v3/account" AGG_TRADES = "/api/v3/aggTrades" ALL_ORDER_LIST = "/api/v3/allOrderList" AVG_PRICE = "/api/v3/avgPrice" BOOK_DEPTH = "/api/v3/depth" BOOK_TICKER = "/api/v3/ticker/bookTicker" DAY_CHANGE = "/api/v3/ticker/24hr" EXCHANGE_INFO = "/api/v3/exchangeInfo" HIST_TRADES = "/api/v3/historicalTrades" KLINES = "/api/v3/klines" OCO_ORDER = "/api/v3/order/oco" OPEN_ORDER_LIST = "/api/v3/openOrderList" OPEN_ORDERS = "/api/v3/openOrders" ORDER = "/api/v3/order" ORDER_LIST = "/api/v3/orderList" PING = "/api/v3/ping" PRICE = "/api/v3/ticker/price" RECENT_TRADES = "/api/v3/trades" SYSTEM_STATUS = "/sapi/v1/system/status" TEST_ORDER = "/api/v3/order/test" TICKER = "/api/v3/ticker" TICKER_PRICE = "/api/v3/ticker/price" TIME = "/api/v3/time" USER_DATA = "/api/v3/userDataStream" USER_TRADES = "/api/v3/myTrades" )
const ( PRICE_FILTER = "PRICE_FILTER" PERCENT_PRICE = "PERCENT_PRICE" PERCENT_PRICE_BY_SIDE = "PERCENT_PRICE_BY_SIDE" LOT_SIZE = "LOT_SIZE" NOTIONAL = "NOTIONAL" MIN_NOTIONAL = "MIN_NOTIONAL" ICEBERG_PARTS = "ICEBERG_PARTS" MARKET_LOT_SIZE = "MARKET_LOT_SIZE" MAX_NUM_ORDERS = "MAX_NUM_ORDERS" MAX_NUM_ALGO_ORDERS = "MAX_NUM_ALGO_ORDERS" MAX_NUM_ICEBERG_ORDERS = "MAX_NUM_ICEBERG_ORDERS" MAX_POSITION = "MAX_POSITION" TRAILING_DELTA = "TRAILING_DELTA" )
const ( EXCHANGE_MAX_NUM_ORDERS = "EXCHANGE_MAX_NUM_ORDERS" EXCHANGE_MAX_ALGO_ORDERS = "EXCHANGE_MAX_ALGO_ORDERS" EXCHANGE_MAX_NUM_ICEBERG_ORDERS = "EXCHANGE_MAX_NUM_ICEBERG_ORDERS" )
Variables ¶
var ( ErrUnknown = errors.New("- 1000 UNKNOWN") ErrDisconnect = errors.New("- 1001 DISCONNECTED") ErrUnauth = errors.New("- 1002 UNAUTHORIZED") ErrTooManyReqs = errors.New("- 1003 TOO_MANY_REQUESTS") ErrUnexpected = errors.New("- 1006 UNEXPECTED_RESP") ErrTimeOut = errors.New("- 1007 TIMEOUT") ErrBusy = errors.New("- 1008 SERVER_BUSY") ErrOrderComp = errors.New("- 1014 UNKNOWN_ORDER_COMPOSITION") ErrTooManyOrd = errors.New("- 1015 TOO_MANY_ORDERS") ErrServiceDown = errors.New("- 1016 SERVICE_SHUTTING_DOWN") ErrUnsuported = errors.New("- 1020 UNSUPPORTED_OPERATION") ErrTimestamp = errors.New("- 1021 INVALID_TIMESTAMP") ErrSignature = errors.New("- 1022 INVALID_SIGNATURE") ErrIllChar = errors.New("- 1100 ILLEGAL_CHARS") ErrTooManyPar = errors.New("- 1101 TOO_MANY_PARAMETERS") ErrBadParam = errors.New("- 1102 MANDATORY_PARAM_EMPTY_OR_MALFORMED") ErrUnknownParam = errors.New("- 1103 UNKNOWN_PARAM") ErrUnreadParams = errors.New("- 1104 UNREAD_PARAMETERS") ErrEmptyParam = errors.New("- 1105 PARAM_EMPTY") ErrParamNR = errors.New("- 1106 PARAM_NOT_REQUIRED") ErrParamOverflow = errors.New("- 1108 PARAM_OVERFLOW") ErrBadPrecision = errors.New("- 1111 BAD_PRECISION") ErrNoDepth = errors.New("- 1112 NO_DEPTH") ErrTIFNR = errors.New("- 1114 TIF_NOT_REQUIRED") ErrBadTIF = errors.New("- 1115 INVALID_TIF") ErrBadOrderType = errors.New("- 1116 INVALID_ORDER_TYPE") ErrBadSide = errors.New("- 1117 INVALID_SIDE") ErrEmptyNewClOId = errors.New("- 1118 EMPTY_NEW_CL_ORD_ID") ErrEmptyOrigClOId = errors.New("- 1119 EMPTY_ORG_CL_ORD_ID") ErrBadInterval = errors.New("- 1120 BAD_INTERVAL") ErrBadSymbol = errors.New("- 1121 BAD_SYMBOL") ErrBadListenKey = errors.New("- 1125 INVALID_LISTEN_KEY") ErrMoreThanXXHrs = errors.New("- 1127 MORE_THAN_XX_HOURS") ErrBadParamsCombo = errors.New("- 1128 OPTIONAL_PARAMS_BAD_COMBO") ErrReqBadParam = errors.New("- 1130 INVALID_PARAMETER") ErrBadJson = errors.New("- 1135 INVALID_JSON") ErrNewOrderReject = errors.New("- 2010 NEW_ORDER_REJECTED") ErrCancelReject = errors.New("- 2011 CANCEL_REJECTED") ErrNoSuchOrder = errors.New("- 2013 NO_SUCH_ORDER") ErrBadApiKey = errors.New("- 2014 BAD_API_KEY_FMT") ErrBadMbxKey = errors.New("- 2015 REJECTED_MBX_KEY") ErrTradingWindow = errors.New("- 2016 NO_TRADING_WINDOW") ErrPartialFail = errors.New("- 2021 Order cancel-replace partially failed") ErrCancelReplaceFail = errors.New("- 2022 Order cancel-replace failed") ErrMsgReceived = errors.New("- 1010 ERROR_MSG_RECEIVED") ErrWsUknownProperty = errors.New("0 unknown property") ErrWsBadValueType = errors.New("1 invalid value type") ErrWsBadRequest = errors.New("2 invalid request") ErrWsBadJson = errors.New("3 invalid json") ErrRespParse = errors.New("client could not parse error response from binance api") )
Functions ¶
Types ¶
type Account ¶
type Account struct { MakerCommission int `json:"makerCommission"` TakerCommission int `json:"takerCommission"` BuyerCommission int `json:"buyerCommission"` SellerCommission int `json:"sellerCommission"` CommissionRates struct { Maker float64 `json:"maker,string"` Taker float64 `json:"taker,string"` Buyer float64 `json:"buyer,string"` Seller float64 `json:"seller,string"` } `json:"commissionRates"` CanTrade bool `json:"canTrade"` CanWithdraw bool `json:"canWithdraw"` CanDeposit bool `json:"canDeposit"` Brokered bool `json:"brokered"` RequireSelfTradePrevent bool `json:"requireSelfTradePrevention"` UpdateTime int `json:"updateTime"` AccountType string `json:"accountType"` Balances []struct { Asset string `json:"asset"` Free float64 `json:"free,string"` Locked float64 `json:"locked,string"` } `json:"balances"` Permissions []string `json:"permissions"` }
type AggregateTrade ¶
type AggregateTrade struct { A int64 `json:"a"` P float64 `json:"p,string"` Q float64 `json:"q,string"` F int64 `json:"f"` L int64 `json:"L"` T int64 `json:"T"` IsBuyerMaker bool `json:"m"` IsBestMatch bool `json:"M"` }
letters are assumed to follow order of RecentTradesResp
type AvgPriceResp ¶
type BaseUrl ¶
type BaseUrl string
const ( BINANCE_US BaseUrl = "https://api.binance.us" BINANCE_COM BaseUrl = "https://api.binance.com" BINANCE_COM1 BaseUrl = "https://api1.binance.com" BINANCE_COM2 BaseUrl = "https://api2.binance.com" BINANCE_COM3 BaseUrl = "https://api3.binance.com" BINANCE_COM4 BaseUrl = "https://api4.binance.com" )
type BookTickerResp ¶
type CancelOrderParams ¶ added in v0.0.9
type CancelOrderParams struct { Symbol string OrderId int OrigClientOrderId string NewClientOrderId string RecvWindow int Timestamp time.Time }
func NewCancelOrderParams ¶ added in v0.0.9
func NewCancelOrderParams(symbol string, orderId int, origClientOrderId string) CancelOrderParams
type CancellationResp ¶ added in v0.0.12
type CancellationResp struct { Symbol string `json:"symbol"` OrigClientOrderId string `json:"origClientOrderId"` OrderId int `json:"orderId"` OrderListId int `json:"orderListId"` //Unless part of an OCO, the value will always be -1. ClientOrderId string `json:"clientOrderId"` Price float64 `json:"price,string"` OrigQty float64 `json:"origQty,string"` ExecutedQty float64 `json:"executedQty,string"` CummulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"` Status string `json:"status"` TimeInForce string `json:"timeInForce"` OrderType string `json:"type"` Side string `json:"side"` StopPrice float64 `json:"stopPrice,string"` // might not be sent SelfTradePreventionMode string `json:"selfTradePreventionMode"` }
type Client ¶
type Client struct { ApiKey string SecretKey string BaseUrl BaseUrl Symbols map[string]Symbol RequestTimeout time.Duration // contains filtered or unexported fields }
func (Client) AggregateTrades ¶
func (Client) BookTicker ¶
func (c Client) BookTicker(symbol string) (BookTickerResp, error)
func (Client) BookTickers ¶
func (c Client) BookTickers(symbols []string) ([]BookTickerResp, error)
func (Client) CancelOrder ¶
func (c Client) CancelOrder(symbol string, orderId int) (CancellationResp, error)
func (Client) CancelOrder2 ¶ added in v0.0.9
func (c Client) CancelOrder2(symbol string, clientOrderId string) (CancellationResp, error)
func (Client) CancelOrder3 ¶ added in v0.0.9
func (c Client) CancelOrder3(cop CancelOrderParams) (CancellationResp, error)
func (Client) CloseUserDataStream ¶ added in v0.0.9
func (Client) CreateUserDataStream ¶ added in v0.0.9
Returns a listen key and an error, which is nil on success.
func (Client) DayPriceChange ¶
func (c Client) DayPriceChange(symbol string) (PriceChange, error)
Returns the 24-hour price change statistics
func (Client) DayPriceChanges ¶
func (c Client) DayPriceChanges(symbols []string) ([]PriceChange, error)
Returns the 24-hour price change statistics
func (Client) ExchangeInfo ¶
func (c Client) ExchangeInfo() (ExchangeInfoResp, error)
func (Client) ExtendUserDataStream ¶ added in v0.0.9
Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It's recommended to send a ping about every 30 minutes.
func (Client) HistoricalTrades ¶
func (c Client) HistoricalTrades(symbol string, limit, fromId int) ([]RecentTradesResp, error)
Default limit is 500; value must be between 1 and 1,000. If fromId is negative, the most recent trades are used.
func (Client) Klines ¶
func (c Client) Klines(symbol, interval string, limit int, startTime, endTime time.Time) ([]Kline, error)
The fields for most return values are of an equivalent type as the original JSON response from the API; not so with Klines. Because of the way the response is structured, it makes sense to typecast the unmarshalled JSON to numeric types that are easier to work with.
func (Client) OCOCancelOrderList ¶ added in v0.0.12
func (c Client) OCOCancelOrderList(oc OCOCancelParams) (OCOCancellationResp, error)
func (Client) OpenOrders ¶
func (c Client) OpenOrders() ([]OpenOrderResp, error)
func (Client) OrderBookDepth ¶
func (Client) OrderInfo ¶ added in v0.0.7
func (c Client) OrderInfo(symbol string, orderId int) (OrderInfoResp, error)
func (Client) OrderInfo2 ¶ added in v0.0.9
func (c Client) OrderInfo2(symbol string, clientOrderId string) (OrderInfoResp, error)
func (Client) PermissionsInfo ¶
func (c Client) PermissionsInfo(permission string) (ExchangeInfoResp, error)
func (Client) RecentTrades ¶
func (c Client) RecentTrades(symbol string, limit int) ([]RecentTradesResp, error)
Default limit is 500; value must be between 1 and 1,000
func (Client) RollingChange ¶
func (c Client) RollingChange(symbol string, windowSize uint, windowSizeUnit IntervalUnit) (PriceChange, error)
func (Client) SymbolInfo ¶
func (c Client) SymbolInfo(symbol string) (ExchangeInfoResp, error)
func (Client) SymbolsInfo ¶
func (c Client) SymbolsInfo(symbols []string) (ExchangeInfoResp, error)
func (Client) SystemStatus ¶
func (Client) TickerPrice ¶
func (c Client) TickerPrice(symbol string) (TickerResp, error)
func (Client) TickerPrices ¶
func (c Client) TickerPrices(symbols []string) ([]TickerResp, error)
func (Client) UserTrades ¶
func (c Client) UserTrades(u UserTradesParams) ([]UserTradeResp, error)
type ExchangeInfoResp ¶
type ExchangeInfoResp struct { Timezone string `json:"timezone"` ServerTime int64 `json:"serverTime"` RateLimits []RateLimit `json:"rateLimits"` RawExchangeFilters []any `json:"exchangeFilters"` //ExchangeFilters map[string]any Symbols []Symbol `json:"symbols"` Permissions []string `json:"permissions"` DefaultSeltPrevent string `json:"defaultSelfTradePreventionMode"` AllowedSelfPrevent []string `json:"allowedSelfTradePreventionModes"` }
type IntervalUnit ¶
type IntervalUnit string
const ( MINUTE IntervalUnit = "m" HOUR IntervalUnit = "h" DAY IntervalUnit = "d" )
type LimitMakerOrder ¶
type LimitMakerOrder struct { Symbol string // REQUIRED Side Side // REQUIRED TimeInForce TimeInForce // REQUIRED Quantity float64 // REQUIRED Price float64 // REQUIRED NewClientOrderId string IcebergQty float64 SelfTradePreventionMode string OrderRespType OrderRespType RecvWindow int Timestamp time.Time // REQUIRED }
func NewLimitMakerOrder ¶
func NewLimitMakerOrder(symbol string, side Side, timeInForce TimeInForce, quantity, price float64) LimitMakerOrder
type LimitOrder ¶
type LimitOrder struct { Symbol string // REQUIRED Side Side // REQUIRED TimeInForce TimeInForce // REQUIRED Quantity float64 // REQUIRED Price float64 // REQUIRED NewClientOrderId string IcebergQty float64 SelfTradePreventionMode string OrderRespType OrderRespType RecvWindow int Timestamp time.Time // REQUIRED }
func NewLimitOrder ¶
func NewLimitOrder(symbol string, side Side, timeInForce TimeInForce, quantity, price float64) LimitOrder
type MarketOrder ¶
type MarketOrder struct { Symbol string // REQUIRED Side Side // REQUIRED Quantity float64 // DEFAULT; MUST BE USED IFF QuoteOrderQty == 0 QuoteOrderQty float64 // 0 BY DEFAULT; MUST BE USED IFF Quantity == 0 NewClientOrderId string SelfTradePreventionMode string OrderRespType OrderRespType RecvWindow int Timestamp time.Time // REQUIRED }
func NewMarketOrder ¶
func NewMarketOrder(symbol string, side Side, quantity float64) MarketOrder
type OCOCancelParams ¶ added in v0.0.12
type OCOCancellationResp ¶ added in v0.0.12
type OCOCancellationResp struct { OrderListId int `json:"orderListId"` ContingencyType string `json:"contingencyType"` ListStatusType string `json:"listStatusType"` ListOrderStatus string `json:"listOrderStatus"` ListClientOrderId string `json:"listClientOrderId"` TransactionTime int `json:"transactionTime"` Symbol string `json:"symbol"` Orders []struct { Symbol string `json:"symbol"` OrderId int `json:"orderId"` ClientOrderId string `json:"clientOrderId"` } `json:"orders"` OrderReports []CancellationResp `json:"orderReports"` }
type OCOListStatus ¶ added in v0.0.3
type OCOListStatus string
const ( RESPONSE OCOListStatus = "RESPONSE" EXEC_STARTED OCOListStatus = "EXEC_STARTED" ALL_DONE OCOListStatus = "ALL_DONE" )
type OCOOrder ¶
type OCOOrder struct { Symbol string // REQUIRED ListClientOrderId string Side Side // REQUIRED Quantity float64 // REQUIRED LimitClientOrderId string LimitStrategyId int LimitStrategyType int Price float64 // REQUIRED LimitIcebergQty float64 TrailingDelta int StopClientOrderId string StopPrice float64 // REQUIRED StopStrategyId int StopStrategyType int StopLimitPrice float64 StopIcebergQty float64 StopLimitTimeInForce TimeInForce // REQUIRED WITH StopLimitPrice NewOrderRespType OrderRespType SelfTradePreventionMode SelfTradePreventionMode RecvWindow int Timestamp time.Time // REQUIRED }
type OCOOrderStatus ¶ added in v0.0.3
type OCOOrderStatus string
const ( EXECUTING OCOOrderStatus = "EXECUTING" DONE OCOOrderStatus = "ALL_DONE" REJECT OCOOrderStatus = "REJECT" )
type OCOTradeResp ¶
type OCOTradeResp struct { OrderListId int `json:"orderListId"` ContingencyType string `json:"contingencyType"` ListStatusType string `json:"listStatusType"` ListOrderStatus string `json:"listOrderStatus"` ListClientOrderId string `json:"listClientOrderId"` TransactionTime int `json:"transactionTime"` Symbol string `json:"symbol"` Orders []struct { Symbol string `json:"symbol"` OrderId int `json:"orderId"` ClientOrderId string `json:"clientOrderId"` } `json:"orders"` OrderReports []TradeFull `json:"orderReports"` }
type OpenOrderResp ¶
type OpenOrderResp struct { Symbol string OrderId int OrderListId int ClientOrderId string Price float64 OrigQty float64 ExecutedQty float64 CummulativeQty float64 Status string TimeInForce TimeInForce OrderType OrderType Side Side StopPrice float64 IcebergQty float64 Time time.Time UpdateTime time.Time IsWorking bool OrigQuoteOrderQty float64 SelfTradeMode SelfTradePreventionMode }
type Order ¶
type Order interface {
// contains filtered or unexported methods
}
Types that satisfy the Order interface include: MarketOrder, LimitOrder, LimitMakerOrder StopLossOrder, StopLossLimitOrder, TakeProfitOrder, and TakeProfitLimitOrder.
type OrderInfoResp ¶ added in v0.0.7
type OrderInfoResp struct { Symbol string `json:"symbol"` OrderId int `json:"orderId"` OrderListId int `json:"orderListId"` // Unless part of an OCO, the value will always be -1. ClientOrderId string `json:"clientOrderId"` Price float64 `json:"price,string"` OrigQty float64 `json:"origQty,string"` ExecutedQty float64 `json:"executedQty,string"` CummulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"` Status string `json:"status"` TimeInForce string `json:"timeInForce"` OrderType string `json:"type"` Side string `json:"side"` StopPrice float64 `json:"stopPrice,string"` IcebergQty float64 `json:"icebergQty,string"` Time int `json:"time"` UpdateTime int `json:"updateTime"` IsWorking bool `json:"isWorking"` OrigQuoteOrderQty float64 `json:"origQuoteOrderQty,string"` WorkingTime int `json:"workingTime"` SelfTradePreventionMode string `json:"selfTradePreventionMode"` }
type OrderRespType ¶
type OrderRespType string
const ( ACK OrderRespType = "ACK" FULL OrderRespType = "FULL" RESULT OrderRespType = "RESULT" )
type OrderStatus ¶ added in v0.0.3
type OrderStatus string
const ( NEW OrderStatus = "NEW" PARTIALLY_FILLED OrderStatus = "PARTIALLY_FILLED" FILLED OrderStatus = "FILLED" CANCELED OrderStatus = "CANCELED" PENDING_CANCEL OrderStatus = "PENDING_CANCEL" REJECTED OrderStatus = "REJECTED" EXPIRED OrderStatus = "EXPIRED" EXPIRED_IN_MATCH OrderStatus = "EXPIRED_IN_MATCH" )
type Permission ¶
type Permission string
const ( LEVERAGED Permission = "LEVERAGED" MARGIN Permission = "MARGIN" SPOT Permission = "SPOT" TRD_GRP_002 Permission = "TRD_GRP_002" // BINANCE.COM ONLY TRD_GRP_003 Permission = "TRD_GRP_003" // BINANCE.COM ONLY TRD_GRP_004 Permission = "TRD_GRP_004" // BINANCE.COM ONLY TRD_GRP_005 Permission = "TRD_GRP_005" // BINANCE.COM ONLY TRD_GRP_006 Permission = "TRD_GRP_006" // BINANCE.COM ONLY TRD_GRP_007 Permission = "TRD_GRP_007" // BINANCE.COM ONLY )
type PriceChange ¶
type PriceChange 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 int `json:"openTime"` CloseTime int `json:"closeTime"` FirstId int `json:"firstId"` LastId int `json:"lastId"` Count int `json:"count"` }
type RawFilter ¶
type RawFilter struct { FilterType string `json:"filterType"` MinPrice string `json:"minPrice"` MaxPrice string `json:"maxPrice"` TickSize string `json:"tickSize"` MultiplierUp string `json:"multiplierUp"` MultiplierDown string `json:"multiplierDown"` AvgPriceMins int `json:"avgPriceMins"` BidMultiplierUp string `json:"bidMultiplierUp"` BidMultiplierDown string `json:"bidMultiplierDown"` AskMultiplierUp string `json:"askMultiplierUp"` AskMultiplierDown string `json:"askMultiplierDown"` MinQty string `json:"minQty"` MaxQty string `json:"maxQty"` StepSize string `json:"stepSize"` MinNotional string `json:"minNotional"` ApplyMinToMarket bool `json:"applyMinToMarket"` MaxNotional string `json:"maxNotional"` ApplyMaxToMarket bool `json:"applyMaxToMarket"` Limit int `json:"limit"` MaxNumAlgoOrders int `json:"maxNumAlgoOrders"` MaxNumIcebergOrders int `json:"maxNumIcebergOrders"` MaxPosition string `json:"maxPosition"` MinTrailingAboveDelta int `json:"minTrailingAboveDelta"` MaxTrailingAboveDelta int `json:"maxTrailingAboveDelta"` MinTrailingBelowDelta int `json:"minTrailingBelowDelta"` MaxTrailingBelowDelta int `json:"maxTrailingBelowDelta"` MaxNumOrders int `json:"maxNumOrders"` }
type RawOrder ¶
type RawOrder struct { OrderType OrderType Symbol string Side Side Quantity float64 QuoteOrderQty float64 NewClientOrderId string SelfTradePreventionMode string OrderRespType OrderRespType RecvWindow int Timestamp time.Time TimeInForce TimeInForce Price float64 IcebergQty float64 StopPrice float64 TrailingDelta int }
func NewRawOrder ¶
func NewRawOrder() RawOrder
type RecentTradesResp ¶
type SelfTradePreventionMode ¶
type SelfTradePreventionMode string
const ( EXPIRE_BOTH SelfTradePreventionMode = "EXPIRE_BOTH" EXPIRE_MAKER SelfTradePreventionMode = "EXPIRE_MAKER" EXPIRE_TAKER SelfTradePreventionMode = "EXPIRE_TAKER" )
type StopLossLimitOrder ¶
type StopLossLimitOrder struct { Symbol string // REQUIRED TimeInForce TimeInForce // REQUIRED Quantity float64 // REQUIRED Price float64 // REQUIRED NewClientOrderId string StopPrice float64 // DEFAULT; MUST BE USED IFF TrailingDelta == 0 TrailingDelta int // 0 BY DEFAULT; MUST BE USED IFF StopPrice == 0 IcebergQty float64 SelfTradePreventionMode string OrderRespType OrderRespType RecvWindow int Timestamp time.Time // REQUIRED }
func NewStopLossLimitOrder ¶
func NewStopLossLimitOrder(symbol string, timeInForce TimeInForce, quantity, price, stopPrice float64) StopLossLimitOrder
type StopLossOrder ¶
type StopLossOrder struct { Symbol string // REQUIRED Quantity float64 // REQUIRED NewClientOrderId string StopPrice float64 // REQUIRED SelfTradePreventionMode string OrderRespType OrderRespType RecvWindow int Timestamp time.Time // REQUIRED }
func NewStopLossOrder ¶
func NewStopLossOrder(symbol string, quantity, stopPrice float64) StopLossOrder
type Symbol ¶
type Symbol struct { Symbol string `json:"symbol"` Status string `json:"status"` BaseAsset string `json:"baseAsset"` BaseAssetPrecision int `json:"baseAssetPrecision"` QuoteAsset string `json:"quoteAsset"` QuotePrecision int `json:"quotePrecision"` QuoteAssetPrecision int `json:"quoteAssetPrecision"` BaseCommissionPrecision int `json:"baseCommissionPrecision"` QuoteCommissionPrecision int `json:"quoteCommissionPrecision"` OrderTypes []string `json:"orderTypes"` IcebergAllowed bool `json:"icebergAllowed"` OcoAllowed bool `json:"ocoAllowed"` QuoteOrderQtyMarketAllowed bool `json:"quoteOrderQtyMarketAllowed"` AllowTrailingStop bool `json:"allowTrailingStop"` CancelReplaceAllowed bool `json:"cancelReplaceAllowed"` IsSpotTradingAllowed bool `json:"isSpotTradingAllowed"` IsMarginTradingAllowed bool `json:"isMarginTradingAllowed"` RawFilters []map[string]any `json:"filters"` TickSize int StepSize int MinNotional float64 }
type TakeProfitLimitOrder ¶
type TakeProfitLimitOrder struct { Symbol string // REQUIRED TimeInForce TimeInForce // REQUIRED Quantity float64 // REQUIRED Price float64 // REQUIRED NewClientOrderId string StopPrice float64 // DEFAULT; MUST BE USED IFF TrailingDelta == 0 TrailingDelta int // 0 BY DEFAULT; MUST BE USED IFF StopPrice == 0 IcebergQty float64 SelfTradePreventionMode string OrderRespType OrderRespType RecvWindow int Timestamp time.Time // REQUIRED }
func NewTakeProfitLimitOrder ¶
func NewTakeProfitLimitOrder(symbol string, timeInForce TimeInForce, quantity, price, stopPrice float64) TakeProfitLimitOrder
type TakeProfitOrder ¶
type TakeProfitOrder struct { Symbol string // REQUIRED Quantity float64 // REQUIRED NewClientOrderId string StopPrice float64 // DEFAULT; MUST BE USED IFF TrailingDelta == 0 TrailingDelta int // 0 BY DEFAULT; MUST BE USED IFF StopPrice == 0 SelfTradePreventionMode string OrderRespType OrderRespType RecvWindow int Timestamp time.Time // REQUIRED }
func NewTakeProfitOrder ¶
func NewTakeProfitOrder(symbol string, quantity, stopPrice float64) TakeProfitOrder
type TickerResp ¶
type TimeInForce ¶
type TimeInForce string
const ( GTC TimeInForce = "GTC" FOK TimeInForce = "FOK" IOC TimeInForce = "IOC" )
type TradeFull ¶
type TradeFull struct { Symbol string `json:"symbol"` OrderId int `json:"orderId"` OrderListId int `json:"orderListId"` ClientOrderId string `json:"clientOrderId"` TransactTime int `json:"transactTime"` Price float64 `json:"price,string"` OrigQty float64 `json:"origQty,string"` ExecutedQty float64 `json:"executedQty,string"` CummulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"` Status string `json:"status"` TimeInForce string `json:"timeInForce"` Type string `json:"type"` Side string `json:"side"` WorkingTime int `json:"workingTime"` SelfTradePreventionMode string `json:"selfTradePreventionMode"` Fills []struct { Price float64 `json:"price,string"` Qty float64 `json:"qty,string"` Commission float64 `json:"commission,string"` CommissionAsset string `json:"commissionAsset"` TradeId int `json:"tradeId"` } `json:"fills"` }
type TradeResp ¶
type TradeResp struct {
// contains filtered or unexported fields
}
The Binance API responds to order creation requests with an error or at most one of an ACK, a RESULT, or a FULL response type, depending on the order type or NewOrderRespType parameter. The order types ascend in size and provide increasingly detailed information. A FULL response contains all the information in a RESULT response, and a RESULT response contains all the information in an ACK response. A TradeAck and TradeResult can be derived from any valid TradeResp with a RespType of "FULL", and soforth. Per the Binance API documentation, "MARKET and LIMIT order types default to FULL; all other orders default to ACK".
func (TradeResp) Result ¶
func (t TradeResp) Result() (TradeResult, error)
type TradeResult ¶
type TradeResult struct { Symbol string `json:"symbol"` OrderId int `json:"orderId"` OrderListId int `json:"orderListId"` ClientOrderId string `json:"clientOrderId"` TransactTime int `json:"transactTime"` Price float64 `json:"price,string"` OrigQty float64 `json:"origQty,string"` ExecutedQty float64 `json:"executedQty,string"` CummulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"` Status string `json:"status"` TimeInForce string `json:"timeInForce"` Type string `json:"type"` Side string `json:"side"` WorkingTime int `json:"workingTime"` SelfTradePreventionMode string `json:"selfTradePreventionMode"` }
type UserTradeResp ¶
type UserTradeResp struct { Symbol string `json:"symbol"` Id int `json:"id"` OrderId int `json:"orderId"` OrderListId int `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 int `json:"time"` IsBuyer bool `json:"isBuyer"` IsMaker bool `json:"isMaker"` IsBestMatch bool `json:"isBestMatch"` }
Source Files
¶
- account.go
- agg_trades.go
- avg_price.go
- book_ticker.go
- bookdepth.go
- cancel_all.go
- cancel_oco.go
- cancel_order.go
- client.go
- common.go
- day_price_change.go
- endpoints.go
- enums.go
- errs.go
- exchange_info.go
- filters.go
- historical_trades.go
- kline.go
- limit_order.go
- market_order.go
- oco_order.go
- open_orders.go
- order_info.go
- orders.go
- parse_filters.go
- raw_order.go
- recent_trades.go
- rolling_change.go
- server_time.go
- stop_loss_limit_order.go
- stop_loss_order.go
- symbol.go
- system_status.go
- take_profit_limit_order.go
- take_profit_order.go
- ticker_price.go
- trade.go
- trade_resp.go
- user_data_stream.go
- user_trades.go