exchangerates

package
v0.0.0-...-b118cd4 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CoinGeckoCurrencyUSD is the name of US dollars in CoinGecko.
	CoinGeckoCurrencyUSD = "usd"
	// CoinGeckoCurrencyEUR is the name of euros in CoinGecko.
	CoinGeckoCurrencyEUR = "eur"
	// CoinGeckoCurrencyCAD is the name of Canadian dollars in CoinGecko.
	CoinGeckoCurrencyCAD = "cad"
	// CoinGeckoCurrencyAUD is the name of Australian dollars in CoinGecko.
	CoinGeckoCurrencyAUD = "aud"
	// CoinGeckoCurrencyGBP is the name of British pounds in CoinGecko.
	CoinGeckoCurrencyGBP = "gbp"
	// CoinGeckoCurrencyJPY is the name of Japanese yen in CoinGecko.
	CoinGeckoCurrencyJPY = "jpy"
	// CoinGeckoCurrencyCNY is the name of Chinese yuan in CoinGecko.
	CoinGeckoCurrencyCNY = "cny"
	// CoinGeckoCurrencyBTC is the name of Bitcoin in CoinGecko.
	CoinGeckoCurrencyBTC = "btc"
	// CoinGeckoCurrencyETH is the name of Ethereum in CoinGecko.
	CoinGeckoCurrencyETH = "eth"
)
View Source
const (
	// CurrencyUSD represents US dollars.
	CurrencyUSD = "USD"
	// CurrencyEUR represents euros.
	CurrencyEUR = "EUR"
	// CurrencyCAD represents Canadian dollars.
	CurrencyCAD = "CAD"
	// CurrencyAUD represents Australian dollars.
	CurrencyAUD = "AUD"
	// CurrencyGBP represents British pounds.
	CurrencyGBP = "GBP"
	// CurrencyJPY represents Japanese yen.
	CurrencyJPY = "JPY"
	// CurrencyCNY represents Chinese yuan.
	CurrencyCNY = "CNY"
	// CurrencyBTC represents Bitcoin.
	CurrencyBTC = "BTC"
	// CurrencyETH represents Ethereum.
	CurrencyETH = "ETH"
)
View Source
const (
	// KrakenPairSiacoinUSD is the ID of SC/USD pair in Kraken
	KrakenPairSiacoinUSD = "SCUSD"
	// KrakenPairSiacoinEUR is the ID of SC/EUR pair in Kraken
	KrakenPairSiacoinEUR = "SCEUR"
	// KrakenPairSiacoinBTC is the ID of SC/BTC pair in Kraken
	KrakenPairSiacoinBTC = "SCXBT"
)
View Source
const (
	// CoinGeckoTokenSiacoin is the token ID of Siacoin in CoinGecko
	CoinGeckoTokenSiacoin = "siacoin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Source

type Source interface {
	Last(currency string) (float64, error)
	Start(ctx context.Context)
}

An Source returns the price of 1 unit of an asset in USD.

func NewAverager

func NewAverager(ignoreOnError bool, sources ...Source) (Source, error)

NewAverager returns an exchange rate source that averages multiple exchange rates.

func NewCoinGecko

func NewCoinGecko(pro bool, apiKey string, pairMap map[string]string, token string, refresh time.Duration) Source

NewCoinGecko creates an Source with user-specified mappings

func NewKraken

func NewKraken(pairMap map[string]string, refresh time.Duration) Source

NewKraken returns an Source that gets data from Kraken.

Jump to

Keyboard shortcuts

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