Documentation ¶
Overview ¶
Credit: @oleksandrmarkelov https://github.com/NibiruChain/pricefeeder/pull/27
Index ¶
- Constants
- Variables
- func BinancePriceUpdate(symbols set.Set[types.Symbol], logger zerolog.Logger) (rawPrices map[types.Symbol]float64, err error)
- func BinanceSymbolCsv(symbols set.Set[types.Symbol]) string
- func BitfinexPriceUpdate(symbols set.Set[types.Symbol], logger zerolog.Logger) (rawPrices map[types.Symbol]float64, err error)
- func BitfinexSymbolCsv(symbols set.Set[types.Symbol]) string
- func BybitPriceUpdate(symbols set.Set[types.Symbol], logger zerolog.Logger) (rawPrices map[types.Symbol]float64, err error)
- func CoingeckoPriceUpdate(sourceConfig json.RawMessage) types.FetchPricesFunc
- func CoinmarketcapPriceUpdate(coinmarketcapConfig json.RawMessage) types.FetchPricesFunc
- func GateIoPriceUpdate(symbols set.Set[types.Symbol], logger zerolog.Logger) (rawPrices map[types.Symbol]float64, err error)
- func OkexPriceUpdate(symbols set.Set[types.Symbol], logger zerolog.Logger) (rawPrices map[types.Symbol]float64, err error)
- type BinanceTicker
- type BybitResponse
- type CmcQuote
- type CmcQuotePrice
- type CmcResponse
- type CmcTicker
- type CoingeckoConfig
- type CoingeckoTicker
- type CoinmarketcapConfig
- type OkexResponse
- type OkexTicker
- type TickSource
Constants ¶
const ( Coingecko = "coingecko" FreeLink = "https://api.coingecko.com/api/v3/" PaidLink = "https://pro-api.coingecko.com/api/v3/" ApiKeyParam = "x_cg_pro_api_key" )
const (
Binance = "binance"
)
const (
Bitfinex = "bitfinex"
)
const (
Bybit = "bybit"
)
const (
CoinMarketCap = "coinmarketcap"
)
const (
GateIo = "gateio"
)
const (
Okex = "okex"
)
Variables ¶
var UpdateTick = 8 * time.Second
UpdateTick defines the wait time between price updates.
Functions ¶
func BinancePriceUpdate ¶
func BinancePriceUpdate(symbols set.Set[types.Symbol], logger zerolog.Logger) (rawPrices map[types.Symbol]float64, err error)
BinancePriceUpdate returns the prices given the symbols or an error. Uses the Binance API at https://docs.binance.us/#price-data.
func BitfinexPriceUpdate ¶
func BitfinexPriceUpdate(symbols set.Set[types.Symbol], logger zerolog.Logger) (rawPrices map[types.Symbol]float64, err error)
BitfinexPriceUpdate returns the prices given the symbols or an error.
func BybitPriceUpdate ¶ added in v1.0.1
func BybitPriceUpdate(symbols set.Set[types.Symbol], logger zerolog.Logger) (rawPrices map[types.Symbol]float64, err error)
BybitPriceUpdate returns the prices for given symbols or an error. Uses BYBIT API at https://bybit-exchange.github.io/docs/v5/market/tickers.
func CoingeckoPriceUpdate ¶
func CoingeckoPriceUpdate(sourceConfig json.RawMessage) types.FetchPricesFunc
func CoinmarketcapPriceUpdate ¶ added in v1.0.0
func CoinmarketcapPriceUpdate(coinmarketcapConfig json.RawMessage) types.FetchPricesFunc
func GateIoPriceUpdate ¶ added in v1.0.1
func GateIoPriceUpdate(symbols set.Set[types.Symbol], logger zerolog.Logger) (rawPrices map[types.Symbol]float64, err error)
GateIoPriceUpdate returns the prices given the symbols or an error. Uses the GateIo API at https://www.gate.io/docs/developers/apiv4/en/#get-details-of-a-specifc-currency-pair.
Types ¶
type BinanceTicker ¶
type BybitResponse ¶ added in v1.0.1
type CmcQuote ¶ added in v1.0.0
type CmcQuote struct {
USD CmcQuotePrice
}
type CmcQuotePrice ¶ added in v1.0.0
type CmcQuotePrice struct {
Price float64
}
type CmcResponse ¶ added in v1.0.0
type CoingeckoConfig ¶
type CoingeckoConfig struct {
ApiKey string `json:"api_key"`
}
type CoingeckoTicker ¶
type CoingeckoTicker struct {
Price float64 `json:"usd"`
}
type CoinmarketcapConfig ¶ added in v1.0.0
type CoinmarketcapConfig struct {
ApiKey string `json:"api_key"`
}
type OkexResponse ¶ added in v1.0.1
type OkexResponse struct {
Data []OkexTicker `json:"data"`
}
type OkexTicker ¶ added in v1.0.1
type TickSource ¶
type TickSource struct {
// contains filtered or unexported fields
}
TickSource is a Source which updates prices every x time.Duration.
func NewTickSource ¶
func NewTickSource(symbols set.Set[types.Symbol], fetchPricesFunc types.FetchPricesFunc, logger zerolog.Logger) *TickSource
NewTickSource instantiates a new TickSource instance, given the symbols and a price updater function which returns the latest prices for the provided symbols.
func (*TickSource) Close ¶
func (s *TickSource) Close()
func (*TickSource) PriceUpdates ¶
func (s *TickSource) PriceUpdates() <-chan map[types.Symbol]types.RawPrice