price_fetcher

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriceFetcher

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

PriceFetcher fetches prices from an exchange by making a query based on the `exchangeConfig` specifications and then encodes the price or any associated error.

func NewPriceFetcher

func NewPriceFetcher(
	exchangeStartupConfig types.ExchangeStartupConfig,
	exchangeDetails types.ExchangeQueryDetails,
	mutableExchangeConfig *types.MutableExchangeMarketConfig,
	mutableMarketConfigs []*types.MutableMarketConfig,
	queryHandler handler.ExchangeQueryHandler,
	logger log.Logger,
	bCh chan<- *PriceFetcherSubtaskResponse,
) (
	*PriceFetcher,
	error,
)

NewPriceFetcher creates a new PriceFetcher struct. It manages querying markets via goroutine queries to an exchange and encodes the responses or related errors into the shared buffered channel `bCh`.

func (*PriceFetcher) GetExchangeId

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

GetExchangeId returns the exchange id for the exchange queried by the price fetcher. This method is added to support the MutableExchangeConfigUpdater interface.

func (*PriceFetcher) RunTaskLoop

func (pf *PriceFetcher) RunTaskLoop(requestHandler daemontypes.RequestHandler)

RunTaskLoop queries the exchange for market prices. Each goroutine makes a single exchange query for a specific set of one or more markets. RunTaskLoop blocks until all spawned goroutines have completed.

func (*PriceFetcher) UpdateMutableExchangeConfig

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

UpdateMutableExchangeConfig updates the price fetcher 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.

type PriceFetcherSubtaskResponse

type PriceFetcherSubtaskResponse struct {
	Price *types.MarketPriceTimestamp
	Err   error
}

PriceFetcherSubtaskResponse represents a transformed exchange API response that contains price info or an error.

Jump to

Keyboard shortcuts

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