forked from coinrust/crex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebsocket.go
More file actions
30 lines (26 loc) · 752 Bytes
/
websocket.go
File metadata and controls
30 lines (26 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package crex
// WS 事件
type WSEvent int
// WS 事件枚举
const (
WSEventTrade WSEvent = iota + 1
WSEventL2Snapshot
WSEventBalance
WSEventOrder
WSEventPosition
WSEventError
WSEventDisconnected
WSEventReconnected
)
// Market 市场信息
type Market struct {
Symbol string // BTCUSDT(OKEX)/XBTUSD(BitMEX)/...
}
// WebSocket 代表WS连接
type WebSocket interface {
SubscribeTrades(market Market, callback func(trades []Trade)) error
SubscribeLevel2Snapshots(market Market, callback func(ob *OrderBook)) error
//SubscribeBalances(market Market, callback func(balance *Balance)) error
SubscribeOrders(market Market, callback func(orders []Order)) error
SubscribePositions(market Market, callback func(positions []Position)) error
}