Documentation ¶
Index ¶
- Constants
- Variables
- func BinancePriceUpdate(symbols set.Set[types.Symbol]) (rawPrices map[types.Symbol]float64, err error)
- func BinanceSymbolCsv(symbols set.Set[types.Symbol]) string
- func BitfinexPriceUpdate(symbols set.Set[types.Symbol]) (rawPrices map[types.Symbol]float64, err error)
- func BitfinexSymbolCsv(symbols set.Set[types.Symbol]) string
- func CoingeckoPriceUpdate(jsonConfig json2.RawMessage) types.FetchPricesFunc
- type BinanceTicker
- type CoingeckoConfig
- type CoingeckoTicker
- type TickSource
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 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 CoingeckoPriceUpdate ¶
func CoingeckoPriceUpdate(jsonConfig json2.RawMessage) types.FetchPricesFunc
Types ¶
type BinanceTicker ¶
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
Click to show internal directories.
Click to hide internal directories.