Documentation ¶
Index ¶
- Constants
- func ConvertTrades(remoteTrades []*binance.TradeV3) (trades []types.Trade, err error)
- func ParseEvent(message string) (interface{}, error)
- func ToGlobalOrder(binanceOrder *binance.Order, isMargin bool) (*types.Order, error)
- func ToGlobalOrders(binanceOrders []*binance.Order) (orders []types.Order, err error)
- func ToGlobalTrade(t binance.TradeV3, isMargin bool) (*types.Trade, error)
- type Balance
- type BalanceUpdateEvent
- 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) 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) 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 KLine
- type KLineEvent
- type OutboundAccountInfoEvent
- type OutboundAccountPositionEvent
- 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) EmitDepthEvent(e *DepthEvent)
- func (s *Stream) EmitExecutionReportEvent(event *ExecutionReportEvent)
- func (s *Stream) EmitKLineClosedEvent(e *KLineEvent)
- func (s *Stream) EmitKLineEvent(e *KLineEvent)
- func (s *Stream) EmitOutboundAccountInfoEvent(event *OutboundAccountInfoEvent)
- func (s *Stream) EmitOutboundAccountPositionEvent(event *OutboundAccountPositionEvent)
- func (s *Stream) OnBalanceUpdateEvent(cb func(event *BalanceUpdateEvent))
- 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) 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 ¶
ConvertTrades converts the binance v3 trade into the global trade type
func ParseEvent ¶
func ToGlobalOrder ¶
func ToGlobalOrders ¶
Types ¶
type Balance ¶
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 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 ¶
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 Client *binance.Client }
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) QueryIsolatedMarginAccount ¶
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 ¶
func (*Exchange) QueryMarkets ¶
func (*Exchange) QueryOpenOrders ¶
func (*Exchange) QueryTicker ¶
func (*Exchange) QueryTickers ¶
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 ¶
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 KLine ¶
type KLine struct { StartTime int64 `json:"t"` EndTime int64 `json:"T"` Symbol string `json:"s"` Interval string `json:"i"` Open string `json:"o"` Close string `json:"c"` High string `json:"h"` Low string `json:"l"` Volume string `json:"v"` // base asset volume (like 10 BTC) QuoteVolume string `json:"q"` // quote asset volume TakerBaseVolume string `json:"V"` // taker buy base asset volume (like 10 BTC) TakerQuoteVolume string `json:"Q"` // taker buy quote asset volume (like 1000USDT) LastTradeID int `json:"L"` NumberOfTrades int64 `json:"n"` Closed bool `json:"x"` }
type KLineEvent ¶
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 ResultEvent ¶
type ResultEvent struct { Result interface{} `json:"result,omitempty"` ID int `json:"id"` }
type Stream ¶
type Stream struct { types.MarginSettings types.StandardStream Client *binance.Client ListenKey string Conn *websocket.Conn // contains filtered or unexported fields }
func (*Stream) EmitBalanceUpdateEvent ¶
func (s *Stream) EmitBalanceUpdateEvent(event *BalanceUpdateEvent)
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) EmitOutboundAccountInfoEvent ¶
func (s *Stream) EmitOutboundAccountInfoEvent(event *OutboundAccountInfoEvent)
func (*Stream) EmitOutboundAccountPositionEvent ¶
func (s *Stream) EmitOutboundAccountPositionEvent(event *OutboundAccountPositionEvent)
func (*Stream) OnBalanceUpdateEvent ¶
func (s *Stream) OnBalanceUpdateEvent(cb func(event *BalanceUpdateEvent))
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) OnOutboundAccountInfoEvent ¶
func (s *Stream) OnOutboundAccountInfoEvent(cb func(event *OutboundAccountInfoEvent))
func (*Stream) OnOutboundAccountPositionEvent ¶
func (s *Stream) OnOutboundAccountPositionEvent(cb func(event *OutboundAccountPositionEvent))
func (*Stream) SetPublicOnly ¶
func (s *Stream) SetPublicOnly()
type StreamEventHub ¶
type StreamEventHub interface { OnDepthEvent(cb func(e *DepthEvent)) OnKLineEvent(cb func(e *KLineEvent)) OnKLineClosedEvent(cb func(e *KLineEvent)) OnBalanceUpdateEvent(cb func(event *BalanceUpdateEvent)) OnOutboundAccountInfoEvent(cb func(event *OutboundAccountInfoEvent)) OnOutboundAccountPositionEvent(cb func(event *OutboundAccountPositionEvent)) OnExecutionReportEvent(cb func(event *ExecutionReportEvent)) }