-
Notifications
You must be signed in to change notification settings - Fork 0
/
static_exchange_query_config.go
137 lines (134 loc) · 5.31 KB
/
static_exchange_query_config.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package constants
import (
"github.com/jinxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants/exchange_common"
"github.com/jinxprotocol/v4-chain/protocol/daemons/pricefeed/client/types"
)
const (
defaultIntervalMs = 2_000
// Binance / BinanceUS has a limit of 1_200 request weight per minute. At 40 request weight per
// iteration, we can query once every 2 seconds, but increase to 2.5s to allow for some jitter.
binanceIntervalMs = 2_500
// Bitfinex has a rate limit of 30 requests per minute, so we query every 2.5 seconds
// to allow for some jitter, as the 2-second interval occasionally produces 429 responses.
bitfinexIntervalMs = 2_500
defaultTimeoutMs = 3_000
defaultMaxQueries = 3
defaultMultiMarketMaxQueries = 1
)
var (
StaticExchangeQueryConfig = map[types.ExchangeId]*types.ExchangeQueryConfig{
// See above for rate limiting information of Binance.
// https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics
exchange_common.EXCHANGE_ID_BINANCE: {
ExchangeId: exchange_common.EXCHANGE_ID_BINANCE,
IntervalMs: binanceIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// See above for rate limiting information of BinanceUS.
exchange_common.EXCHANGE_ID_BINANCE_US: {
ExchangeId: exchange_common.EXCHANGE_ID_BINANCE_US,
IntervalMs: binanceIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// Bitfinex has a limit of 30 requests per minute.
// https://docs.bitfinex.com/reference/rest-public-tickers
exchange_common.EXCHANGE_ID_BITFINEX: {
ExchangeId: exchange_common.EXCHANGE_ID_BITFINEX,
IntervalMs: bitfinexIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
exchange_common.EXCHANGE_ID_KRAKEN: {
ExchangeId: exchange_common.EXCHANGE_ID_KRAKEN,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// Gate has a limit of 900 requests/second
// https://www.gate.io/docs/developers/apiv4/en/#frequency-limit-rule
exchange_common.EXCHANGE_ID_GATE: {
ExchangeId: exchange_common.EXCHANGE_ID_GATE,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// Bitstamp has a limit of 8000 requests per 10 minutes.
// https://www.bitstamp.net/api/#request-limits
exchange_common.EXCHANGE_ID_BITSTAMP: {
ExchangeId: exchange_common.EXCHANGE_ID_BITSTAMP,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// Bybit has a limit of 120 requests per second for 5 consecutive seconds.
// https://bybit-exchange.github.io/docs/v5/rate-limit
exchange_common.EXCHANGE_ID_BYBIT: {
ExchangeId: exchange_common.EXCHANGE_ID_BYBIT,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// Crypto.com has a limit of 100 requests per second.
// https://exchange-docs.crypto.com/derivatives/index.html#rate-limits
exchange_common.EXCHANGE_ID_CRYPTO_COM: {
ExchangeId: exchange_common.EXCHANGE_ID_CRYPTO_COM,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// Huobi has a limit of 100 requests per second.
// https://huobiapi.github.io/docs/spot/v1/en/#api-access
exchange_common.EXCHANGE_ID_HUOBI: {
ExchangeId: exchange_common.EXCHANGE_ID_HUOBI,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// Kucoin has a limit of 500 requests per 10 seconds.
// https://docs.kucoin.com/#request-rate-limit
exchange_common.EXCHANGE_ID_KUCOIN: {
ExchangeId: exchange_common.EXCHANGE_ID_KUCOIN,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// Okx has a limit of 20 requests per 2 seconds.
// https://www.okx.com/docs-v5/en/#rest-api-market-data-get-tickers
exchange_common.EXCHANGE_ID_OKX: {
ExchangeId: exchange_common.EXCHANGE_ID_OKX,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// Mexc has a limit of 20 requests per second.
// https://mxcdevelop.github.io/apidocs/spot_v2_en/#rate-limit
exchange_common.EXCHANGE_ID_MEXC: {
ExchangeId: exchange_common.EXCHANGE_ID_MEXC,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMultiMarketMaxQueries,
},
// CoinbasePro has a limit of 10 requests per second.
// https://docs.cloud.coinbase.com/exchange/docs/rest-rate-limits
exchange_common.EXCHANGE_ID_COINBASE_PRO: {
ExchangeId: exchange_common.EXCHANGE_ID_COINBASE_PRO,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMaxQueries,
},
exchange_common.EXCHANGE_ID_TEST_VOLATILE_EXCHANGE: {
ExchangeId: exchange_common.EXCHANGE_ID_TEST_VOLATILE_EXCHANGE,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMaxQueries,
},
exchange_common.EXCHANGE_ID_TEST_FIXED_PRICE_EXCHANGE: {
ExchangeId: exchange_common.EXCHANGE_ID_TEST_FIXED_PRICE_EXCHANGE,
IntervalMs: defaultIntervalMs,
TimeoutMs: defaultTimeoutMs,
MaxQueries: defaultMaxQueries,
},
}
)