/
base.go
45 lines (41 loc) · 1016 Bytes
/
base.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
package banexg
import (
"fmt"
"github.com/banbox/banexg/errs"
)
func (h *ExgHosts) GetHost(key string) string {
var dict map[string]string
if h.TestNet {
dict = h.Test
} else {
dict = h.Prod
}
host, ok := dict[key]
if !ok {
panic(fmt.Sprintf("Entry not exist: %s", key))
}
return host
}
func (c *Credential) CheckFilled(keys map[string]bool) *errs.Error {
var requires []string
if c.ApiKey == "" && keys["ApiKey"] {
requires = append(requires, "ApiKey")
}
if c.Secret == "" && keys["Secret"] {
requires = append(requires, "Secret")
}
if c.UID == "" && keys["UID"] {
requires = append(requires, "UID")
}
if c.Password == "" && keys["Password"] {
requires = append(requires, "Password")
}
if len(requires) > 0 {
return errs.NewMsg(errs.CodeCredsRequired, "credential required %v", requires)
}
return nil
}
func IsContract(marketType string) bool {
return marketType == MarketFuture || marketType == MarketSwap ||
marketType == MarketLinear || marketType == MarketInverse
}