-
Notifications
You must be signed in to change notification settings - Fork 0
/
connectors.go
40 lines (35 loc) · 1.48 KB
/
connectors.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
package cryptoapi
import (
"fmt"
"strings"
"github.com/grinply/cryptoapi/internal/exchanges/binance"
"github.com/grinply/cryptoapi/pkg/trade"
)
func GetInfoConnector(exchangeName string) (trade.InfoConnector, error) {
switch strings.ToLower(exchangeName) {
case "binance":
return binance.NewBinanceInfoConnector(), nil
default:
return nil, fmt.Errorf("exchange %s not supported", exchangeName)
}
}
// GetPriceConnector creates a connector that can retrieve pricing information for the specified cryptocurrency exchange
// a not nil error indicates that a connector for the exchange is not available
func GetPriceConnector(exchangeName string) (trade.PriceConnector, error) {
switch strings.ToLower(exchangeName) {
case "binance":
return binance.NewPriceConnector(), nil
default:
return nil, fmt.Errorf("could't find a price connector for the provided exchange %s", exchangeName)
}
}
// GetOrderConnector creates a connector that can execute orders and access private information for the specified cryptocurrency exchange
// a not nil error indicates wrong authentication information or that a connector for the exchange is not available
func GetOrderConnector(exchangeName, apiKey, secretKey string, isTestnet bool) (trade.OrderConnector, error) {
switch strings.ToLower(exchangeName) {
case "binance":
return binance.NewOrderConnector(apiKey, secretKey, isTestnet), nil
default:
return nil, fmt.Errorf("could't find a order connector for the provided exchange %s", exchangeName)
}
}