-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexchange.go
78 lines (71 loc) · 2.24 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
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
package cryptowatch
import "context"
// List of supported exchanges.
//nolint:varcheck,deadcode,unused
const (
Bitfinex = "bitfinex"
CoinbasePro = "coinbase-pro"
Bitstamp = "bitstamp"
Kraken = "kraken"
CEXIO = "cexio"
Gemini = "gemini"
Quoine = "quoine"
Liquid = "liquid"
bitFlyer = "bitflyer"
OKCoin = "okcoin"
BitMEX = "bitmex"
Huobi = "huobi"
Luno = "luno"
Poloniex = "poloniex"
Bisq = "bisq"
Bithumb = "bithumb"
Bittrex = "bittrex"
Binance = "binance"
BitBay = "bitbay"
Okex = "okex"
Coinone = "coinone"
HitBTC = "hitbtc"
BitZ = "bitz"
Gateio = "gateio"
BinanceUS = "binance-us"
KrakenFutures = "kraken-futures"
DEXAggregated = "dex-aggregated"
FTX = "ftx"
Deribit = "deribit"
)
// Exchange is where all the action happens!
type Exchange struct {
ID int `json:"id"`
Symbol string `json:"symbol"`
Name string `json:"name"`
Route string `json:"route"`
Active bool `json:"active"`
}
// ExchangeDetail holds detailed information about an exhange.
type ExchangeDetail struct {
ID int `json:"id"`
Symbol string `json:"symbol"`
Name string `json:"name"`
Active bool `json:"active"`
Routes struct {
Markets string `json:"markets"`
} `json:"routes"`
}
// ListExchanges list all exchanges.
func (c *Client) ListExchanges(ctx context.Context, opts ...Option) ([]Exchange, error) {
var as []Exchange
opts = append([]Option{withURL(host + "/exchanges")}, opts...)
return as, c.doRequest(ctx, &as, opts...)
}
// ListExchangeDetails returns details of given exchange.
func (c *Client) ListExchangeDetails(ctx context.Context, exchange string, opts ...Option) (ExchangeDetail, error) {
var as ExchangeDetail
opts = append([]Option{withURL(host + "/exchanges/" + exchange)}, opts...)
return as, c.doRequest(ctx, &as, opts...)
}
// ListExchangeMarkets returns markets associated with an exchange.
func (c *Client) ListExchangeMarkets(ctx context.Context, exchange string, opts ...Option) ([]Market, error) {
var as []Market
opts = append([]Option{withURL(host + "/markets/" + exchange)}, opts...)
return as, c.doRequest(ctx, &as, opts...)
}