-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.go
More file actions
42 lines (34 loc) · 806 Bytes
/
bot.go
File metadata and controls
42 lines (34 loc) · 806 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
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"auto-bot/client"
"auto-bot/common"
"auto-bot/serve"
"encoding/json"
"fmt"
"log"
)
func main() {
var channel chan struct{}
fmt.Print(common.Prompt)
ws := client.NewClient()
ws.SetFollow(0.0001)
ws.SetCallbacks(func(response *client.DepthResponse) {
if len(response.Asks) > 0 {
log.Println("深度 ------------ 卖 :", response.Asks[0])
}
if len(response.Bids) > 0 {
log.Println("深度 ------------ 买 :", response.Bids[0])
}
}, func(response *client.KlineResponse) {
for _, v := range serve.ConnPool {
d, _ := json.Marshal(response)
v.WriteMessage(d)
}
log.Println("K线数据", response)
}, nil)
ws.SubscribeKline("btcusdt")
ws.SubscribeDepth("btcusdt")
//ws.SubscribeDepth("ethusdt")
go serve.New().Listen()
<-channel
}