forked from coinrust/crex
/
exchange.go
48 lines (42 loc) · 1.17 KB
/
exchange.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
package exchanges
import (
"fmt"
. "github.com/evzpav/crex"
"github.com/evzpav/crex/exchanges/binancefutures"
"github.com/evzpav/crex/exchanges/bitmex"
"github.com/evzpav/crex/exchanges/bybit"
"github.com/evzpav/crex/exchanges/deribit"
"github.com/evzpav/crex/exchanges/hbdm"
"github.com/evzpav/crex/exchanges/hbdmswap"
"github.com/evzpav/crex/exchanges/okexfutures"
"github.com/evzpav/crex/exchanges/okexswap"
)
func NewExchange(name string, opts ...ApiOption) Exchange {
params := &Parameters{}
for _, opt := range opts {
opt(params)
}
return NewExchangeFromParameters(name, params)
}
func NewExchangeFromParameters(name string, params *Parameters) Exchange {
switch name {
case BinanceFutures:
return binancefutures.NewBinanceFutures(params)
case BitMEX:
return bitmex.NewBitMEX(params)
case Deribit:
return deribit.NewDeribit(params)
case Bybit:
return bybit.NewBybit(params)
case Hbdm:
return hbdm.NewHbdm(params)
case HbdmSwap:
return hbdmswap.NewHbdmSwap(params)
case OkexFutures:
return okexfutures.NewOkexFutures(params)
case OkexSwap:
return okexswap.NewOkexSwap(params)
default:
panic(fmt.Sprintf("new exchange error [%v]", name))
}
}