sources

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Coingecko   = "coingecko"
	FreeLink    = "https://api.coingecko.com/api/v3/"
	PaidLink    = "https://pro-api.coingecko.com/api/v3/"
	ApiKeyParam = "x_cg_pro_api_key"
)
View Source
const (
	Binance = "binance"
)
View Source
const (
	Bitfinex = "bitfinex"
)

Variables

View Source
var (
	// UpdateTick defines the wait time between price updates.
	UpdateTick = 8 * time.Second
)

Functions

func BinancePriceUpdate

func BinancePriceUpdate(symbols set.Set[types.Symbol]) (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 BinanceSymbolCsv

func BinanceSymbolCsv(symbols set.Set[types.Symbol]) string

func BitfinexPriceUpdate

func BitfinexPriceUpdate(symbols set.Set[types.Symbol]) (rawPrices map[types.Symbol]float64, err error)

BitfinexPriceUpdate returns the prices given the symbols or an error.

func BitfinexSymbolCsv

func BitfinexSymbolCsv(symbols set.Set[types.Symbol]) string

func CoingeckoPriceUpdate

func CoingeckoPriceUpdate(jsonConfig json2.RawMessage) types.FetchPricesFunc

Types

type BinanceTicker

type BinanceTicker struct {
	Symbol string  `json:"symbol"`
	Price  float64 `json:"price,string"`
}

type CoingeckoConfig

type CoingeckoConfig struct {
	ApiKey string `json:"api_key"`
}

type CoingeckoTicker

type CoingeckoTicker struct {
	Price float64 `json:"usd,string"`
}

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

Jump to

Keyboard shortcuts

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