-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
ws_spot_v1.go
68 lines (63 loc) · 1.84 KB
/
ws_spot_v1.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package bybit
import (
"github.com/gorilla/websocket"
)
// SpotWebsocketV1Service :
type SpotWebsocketV1Service struct {
client *WebSocketClient
}
// PublicV1 :
func (s *SpotWebsocketV1Service) PublicV1() (*SpotWebsocketV1PublicV1Service, error) {
url := s.client.baseURL + SpotWebsocketV1PublicV1Path
var c *websocket.Conn
var err error
if s.client.dialer != nil {
c, _, err = s.client.dialer.Dial(url, nil)
} else {
c, _, err = websocket.DefaultDialer.Dial(url, nil)
}
if err != nil {
return nil, err
}
return &SpotWebsocketV1PublicV1Service{
connection: c,
paramTradeMap: map[SpotWebsocketV1PublicV1TradeParamKey]func(SpotWebsocketV1PublicV1TradeResponse) error{},
}, nil
}
// PublicV2 :
func (s *SpotWebsocketV1Service) PublicV2() (*SpotWebsocketV1PublicV2Service, error) {
url := s.client.baseURL + SpotWebsocketV1PublicV2Path
var c *websocket.Conn
var err error
if s.client.dialer != nil {
c, _, err = s.client.dialer.Dial(url, nil)
} else {
c, _, err = websocket.DefaultDialer.Dial(url, nil)
}
if err != nil {
return nil, err
}
return &SpotWebsocketV1PublicV2Service{
connection: c,
paramTradeMap: map[SpotWebsocketV1PublicV2TradeParamKey]func(SpotWebsocketV1PublicV2TradeResponse) error{},
}, nil
}
// Private :
func (s *SpotWebsocketV1Service) Private() (*SpotWebsocketV1PrivateService, error) {
url := s.client.baseURL + SpotWebsocketV1PrivatePath
var c *websocket.Conn
var err error
if s.client.dialer != nil {
c, _, err = s.client.dialer.Dial(url, nil)
} else {
c, _, err = websocket.DefaultDialer.Dial(url, nil)
}
if err != nil {
return nil, err
}
return &SpotWebsocketV1PrivateService{
client: s.client,
connection: c,
paramOutboundAccountInfoMap: map[SpotWebsocketV1PrivateParamKey]func(SpotWebsocketV1PrivateOutboundAccountInfoResponse) error{},
}, nil
}