Documentation
¶
Index ¶
- Constants
- func ConvertTrades(remoteTrades []*binance.TradeV3) (trades []types.Trade, err error)
- func MaskKey(key string) string
- func ParseEvent(message string) (interface{}, error)
- func ToGlobalTrade(t binance.TradeV3, isMargin bool) (*types.Trade, error)
- type Balance
- type BalanceUpdateEvent
- type ContinuousKLineEvent
- type DepthEntry
- type DepthEvent
- type DepthFrame
- func (f *DepthFrame) EmitPush(e DepthEvent)
- func (f *DepthFrame) EmitReady(snapshotDepth DepthEvent, bufEvents []DepthEvent)
- func (f *DepthFrame) OnPush(cb func(e DepthEvent))
- func (f *DepthFrame) OnReady(cb func(snapshotDepth DepthEvent, bufEvents []DepthEvent))
- func (f *DepthFrame) PushEvent(e DepthEvent)
- type EventBase
- type Exchange
- func (e *Exchange) BatchQueryKLines(ctx context.Context, symbol string, interval types.Interval, ...) ([]types.KLine, error)
- func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err2 error)
- func (e *Exchange) Name() types.ExchangeName
- func (e *Exchange) NewStream() types.Stream
- func (e *Exchange) PlatformFeeCurrency() string
- func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error)
- func (e *Exchange) QueryAccountBalances(ctx context.Context) (types.BalanceMap, error)
- func (e *Exchange) QueryAveragePrice(ctx context.Context, symbol string) (float64, error)
- func (e *Exchange) QueryClosedOrders(ctx context.Context, symbol string, since, until time.Time, lastOrderID uint64) (orders []types.Order, err error)
- func (e *Exchange) QueryDepositHistory(ctx context.Context, asset string, since, until time.Time) (allDeposits []types.Deposit, err error)
- func (e *Exchange) QueryFundingRateHistory(ctx context.Context, symbol string) (*FundingRate, error)
- func (e *Exchange) QueryIsolatedMarginAccount(ctx context.Context, symbols ...string) (*types.IsolatedMarginAccount, error)
- func (e *Exchange) QueryKLines(ctx context.Context, symbol string, interval types.Interval, ...) ([]types.KLine, error)
- func (e *Exchange) QueryMarginAccount(ctx context.Context) (*types.MarginAccount, error)
- func (e *Exchange) QueryMarkets(ctx context.Context) (types.MarketMap, error)
- func (e *Exchange) QueryOpenOrders(ctx context.Context, symbol string) (orders []types.Order, err error)
- func (e *Exchange) QueryPremiumIndex(ctx context.Context, symbol string) (*PremiumIndex, error)
- func (e *Exchange) QueryTicker(ctx context.Context, symbol string) (*types.Ticker, error)
- func (e *Exchange) QueryTickers(ctx context.Context, symbol ...string) (map[string]types.Ticker, error)
- func (e *Exchange) QueryTrades(ctx context.Context, symbol string, options *types.TradeQueryOptions) (trades []types.Trade, err error)
- func (e *Exchange) QueryWithdrawHistory(ctx context.Context, asset string, since, until time.Time) (allWithdraws []types.Withdraw, err error)
- func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (createdOrders types.OrderSlice, err error)
- func (e *Exchange) Withdrawal(ctx context.Context, asset string, amount fixedpoint.Value, address string, ...) error
- type ExecutionReportEvent
- type FundingRate
- type KLine
- type KLineEvent
- type MarkPriceUpdateEvent
- type OutboundAccountInfoEvent
- type OutboundAccountPositionEvent
- type PremiumIndex
- type ResultEvent
- type Stream
- func (s *Stream) Close() error
- func (s *Stream) Connect(ctx context.Context) error
- func (s *Stream) EmitBalanceUpdateEvent(event *BalanceUpdateEvent)
- func (s *Stream) EmitContinuousKLineEvent(e *ContinuousKLineEvent)
- func (s *Stream) EmitDepthEvent(e *DepthEvent)
- func (s *Stream) EmitExecutionReportEvent(event *ExecutionReportEvent)
- func (s *Stream) EmitKLineClosedEvent(e *KLineEvent)
- func (s *Stream) EmitKLineEvent(e *KLineEvent)
- func (s *Stream) EmitMarkPriceUpdateEvent(e *MarkPriceUpdateEvent)
- func (s *Stream) EmitOutboundAccountInfoEvent(event *OutboundAccountInfoEvent)
- func (s *Stream) EmitOutboundAccountPositionEvent(event *OutboundAccountPositionEvent)
- func (s *Stream) OnBalanceUpdateEvent(cb func(event *BalanceUpdateEvent))
- func (s *Stream) OnContinuousKLineEvent(cb func(e *ContinuousKLineEvent))
- func (s *Stream) OnDepthEvent(cb func(e *DepthEvent))
- func (s *Stream) OnExecutionReportEvent(cb func(event *ExecutionReportEvent))
- func (s *Stream) OnKLineClosedEvent(cb func(e *KLineEvent))
- func (s *Stream) OnKLineEvent(cb func(e *KLineEvent))
- func (s *Stream) OnMarkPriceUpdateEvent(cb func(e *MarkPriceUpdateEvent))
- func (s *Stream) OnOutboundAccountInfoEvent(cb func(event *OutboundAccountInfoEvent))
- func (s *Stream) OnOutboundAccountPositionEvent(cb func(event *OutboundAccountPositionEvent))
- func (s *Stream) SetPublicOnly()
- type StreamEventHub
- type StreamRequest
Constants ¶
const BNB = "BNB"
Variables ¶
This section is empty.
Functions ¶
func ConvertTrades ¶ added in v1.2.0
ConvertTrades converts the binance v3 trade into the global trade type
func ParseEvent ¶
Types ¶
type Balance ¶
type Balance struct {
Asset string `json:"a"`
Free fixedpoint.Value `json:"f"`
Locked fixedpoint.Value `json:"l"`
}
outboundAccountInfo
{
"e": "outboundAccountInfo", // KLineEvent type
"E": 1499405658849, // KLineEvent time
"m": 0, // Maker commission rate (bips)
"t": 0, // Taker commission rate (bips)
"b": 0, // Buyer commission rate (bips)
"s": 0, // Seller commission rate (bips)
"T": true, // Can trade?
"W": true, // Can withdraw?
"D": true, // Can deposit?
"u": 1499405658848, // Time of last account update
"B": [ // AccountBalances array
{
"a": "LTC", // Asset
"f": "17366.18538083", // Free amount
"l": "0.00000000" // Locked amount
},
{
"a": "BTC",
"f": "10537.85314051",
"l": "2.19464093"
},
{
"a": "ETH",
"f": "17902.35190619",
"l": "0.00000000"
},
{
"a": "BNC",
"f": "1114503.29769312",
"l": "0.00000000"
},
{
"a": "NEO",
"f": "0.00000000",
"l": "0.00000000"
}
],
"P": [ // Account Permissions
"SPOT"
]
}
type BalanceUpdateEvent ¶
type BalanceUpdateEvent struct {
EventBase
Asset string `json:"a"`
Delta string `json:"d"`
ClearTime int64 `json:"T"`
}
balanceUpdate
{
"e": "balanceUpdate", //KLineEvent Type
"E": 1573200697110, //KLineEvent Time
"a": "BTC", //Asset
"d": "100.00000000", //Balance Delta
"T": 1573200697068 //Clear Time
}
type ContinuousKLineEvent ¶ added in v1.18.1
type DepthEntry ¶
type DepthEvent ¶
type DepthEvent struct {
EventBase
Symbol string `json:"s"`
FirstUpdateID int64 `json:"U"`
FinalUpdateID int64 `json:"u"`
Bids []DepthEntry
Asks []DepthEntry
}
func (*DepthEvent) OrderBook ¶
func (e *DepthEvent) OrderBook() (book types.SliceOrderBook, err error)
func (*DepthEvent) String ¶ added in v1.17.0
func (e *DepthEvent) String() (o string)
type DepthFrame ¶
type DepthFrame struct {
Symbol string
// contains filtered or unexported fields
}
func (*DepthFrame) EmitPush ¶
func (f *DepthFrame) EmitPush(e DepthEvent)
func (*DepthFrame) EmitReady ¶
func (f *DepthFrame) EmitReady(snapshotDepth DepthEvent, bufEvents []DepthEvent)
func (*DepthFrame) OnPush ¶
func (f *DepthFrame) OnPush(cb func(e DepthEvent))
func (*DepthFrame) OnReady ¶
func (f *DepthFrame) OnReady(cb func(snapshotDepth DepthEvent, bufEvents []DepthEvent))
func (*DepthFrame) PushEvent ¶
func (f *DepthFrame) PushEvent(e DepthEvent)
type EventBase ¶
kline
{
"e": "kline", // KLineEvent type
"E": 123456789, // KLineEvent time
"s": "BNBBTC", // Symbol
"k": {
"t": 123400000, // Kline start time
"T": 123460000, // Kline close time
"s": "BNBBTC", // Symbol
"i": "1m", // Interval
"f": 100, // First trade ID
"L": 200, // Last trade ID
"o": "0.0010", // Open price
"c": "0.0020", // Close price
"h": "0.0025", // High price
"l": "0.0015", // Low price
"v": "1000", // Base asset volume
"n": 100, // Number of trades
"x": false, // Is this kline closed?
"q": "1.0000", // Quote asset volume
"V": "500", // Taker buy base asset volume
"Q": "0.500", // Taker buy quote asset volume
"B": "123456" // Ignore
}
}
type Exchange ¶
type Exchange struct {
types.MarginSettings
types.FuturesSettings
Client *binance.Client
// contains filtered or unexported fields
}
func (*Exchange) BatchQueryKLines ¶
func (*Exchange) CancelOrders ¶
func (*Exchange) Name ¶
func (e *Exchange) Name() types.ExchangeName
func (*Exchange) PlatformFeeCurrency ¶
func (*Exchange) QueryAccount ¶
func (*Exchange) QueryAccountBalances ¶
func (*Exchange) QueryAveragePrice ¶
func (*Exchange) QueryClosedOrders ¶
func (*Exchange) QueryDepositHistory ¶
func (*Exchange) QueryFundingRateHistory ¶ added in v1.18.0
func (*Exchange) QueryIsolatedMarginAccount ¶ added in v1.8.0
func (*Exchange) QueryKLines ¶
func (e *Exchange) QueryKLines(ctx context.Context, symbol string, interval types.Interval, options types.KLineQueryOptions) ([]types.KLine, error)
QueryKLines queries the Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time. Binance uses inclusive start time query range, eg: https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1m&startTime=1620172860000 the above query will return a kline with startTime = 1620172860000 and, https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1m&startTime=1620172860000&endTime=1620172920000 the above query will return a kline with startTime = 1620172860000, and a kline with endTime = 1620172860000
the endTime of a binance kline, is the (startTime + interval time - 1 millisecond), e.g., millisecond unix timestamp: 1620172860000 and 1620172919999
func (*Exchange) QueryMarginAccount ¶ added in v1.8.0
func (*Exchange) QueryMarkets ¶
func (*Exchange) QueryOpenOrders ¶
func (*Exchange) QueryPremiumIndex ¶ added in v1.18.0
func (*Exchange) QueryTicker ¶ added in v1.11.1
func (*Exchange) QueryTickers ¶ added in v1.11.0
func (*Exchange) QueryTrades ¶
func (*Exchange) QueryWithdrawHistory ¶
func (*Exchange) SubmitOrders ¶
func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (createdOrders types.OrderSlice, err error)
func (*Exchange) Withdrawal ¶ added in v1.16.0
func (e *Exchange) Withdrawal(ctx context.Context, asset string, amount fixedpoint.Value, address string, options *types.WithdrawalOptions) error
type ExecutionReportEvent ¶
type ExecutionReportEvent struct {
EventBase
Symbol string `json:"s"`
Side string `json:"S"`
ClientOrderID string `json:"c"`
OriginalClientOrderID string `json:"C"`
OrderType string `json:"o"`
OrderCreationTime int64 `json:"O"`
TimeInForce string `json:"f"`
IcebergQuantity string `json:"F"`
OrderQuantity string `json:"q"`
QuoteOrderQuantity string `json:"Q"`
OrderPrice string `json:"p"`
StopPrice string `json:"P"`
IsOnBook bool `json:"w"`
IsMaker bool `json:"m"`
Ignore bool `json:"M"`
CommissionAmount string `json:"n"`
CommissionAsset string `json:"N"`
CurrentExecutionType string `json:"x"`
CurrentOrderStatus string `json:"X"`
OrderID int64 `json:"i"`
Ignored int64 `json:"I"`
TradeID int64 `json:"t"`
TransactionTime int64 `json:"T"`
LastExecutedQuantity string `json:"l"`
LastExecutedPrice string `json:"L"`
CumulativeFilledQuantity string `json:"z"`
CumulativeQuoteAssetTransactedQuantity string `json:"Z"`
LastQuoteAssetTransactedQuantity string `json:"Y"`
}
executionReport
{
"e": "executionReport", // Event type
"E": 1499405658658, // Event time
"s": "ETHBTC", // Symbol
"c": "mUvoqJxFIILMdfAW5iGSOW", // Client order ID
"S": "BUY", // Side
"o": "LIMIT", // Order type
"f": "GTC", // Time in force
"q": "1.00000000", // Order quantity
"p": "0.10264410", // Order price
"P": "0.00000000", // Stop price
"F": "0.00000000", // Iceberg quantity
"g": -1, // OrderListId
"C": null, // Original client order ID; This is the ID of the order being canceled
"x": "NEW", // Current execution type
"X": "NEW", // Current order status
"r": "NONE", // Order reject reason; will be an error code.
"i": 4293153, // Order ID
"l": "0.00000000", // Last executed quantity
"z": "0.00000000", // Cumulative filled quantity
"L": "0.00000000", // Last executed price
"n": "0", // Commission amount
"N": null, // Commission asset
"T": 1499405658657, // Transaction time
"t": -1, // Trade ID
"I": 8641984, // Ignore
"w": true, // Is the order on the book?
"m": false, // Is this trade the maker side?
"M": false, // Ignore
"O": 1499405658657, // Order creation time
"Z": "0.00000000", // Cumulative quote asset transacted quantity
"Y": "0.00000000", // Last quote asset transacted quantity (i.e. lastPrice * lastQty)
"Q": "0.00000000" // Quote Order Qty
}
type FundingRate ¶ added in v1.18.0
type KLine ¶
type KLine struct {
StartTime int64 `json:"t"`
EndTime int64 `json:"T"`
Symbol string `json:"s"`
Interval string `json:"i"`
Open fixedpoint.Value `json:"o"`
Close fixedpoint.Value `json:"c"`
High fixedpoint.Value `json:"h"`
Low fixedpoint.Value `json:"l"`
Volume fixedpoint.Value `json:"v"` // base asset volume (like 10 BTC)
QuoteVolume fixedpoint.Value `json:"q"` // quote asset volume
TakerBuyBaseAssetVolume fixedpoint.Value `json:"V"` // taker buy base asset volume (like 10 BTC)
TakerBuyQuoteAssetVolume fixedpoint.Value `json:"Q"` // taker buy quote asset volume (like 1000USDT)
LastTradeID int `json:"L"`
NumberOfTrades int64 `json:"n"`
Closed bool `json:"x"`
}
type KLineEvent ¶
type MarkPriceUpdateEvent ¶ added in v1.18.1
type MarkPriceUpdateEvent struct {
EventBase
Symbol string `json:"s"`
MarkPrice fixedpoint.Value `json:"p"`
IndexPrice fixedpoint.Value `json:"i"`
EstimatedPrice fixedpoint.Value `json:"P"`
FundingRate fixedpoint.Value `json:"r"`
NextFundingTime int64 `json:"T"`
}
type OutboundAccountInfoEvent ¶
type OutboundAccountInfoEvent struct {
EventBase
MakerCommissionRate int `json:"m"`
TakerCommissionRate int `json:"t"`
BuyerCommissionRate int `json:"b"`
SellerCommissionRate int `json:"s"`
CanTrade bool `json:"T"`
CanWithdraw bool `json:"W"`
CanDeposit bool `json:"D"`
LastAccountUpdateTime int `json:"u"`
Balances []Balance `json:"B,omitempty"`
Permissions []string `json:"P,omitempty"`
}
type OutboundAccountPositionEvent ¶ added in v1.8.0
type PremiumIndex ¶ added in v1.18.0
type PremiumIndex struct {
Symbol string `json:"symbol"`
MarkPrice fixedpoint.Value `json:"markPrice"`
LastFundingRate fixedpoint.Value `json:"lastFundingRate"`
NextFundingTime time.Time `json:"nextFundingTime"`
Time time.Time `json:"time"`
}
type ResultEvent ¶
type ResultEvent struct {
Result interface{} `json:"result,omitempty"`
ID int `json:"id"`
}
type Stream ¶
type Stream struct {
types.MarginSettings
types.FuturesSettings
types.StandardStream
Client *binance.Client
Conn *websocket.Conn
ConnLock sync.Mutex
// contains filtered or unexported fields
}
func (*Stream) EmitBalanceUpdateEvent ¶
func (s *Stream) EmitBalanceUpdateEvent(event *BalanceUpdateEvent)
func (*Stream) EmitContinuousKLineEvent ¶ added in v1.18.1
func (s *Stream) EmitContinuousKLineEvent(e *ContinuousKLineEvent)
func (*Stream) EmitDepthEvent ¶
func (s *Stream) EmitDepthEvent(e *DepthEvent)
func (*Stream) EmitExecutionReportEvent ¶
func (s *Stream) EmitExecutionReportEvent(event *ExecutionReportEvent)
func (*Stream) EmitKLineClosedEvent ¶
func (s *Stream) EmitKLineClosedEvent(e *KLineEvent)
func (*Stream) EmitKLineEvent ¶
func (s *Stream) EmitKLineEvent(e *KLineEvent)
func (*Stream) EmitMarkPriceUpdateEvent ¶ added in v1.18.1
func (s *Stream) EmitMarkPriceUpdateEvent(e *MarkPriceUpdateEvent)
func (*Stream) EmitOutboundAccountInfoEvent ¶
func (s *Stream) EmitOutboundAccountInfoEvent(event *OutboundAccountInfoEvent)
func (*Stream) EmitOutboundAccountPositionEvent ¶ added in v1.8.0
func (s *Stream) EmitOutboundAccountPositionEvent(event *OutboundAccountPositionEvent)
func (*Stream) OnBalanceUpdateEvent ¶
func (s *Stream) OnBalanceUpdateEvent(cb func(event *BalanceUpdateEvent))
func (*Stream) OnContinuousKLineEvent ¶ added in v1.18.1
func (s *Stream) OnContinuousKLineEvent(cb func(e *ContinuousKLineEvent))
func (*Stream) OnDepthEvent ¶
func (s *Stream) OnDepthEvent(cb func(e *DepthEvent))
func (*Stream) OnExecutionReportEvent ¶
func (s *Stream) OnExecutionReportEvent(cb func(event *ExecutionReportEvent))
func (*Stream) OnKLineClosedEvent ¶
func (s *Stream) OnKLineClosedEvent(cb func(e *KLineEvent))
func (*Stream) OnKLineEvent ¶
func (s *Stream) OnKLineEvent(cb func(e *KLineEvent))
func (*Stream) OnMarkPriceUpdateEvent ¶ added in v1.18.1
func (s *Stream) OnMarkPriceUpdateEvent(cb func(e *MarkPriceUpdateEvent))
func (*Stream) OnOutboundAccountInfoEvent ¶
func (s *Stream) OnOutboundAccountInfoEvent(cb func(event *OutboundAccountInfoEvent))
func (*Stream) OnOutboundAccountPositionEvent ¶ added in v1.8.0
func (s *Stream) OnOutboundAccountPositionEvent(cb func(event *OutboundAccountPositionEvent))
func (*Stream) SetPublicOnly ¶ added in v1.5.0
func (s *Stream) SetPublicOnly()
type StreamEventHub ¶
type StreamEventHub interface {
OnDepthEvent(cb func(e *DepthEvent))
OnKLineEvent(cb func(e *KLineEvent))
OnKLineClosedEvent(cb func(e *KLineEvent))
OnMarkPriceUpdateEvent(cb func(e *MarkPriceUpdateEvent))
OnContinuousKLineEvent(cb func(e *ContinuousKLineEvent))
OnBalanceUpdateEvent(cb func(event *BalanceUpdateEvent))
OnOutboundAccountInfoEvent(cb func(event *OutboundAccountInfoEvent))
OnOutboundAccountPositionEvent(cb func(event *OutboundAccountPositionEvent))
OnExecutionReportEvent(cb func(event *ExecutionReportEvent))
}