coingecko

package
v0.0.0-...-8276e37 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: NCSA Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProviderName cotains the common name of the provider.
	ProviderName string = "Coingecko"
	// APIBaseURL points to the basic API endpoint used for all requests.
	APIBaseURL string = "https://api.coingecko.com/api/v3"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CoinList

type CoinList []struct {
	ID     string `json:"id"`
	Symbol string `json:"symbol"`
	Name   string `json:"name"`
}

CoinList stores the symbol to ID mappings required for Coingecko API usage.

type Coingecko

type Coingecko struct {

	// Error is used to convey possible errors.
	Error error
	// contains filtered or unexported fields
}

Coingecko is a specific implementation of a Provider.

func New

func New(c *resty.Client) (p Coingecko)

New initializes and returns a usable Provider object.

func (*Coingecko) FetchRate

func (p *Coingecko) FetchRate(coin string, fiat string) (rate types.ExchangeRate, err error)

FetchRate returns a single ExchangeRate.

func (*Coingecko) FetchRateSynced

func (p *Coingecko) FetchRateSynced(coin string, fiat string, rates *types.ExchangeRates, wg *sync.WaitGroup)

FetchRateSynced is a multi-threading implementation of FetchRate.

func (*Coingecko) PopulateCoinList

func (p *Coingecko) PopulateCoinList() (err error)

PopulateCoinList retrieves all coins known to Coingecko and stores that information for further use. This is required for Coingecko because common currency symbols need to be mapped to Coingecko-specific IDs for FetchRate().

func (*Coingecko) SetMarket

func (p *Coingecko) SetMarket(market string) (err error)

SetMarket does nothing, but needs to be implemented to satisfy the Provider interface.

func (*Coingecko) SymbolToID

func (p *Coingecko) SymbolToID(symbol string) (id string, err error)

SymbolToID returns the Coingecko-specific ID for a common currency symbol.

type Prices

type Prices map[string]map[string]float64

Prices is used to unmarshal an API result of a specific rate.

Jump to

Keyboard shortcuts

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