fiat

package
v0.0.0-...-fae8f5a Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coingecko

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

Coingecko is a structure that implements RatesDownloaderInterface

func (*Coingecko) CurrentTickers

func (cg *Coingecko) CurrentTickers() (*common.CurrencyRatesTicker, error)

CurrentTickers returns the latest exchange rates

func (*Coingecko) FiveMinutesTickers

func (cg *Coingecko) FiveMinutesTickers() (*[]common.CurrencyRatesTicker, error)

HourlyTickers returns the array of the exchange rates in five minutes granularity

func (*Coingecko) HourlyTickers

func (cg *Coingecko) HourlyTickers() (*[]common.CurrencyRatesTicker, error)

HourlyTickers returns the array of the exchange rates in hourly granularity

func (*Coingecko) UpdateHistoricalTickers

func (cg *Coingecko) UpdateHistoricalTickers() error

UpdateHistoricalTickers gets historical tickers for the main crypto currency

func (*Coingecko) UpdateHistoricalTokenTickers

func (cg *Coingecko) UpdateHistoricalTokenTickers() error

UpdateHistoricalTokenTickers gets historical tickers for the tokens

type FiatRates

type FiatRates struct {
	Enabled bool
	// contains filtered or unexported fields
}

FiatRates is used to fetch and refresh fiat rates

func NewFiatRates

func NewFiatRates(db *db.RocksDB, configFileContent []byte, metrics *common.Metrics, callback OnNewFiatRatesTicker) (*FiatRates, error)

NewFiatRates initializes the FiatRates handler

func (*FiatRates) GetCurrentTicker

func (fr *FiatRates) GetCurrentTicker(vsCurrency string, token string) *common.CurrencyRatesTicker

GetCurrentTicker returns current ticker

func (*FiatRates) GetTickersForTimestamps

func (fr *FiatRates) GetTickersForTimestamps(timestamps []int64, vsCurrency string, token string) (*[]*common.CurrencyRatesTicker, error)

GetTickersForTimestamps returns tickers for slice of timestamps, that contain requested vsCurrency and token

func (*FiatRates) RunDownloader

func (fr *FiatRates) RunDownloader() error

RunDownloader periodically downloads current (every 15 minutes) and historical (once a day) tickers

type OnNewFiatRatesTicker

type OnNewFiatRatesTicker func(ticker *common.CurrencyRatesTicker)

OnNewFiatRatesTicker is used to send notification about a new FiatRates ticker

type RatesDownloaderInterface

type RatesDownloaderInterface interface {
	CurrentTickers() (*common.CurrencyRatesTicker, error)
	HourlyTickers() (*[]common.CurrencyRatesTicker, error)
	FiveMinutesTickers() (*[]common.CurrencyRatesTicker, error)
	UpdateHistoricalTickers() error
	UpdateHistoricalTokenTickers() error
}

RatesDownloaderInterface provides method signatures for a specific fiat rates downloader

func NewCoinGeckoDownloader

func NewCoinGeckoDownloader(db *db.RocksDB, url string, coin string, platformIdentifier string, platformVsCurrency string, allowedVsCurrencies string, timeFormat string, metrics *common.Metrics, throttleDown bool) RatesDownloaderInterface

NewCoinGeckoDownloader creates a coingecko structure that implements the RatesDownloaderInterface

Jump to

Keyboard shortcuts

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