/
client.go
47 lines (43 loc) · 890 Bytes
/
client.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
package bitmex
import (
. "github.com/SuperGod/coinex"
)
func GetClientByName(name string, bTest bool) (bm *Bitmex) {
configs, err := LoadConfigs()
if err != nil {
panic(err.Error())
}
key, secret := configs.Get(name)
if bTest {
bm = NewBitmexTest(key, secret)
bm.SetDebug(true)
} else {
bm = NewBitmex(key, secret)
}
bm.SetProxy(configs.Proxy)
return bm
}
func GetDefaultClient() *Bitmex {
return GetClientByName("bitmex", false)
}
func GetClients(bTest bool) (clts map[string]*Bitmex) {
configs, err := LoadConfigs()
if err != nil {
panic(err.Error())
}
clts = make(map[string]*Bitmex)
var bm *Bitmex
for k, v := range configs.Exchanges {
if v.Type == "bitmex" {
if bTest {
bm = NewBitmexTest(v.Key, v.Secret)
bm.SetDebug(true)
} else {
bm = NewBitmex(v.Key, v.Secret)
}
bm.SetProxy(configs.Proxy)
clts[k] = bm
}
}
return
}