price_encoder

package
v0.0.0-...-cc24d94 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	FailedToUpdateExchangePrice = "Failed to update exchange price in price daemon priceEncoder"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PriceEncoder

type PriceEncoder interface {
	types.ExchangeConfigUpdater
	ProcessPriceFetcherResponse(response *price_fetcher.PriceFetcherSubtaskResponse)
}

type PriceEncoderImpl

type PriceEncoderImpl struct {
	// contains filtered or unexported fields
}

func NewPriceEncoder

func NewPriceEncoder(
	mutableExchangeConfig *types.MutableExchangeMarketConfig,
	mutableMarketConfigs []*types.MutableMarketConfig,
	exchangeToMarketPrices types.ExchangeToMarketPrices,
	logger log.Logger,
	bCh <-chan *price_fetcher.PriceFetcherSubtaskResponse,
) (*PriceEncoderImpl, error)

NewPriceEncoder creates a new, initialized PriceEncoderImpl struct. It manages decoding and converting of raw prices returned from the price fetcher into the shared exchangeToMarketPrices cache. All prices stored in the cache are converted to the market price in a quote currency of USD, even if the API request was made for a different market and/or used a different quote currency.

func (*PriceEncoderImpl) GetExchangeId

func (p *PriceEncoderImpl) GetExchangeId() types.ExchangeId

GetExchangeId returns the exchange id for this PriceEncoder.

func (*PriceEncoderImpl) ProcessPriceFetcherResponse

func (p *PriceEncoderImpl) ProcessPriceFetcherResponse(response *price_fetcher.PriceFetcherSubtaskResponse)

ProcessPriceFetcherResponse consumes the (price, error) response from the price fetcher and either updates the exchangeToMarketPrices cache with a valid price, or appropriately logs and reports metrics for errors.

func (*PriceEncoderImpl) UpdateMutableExchangeConfig

func (p *PriceEncoderImpl) UpdateMutableExchangeConfig(
	newConfig *types.MutableExchangeMarketConfig,
	newMarketConfigs []*types.MutableMarketConfig,
) error

UpdateMutableExchangeConfig updates the price encoder with the most current copy of the exchange config, as well as all markets supported by the exchange. This method is added to support the ExchangeConfigUpdater interface.

func (*PriceEncoderImpl) UpdatePrice

func (p *PriceEncoderImpl) UpdatePrice(marketPriceTimestamp *types.MarketPriceTimestamp)

UpdatePrice updates the price cache shared by the price updater with the converted market price.

Jump to

Keyboard shortcuts

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