-
Notifications
You must be signed in to change notification settings - Fork 6
/
const.go
87 lines (74 loc) · 1.69 KB
/
const.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package market_center
import "fmt"
type Type int
const (
_ Type = iota
Type_GetSupportList
Type_SubscribeSpotDepth
Type_SubscribeSpotTicker
Type_SubscribeFutureDepth
Type_SubscribeFutureTicker
Type_GetSpotDepth
Type_GetSpotTicker
Type_GetFutureDepth
Type_GetFutureTicker
)
func (t Type) String() string {
if t > 0 && int(t) <= len(typeSymbol) {
return typeSymbol[t-1]
}
return fmt.Sprintf("UNKNOWN_METHOD_TYPE (%d)", t)
}
var typeSymbol = [...]string{"GetSupportList", "SubscribeDepth", "SubscribeTicker", "GetDepth", "GetTicker"}
const (
ErrMsg_ExchangeNotSupport = "exchange(%s) not support"
ErrMsg_ExchangeNoDepth = "exchange(%s) no %s depth data"
ErrMsg_ExchangeNoTicker = "exchange(%s) no %s ticker data"
ErrMsg_RequestFormatError = "request format error: %s"
ErrMsg_RequestTypeNotSupport = "request type(%v) not support"
)
const (
UDS_PATH = "/tmp/goex.market.center"
)
type DataFlag int
const (
DataFlag_Depth DataFlag = 1 << iota
DataFlag_Ticker
DataFlag_Trade
DataFlag_Kline
//DataFlag_All = DataFlag_Depth | DataFlag_Ticker | DataFlag_Trade | DataFlag_Kline
)
func (df DataFlag) String() string {
s := ""
if df&DataFlag_Depth == DataFlag_Depth {
s += "depth, "
}
if df&DataFlag_Ticker == DataFlag_Ticker {
s += "ticker, "
}
if df&DataFlag_Trade == DataFlag_Trade {
s += "trade, "
}
if df&DataFlag_Kline == DataFlag_Kline {
s += "kline, "
}
if len(s) == 0 {
return "unknown"
}
s = s[:(len(s) - 2)]
return s
}
func ParseDataFlag(str string) DataFlag {
switch str {
case "depth":
return DataFlag_Depth
case "ticker":
return DataFlag_Ticker
case "trade":
return DataFlag_Trade
case "kline":
return DataFlag_Kline
default:
return 0
}
}