Documentation ¶
Index ¶
- Variables
- func ValidateCode(code string) error
- func ValidateDate(date string) error
- func ValidateSymbols(symbols []string) error
- func ValidateTimeFrame(TimeFrame [2]string) error
- type Exchange
- func (exchange *Exchange) ConvertAt(date string, target string, amount int) (*big.Float, error)
- func (exchange *Exchange) ConvertTo(target string, amount int) (*big.Float, error)
- func (exchange *Exchange) CryptoCodes() ([]string, error)
- func (exchange *Exchange) CryptoData() (map[string]map[string]string, error)
- func (exchange *Exchange) FluctuationAll(start string, end string) (map[string]map[string]*big.Float, error)
- func (exchange *Exchange) FluctuationMultiple(start string, end string, symbols []string) (map[string]map[string]*big.Float, error)
- func (exchange *Exchange) FluctuationSingle(start string, end string, symbol string) (map[string]*big.Float, error)
- func (exchange *Exchange) ForexCodes() ([]string, error)
- func (exchange *Exchange) ForexData() (map[string]map[string]string, error)
- func (exchange *Exchange) HistoricalRatesAll(date string) (map[string]*big.Float, error)
- func (exchange *Exchange) HistoricalRatesMultiple(date string, symbols []string) (map[string]*big.Float, error)
- func (exchange *Exchange) HistoricalRatesSingle(date string, symbol string) (*big.Float, error)
- func (exchange *Exchange) LatestRatesAll() (map[string]*big.Float, error)
- func (exchange *Exchange) LatestRatesMultiple(symbols []string) (map[string]*big.Float, error)
- func (exchange *Exchange) LatestRatesSingle(symbol string) (*big.Float, error)
- func (exchange *Exchange) SetBase(base string) error
- func (exchange *Exchange) SetCache(cache bool)
- func (exchange *Exchange) TimeseriesAll(start string, end string) (map[string]map[string]*big.Float, error)
- func (exchange *Exchange) TimeseriesMultiple(start string, end string, symbols []string) (map[string]map[string]*big.Float, error)
- func (exchange *Exchange) TimeseriesSingle(start string, end string, symbol string) (map[string]map[string]*big.Float, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidAPIResponse = errors.New("Unknown API error")
ErrInvalidAPIResponse is returned when the API return success: false
var ErrInvalidCode = errors.New("Invalid currency code")
ErrInvalidCode is returned when the currency code is invalid
var ErrInvalidDate = errors.New("Oldest possible date is 1999-01-04")
ErrInvalidDate is returned when the date is too old
var ErrInvalidDateFormat = errors.New("Date format must be YYYY-MM-DD")
ErrInvalidDateFormat is returned when the date isn't formatted as YYYY-MM-DD
var ErrInvalidTimeFrame = errors.New("From date must be older than To date")
ErrInvalidTimeFrame is returned when the to date is older than to date. For example flipped the arguments
var ErrTimeframeExceeded = errors.New("Maximum allowed timeframe is 365 days")
ErrTimeframeExceeded is returned when the time between start_date and end_date is bigger than 365 days
Functions ¶
func ValidateCode ¶
ValidateCode validates a single symbol code
func ValidateDate ¶
ValidateDate validates date string according to YYYY-MM-DD format and if it's
func ValidateSymbols ¶
ValidateSymbols validates all symbols' codes in an array
func ValidateTimeFrame ¶
ValidateTimeFrame checks if the from and to date are not more than 365 days apart and they're not mixed
Types ¶
type Exchange ¶
Exchange is returned by New() and allows access to the methods
func (*Exchange) ConvertAt ¶
ConvertAt converts the amount from the exchange.Base currency to the target currency at a selected historical date
func (*Exchange) ConvertTo ¶
ConvertTo converts the amount from the exchange.Base currency to the target currency
func (*Exchange) CryptoCodes ¶
CryptoCodes returns and array of supported cryptocurrency codes
func (*Exchange) CryptoData ¶
CryptoData returns a map of supported cryptocurrencies data (name and symbol)
func (*Exchange) FluctuationAll ¶
func (exchange *Exchange) FluctuationAll(start string, end string) (map[string]map[string]*big.Float, error)
FluctuationAll returns the fluctuation for all supported symbols
func (*Exchange) FluctuationMultiple ¶
func (exchange *Exchange) FluctuationMultiple(start string, end string, symbols []string) (map[string]map[string]*big.Float, error)
FluctuationMultiple returns the fluctuation for multiple symbols
func (*Exchange) FluctuationSingle ¶
func (exchange *Exchange) FluctuationSingle(start string, end string, symbol string) (map[string]*big.Float, error)
FluctuationSingle returns the fluctuation for a single symbol
func (*Exchange) ForexCodes ¶
ForexCodes returns and array of supported forex/fiat currency codes
func (*Exchange) ForexData ¶
ForexData returns a map of supported forex/fiat currencies data (code & description)
func (*Exchange) HistoricalRatesAll ¶
HistoricalRatesAll returns the historical exchange rates for all supported currencies
func (*Exchange) HistoricalRatesMultiple ¶
func (exchange *Exchange) HistoricalRatesMultiple(date string, symbols []string) (map[string]*big.Float, error)
HistoricalRatesMultiple returns the historical exchange rates for multiple currencies
func (*Exchange) HistoricalRatesSingle ¶
HistoricalRatesSingle returns the historical exchange rates for a single currency
func (*Exchange) LatestRatesAll ¶
LatestRatesAll returns the latest exchange rates for all supportedcurrencies
func (*Exchange) LatestRatesMultiple ¶
LatestRatesMultiple returns the latest exchange rates for multiple currencies
func (*Exchange) LatestRatesSingle ¶
LatestRatesSingle returns the latest exchange rates for a single currencies
func (*Exchange) SetCache ¶
SetCache enables and disable caching (caching last till midnight when the exchange rates are updated)
func (*Exchange) TimeseriesAll ¶
func (exchange *Exchange) TimeseriesAll(start string, end string) (map[string]map[string]*big.Float, error)
TimeseriesAll returns the timeseries for all supported symbols