Documentation ¶
Index ¶
- Constants
- type ByBitWS
- func (b *ByBitWS) Auth() error
- func (b *ByBitWS) Close()
- func (b *ByBitWS) Emit(event interface{}, arguments ...interface{}) *emission.Emitter
- func (b *ByBitWS) IsConnected() bool
- func (b *ByBitWS) Off(event interface{}, listener interface{}) *emission.Emitter
- func (b *ByBitWS) On(event interface{}, listener interface{}) *emission.Emitter
- func (b *ByBitWS) Send(msg string) (err error)
- func (b *ByBitWS) SendCmd(cmd Cmd) error
- func (b *ByBitWS) Start() error
- func (b *ByBitWS) Subscribe(arg string)
- type Cmd
- type Configuration
- type Execution
- type Instrument
- type Insurance
- type Item
- type KLine
- type Order
- type OrderBook
- type OrderBookL2
- type OrderBookL2Delta
- type OrderBookLocal
- type Position
- type Trade
Constants ¶
View Source
const ( HostReal = "wss://stream.bybit.com/realtime" HostTestnet = "wss://stream-testnet.bybit.com/realtime" )
View Source
const ( WSOrderBook25L1 = "orderBookL2_25" // 新版25档orderBook: order_book_25L1.BTCUSD WSKLine = "kline" // K线: kline.BTCUSD.1m WSTrade = "trade" // 实时交易: trade/trade.BTCUSD WSInsurance = "insurance" // 每日保险基金更新: insurance WSInstrument = "instrument" // 产品最新行情: instrument WSPosition = "position" // 仓位变化: position WSExecution = "execution" // 委托单成交信息: execution WSOrder = "order" // 委托单的更新: order WSDisconnected = "disconnected" // WS断开事件 )
View Source
const (
MaxTryTimes = 10
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByBitWS ¶
type ByBitWS struct {
// contains filtered or unexported fields
}
func New ¶
func New(config *Configuration) *ByBitWS
func (*ByBitWS) IsConnected ¶
IsConnected returns the WebSocket connection state
type Cmd ¶
type Cmd struct { Op string `json:"op"` Args []interface{} `json:"args"` }
ws.send('{"op":"subscribe","args":["topic","topic.filter"]}');
// 同一个类型的filter有多个时,以'|'分割 // 如订阅BTCUSD一分钟和三分钟的kline ws.send('{"op":"subscribe","args":["kline.BTCUSD.1m|3m"]}');
// 订阅同一个类型filter的所有数据时请使用'*' // 如订阅所有产品的所有interval kline ws.send('{"op":"subscribe","args":["kline.*.*"]}')
type Configuration ¶
type Execution ¶
type Execution struct { Symbol string `json:"symbol"` Side string `json:"side"` OrderID string `json:"order_id"` ExecID string `json:"exec_id"` OrderLinkID string `json:"order_link_id"` Price float64 `json:"price,string"` OrderQty float64 `json:"order_qty"` ExecType string `json:"exec_type"` ExecQty float64 `json:"exec_qty"` ExecFee float64 `json:"exec_fee,string"` LeavesQty float64 `json:"leaves_qty"` IsMaker bool `json:"is_maker"` TradeTime time.Time `json:"trade_time"` }
type Instrument ¶
type KLine ¶
type KLine struct { ID int64 `json:"id"` // 563 Symbol string `json:"symbol"` // BTCUSD OpenTime int64 `json:"open_time"` // 1539918000 Open float64 `json:"open"` High float64 `json:"high"` Low float64 `json:"low"` Close float64 `json:"close"` Volume float64 `json:"volume"` Turnover float64 `json:"turnover"` // 0.0013844 Interval string `json:"interval"` // 1m }
type Order ¶
type Order struct { OrderID string `json:"order_id"` OrderLinkID string `json:"order_link_id"` Symbol string `json:"symbol"` Side string `json:"side"` OrderType string `json:"order_type"` Price float64 `json:"price,string"` Qty float64 `json:"qty"` TimeInForce string `json:"time_in_force"` // GoodTillCancel/ImmediateOrCancel/FillOrKill/PostOnly CreateType string `json:"create_type"` CancelType string `json:"cancel_type"` OrderStatus string `json:"order_status"` LeavesQty float64 `json:"leaves_qty"` CumExecQty float64 `json:"cum_exec_qty"` CumExecValue float64 `json:"cum_exec_value,string"` CumExecFee float64 `json:"cum_exec_fee,string"` Timestamp time.Time `json:"timestamp"` TakeProfit float64 `json:"take_profit,string"` StopLoss float64 `json:"stop_loss,string"` TrailingStop float64 `json:"trailing_stop,string"` LastExecPrice float64 `json:"last_exec_price,string"` }
type OrderBookL2 ¶
type OrderBookL2 struct { ID int64 `json:"id"` Price float64 `json:"price,string"` Side string `json:"side"` Size int64 `json:"size"` Symbol string `json:"symbol"` }
func (*OrderBookL2) Key ¶
func (o *OrderBookL2) Key() string
type OrderBookL2Delta ¶
type OrderBookL2Delta struct { Delete []*OrderBookL2 `json:"delete"` Update []*OrderBookL2 `json:"update"` Insert []*OrderBookL2 `json:"insert"` }
type OrderBookLocal ¶
type OrderBookLocal struct {
// contains filtered or unexported fields
}
func NewOrderBookLocal ¶
func NewOrderBookLocal() *OrderBookLocal
func (*OrderBookLocal) GetOrderBook ¶
func (o *OrderBookLocal) GetOrderBook() (ob OrderBook)
func (*OrderBookLocal) LoadSnapshot ¶
func (o *OrderBookLocal) LoadSnapshot(newOrderbook []*OrderBookL2) error
func (*OrderBookLocal) Update ¶
func (o *OrderBookLocal) Update(delta *OrderBookL2Delta)
type Position ¶
type Position struct { UserID int64 `json:"user_id"` Symbol string `json:"symbol"` Size float64 `json:"size"` Side string `json:"side"` PositionValue float64 `json:"position_value,string"` EntryPrice float64 `json:"entry_price,string"` LiqPrice float64 `json:"liq_price,string"` BustPrice float64 `json:"bust_price,string"` Leverage float64 `json:"leverage,string"` OrderMargin float64 `json:"order_margin,string"` PositionMargin float64 `json:"position_margin,string"` AvailableBalance float64 `json:"available_balance,string"` TakeProfit float64 `json:"take_profit,string"` StopLoss float64 `json:"stop_loss,string"` RealisedPnl float64 `json:"realised_pnl,string"` TrailingStop float64 `json:"trailing_stop,string"` TrailingActive float64 `json:"trailing_active,string"` WalletBalance float64 `json:"wallet_balance,string"` RiskID int `json:"risk_id"` OccClosingFee float64 `json:"occ_closing_fee,string"` OccFundingFee float64 `json:"occ_funding_fee,string"` AutoAddMargin int `json:"auto_add_margin"` CumRealisedPnl float64 `json:"cum_realised_pnl,string"` PositionStatus string `json:"position_status"` PositionSeq int64 `json:"position_seq"` }
Click to show internal directories.
Click to hide internal directories.