constants

package
v0.0.0-...-baf6593 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2023 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Log keys are used to provide a consistent key-value interface for logging across the daemon.
	SubmoduleLogKey = "submodule"

	ErrorLogKey      = "error"
	ExchangeIdLogKey = "exchangeId"
	MarketIdLogKey   = "marketId"
	PriceLogKey      = "Price"
	ReasonLogKey     = "reason"

	// Module and Submodule names are used to provide consistent key-value pairs for logging across the daemon.
	PricefeedDaemonModuleName       = "pricefeed-daemon"
	PriceFetcherSubmoduleName       = "price-fetcher"
	PriceEncoderSubmoduleName       = "price-encoder"
	PriceUpdaterSubmoduleName       = "price-updater"
	MarketParamUpdaterSubmoduleName = "market-param-updater"

	// PriceDaemonStartupErrorGracePeriod defines the amount of time the daemon waits before logging issues that are
	// intermittent on daemon startup as true errors. Examples of this includes price conversion failures due to
	// an uninitialized prices cache, and failures to fetch market param updates due to a delay on the protocol side
	// in starting the prices query service.
	// If the protocol is not started within this grace period, the daemon will report these errors as true errors.
	PriceDaemonStartupErrorGracePeriod = 120 * time.Second
)
View Source
const (
	// 5K is chosen to be >> than the number of messages an exchange could send in any period before the
	// price encoder is able to read the messages from the buffer, even if we add O(10-100) markets dynamically,
	// but not large enough to allow more than at most a few minutes of price messages to accumulate.
	FixedBufferSize = 1024 * 5
	// https://stackoverflow.com/questions/37774624/go-http-get-concurrency-and-connection-reset-by-peer.
	// This is a good number to start with based on the above link. Adjustments can/will be made accordingly.
	MaxConnectionsPerExchange = 50
)
View Source
const (
	// MarketUpdateIntervalMs defines the interval at which the market updater updates the market configs in milliseconds.
	MarketUpdateIntervalMs = 2_000 // 2 seconds
)
View Source
const (
	// MinimumRequiredExchangesPerMarket is the minimum number of markets required for a market to be reliably priced
	// by the pricefeed daemon. This number was chosen to supply the minimum number of prices required to
	// compute an index price for a market, given exchange unavailability due to exchange geo-fencing,
	// downtime, etc.
	// Ok to drop this to 5 for some markets if needed, but 6 is better.
	MinimumRequiredExchangesPerMarket = 6
)
View Source
const (
	UnexpectedResponseStatusMessage = "Unexpected response status code of:"
)

Variables

View Source
var (
	RateLimitingError = fmt.Errorf("status 429 - rate limit exceeded")
)
View Source
var (
	StaticExchangeQueryConfig = map[types.ExchangeId]*types.ExchangeQueryConfig{

		exchange_common.EXCHANGE_ID_BINANCE: {
			ExchangeId: exchange_common.EXCHANGE_ID_BINANCE,
			IntervalMs: binanceIntervalMs,
			TimeoutMs:  defaultTimeoutMs,
			MaxQueries: defaultMultiMarketMaxQueries,
		},

		exchange_common.EXCHANGE_ID_BINANCE_US: {
			ExchangeId: exchange_common.EXCHANGE_ID_BINANCE_US,
			IntervalMs: binanceIntervalMs,
			TimeoutMs:  defaultTimeoutMs,
			MaxQueries: defaultMultiMarketMaxQueries,
		},

		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,
		},

		exchange_common.EXCHANGE_ID_GATE: {
			ExchangeId: exchange_common.EXCHANGE_ID_GATE,
			IntervalMs: defaultIntervalMs,
			TimeoutMs:  defaultTimeoutMs,
			MaxQueries: defaultMultiMarketMaxQueries,
		},

		exchange_common.EXCHANGE_ID_BITSTAMP: {
			ExchangeId: exchange_common.EXCHANGE_ID_BITSTAMP,
			IntervalMs: defaultIntervalMs,
			TimeoutMs:  defaultTimeoutMs,
			MaxQueries: defaultMultiMarketMaxQueries,
		},

		exchange_common.EXCHANGE_ID_BYBIT: {
			ExchangeId: exchange_common.EXCHANGE_ID_BYBIT,
			IntervalMs: defaultIntervalMs,
			TimeoutMs:  defaultTimeoutMs,
			MaxQueries: defaultMultiMarketMaxQueries,
		},

		exchange_common.EXCHANGE_ID_CRYPTO_COM: {
			ExchangeId: exchange_common.EXCHANGE_ID_CRYPTO_COM,
			IntervalMs: defaultIntervalMs,
			TimeoutMs:  defaultTimeoutMs,
			MaxQueries: defaultMultiMarketMaxQueries,
		},

		exchange_common.EXCHANGE_ID_HUOBI: {
			ExchangeId: exchange_common.EXCHANGE_ID_HUOBI,
			IntervalMs: defaultIntervalMs,
			TimeoutMs:  defaultTimeoutMs,
			MaxQueries: defaultMultiMarketMaxQueries,
		},

		exchange_common.EXCHANGE_ID_KUCOIN: {
			ExchangeId: exchange_common.EXCHANGE_ID_KUCOIN,
			IntervalMs: defaultIntervalMs,
			TimeoutMs:  defaultTimeoutMs,
			MaxQueries: defaultMultiMarketMaxQueries,
		},

		exchange_common.EXCHANGE_ID_OKX: {
			ExchangeId: exchange_common.EXCHANGE_ID_OKX,
			IntervalMs: defaultIntervalMs,
			TimeoutMs:  defaultTimeoutMs,
			MaxQueries: defaultMultiMarketMaxQueries,
		},

		exchange_common.EXCHANGE_ID_MEXC: {
			ExchangeId: exchange_common.EXCHANGE_ID_MEXC,
			IntervalMs: defaultIntervalMs,
			TimeoutMs:  defaultTimeoutMs,
			MaxQueries: defaultMultiMarketMaxQueries,
		},

		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,
		},
	}
)

Functions

func GenerateExchangeConfigJson

func GenerateExchangeConfigJson(
	exchangeToExchangeConfig map[types.ExchangeId]*types.MutableExchangeMarketConfig,
) (
	marketToExchangeConfigJson map[types.MarketId]string,
)

GenerateExchangeConfigJson generates human-readable exchange config json for each market based on the contents of an exchangeToExchangeConfig map. For the default exchange configs, pass in the `StaticExchangeMarketConfig` map above as the argument.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL