-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwisp.go
More file actions
73 lines (61 loc) · 2.2 KB
/
wisp.go
File metadata and controls
73 lines (61 loc) · 2.2 KB
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
69
70
71
72
73
package main
import (
"net/http"
"wisp/common"
"wisp/exchange"
"wisp/log"
"wisp/server"
)
func main() {
//var channel = make(chan struct{})
log.InitLog()
log.Info(common.Logo)
binance := exchange.NewBinanceExchange()
binance.SetCallbacks(depthCallback, tickerCallback, klineCallback)
binance.SubDepths("btcusdt", 5)
binance.SubDepths("ethusdt", 5)
binance.SubDepths("ltcusdt", 5)
binance.SubDepths("etcusdt", 5)
binance.SubDepths("bchusdt", 5)
binance.SubDepths("dashusdt", 5)
binance.SubDepths("eosusdt", 5)
binance.SubDepths("xrpusdt", 5)
binance.SubDepths("adausdt", 5)
binance.SubTicker("btcusdt")
binance.SubTicker("ethusdt")
binance.SubTicker("ltcusdt")
binance.SubTicker("etcusdt")
binance.SubTicker("bchusdt")
binance.SubTicker("dashusdt")
binance.SubTicker("eosusdt")
binance.SubTicker("xrpusdt")
binance.SubTicker("adausdt")
binance.SubKline("btcusdt", common.KLINE_PERIOD_1MIN)
binance.SubKline("ethusdt", common.KLINE_PERIOD_1MIN)
binance.SubKline("ltcusdt", common.KLINE_PERIOD_1MIN)
binance.SubKline("etcusdt", common.KLINE_PERIOD_1MIN)
binance.SubKline("bchusdt", common.KLINE_PERIOD_1MIN)
binance.SubKline("dashusdt", common.KLINE_PERIOD_1MIN)
binance.SubKline("eosusdt", common.KLINE_PERIOD_1MIN)
binance.SubKline("xrpusdt", common.KLINE_PERIOD_1MIN)
binance.SubKline("adausdt", common.KLINE_PERIOD_1MIN)
//<-channel
http.HandleFunc("/ws", server.Echo)
http.ListenAndServe(":8080", nil)
}
func depthCallback(depth *common.Depth) {
log.Info("币安 交易标的: %s 买5档: %v 卖5档: %v \n", depth.Symbol, depth.BidList, depth.AskList)
}
func tickerCallback(ticker *common.Ticker) {
log.Info("币安 交易标的: %s 最新价: %f 最高价: %f 成交量: %f \n", ticker.Symbol, ticker.Last, ticker.High, ticker.Vol)
}
func klineCallback(kline *common.Kline, period int) {
//data, _ := json.Marshal(kline)
dst, ok := common.ChanMap["abc"]
//res :=[1][5]interface{}{{kline.Timestamp,kline.Open,kline.High,kline.Low,kline.Close}}
//resB,_:=json.Marshal(res)
if ok {
dst.WriteJSON(kline)
}
log.Info("币安 交易标的: %s K线类型: %d 开盘价: %f 收盘价: %f 最高价: %f 最低价: %f \n", kline.Symbol, period, kline.Open, kline.Close, kline.High, kline.Low)
}