Documentation ¶
Index ¶
Constants ¶
View Source
const (
GeckoURL = "https://api.coingecko.com/api/v3/coins/%s"
)
View Source
const (
YahooURL = "https://query1.finance.yahoo.com/v10/finance/quoteSummary/%s?modules=price"
)
Variables ¶
This section is empty.
Functions ¶
func FormatAmount ¶
Types ¶
type CurrentPrice ¶
type GeckoPriceResults ¶
type GeckoPriceResults struct { ID string `json:"id"` Symbol string `json:"symbol"` Name string `json:"name"` MarketData MarketData `json:"market_data"` }
The following is the API response gecko gives
func GetCryptoPrice ¶
func GetCryptoPrice(ticker string) (GeckoPriceResults, error)
GetCryptoPrice retrieves the price of a given ticker using the coin gecko API
type MarketData ¶
type MarketData struct { CurrentPrice CurrentPrice `json:"current_price"` MarketCap CurrentPrice `json:"market_cap"` TotalValueLocked TotalValueLocked `json:"total_value_locked"` PriceChangePercent float64 `json:"price_change_percentage_24h"` PriceChangeCurrency CurrentPrice `json:"price_change_24h_in_currency"` MarketCapChangePercent float64 `json:"market_cap_change_percentage_24h"` MarketCapChangeCurrency CurrentPrice `json:"market_cap_change_24h_in_currency"` TotalSupply float64 `json:"total_supply"` CirculatingSupply float64 `json:"circulating_supply"` }
type PriceResults ¶
The following is the API response yahoo gives
func GetStockPrice ¶
func GetStockPrice(ticker string) (PriceResults, error)
GetStockPrice retrieves the price of a given ticker using the yahoo API
type Pricing ¶
type Pricing struct { MaxAge int `json:"maxAge"` PreMarketChangePercent Change `json:"preMarketChangePercent"` PreMarketChange Change `json:"preMarketChange"` PreMarketPrice Change `json:"preMarketPrice"` PreMarketSource string `json:"preMarketSource"` PostMarketChangePercent Change `json:"postMarketChangePercent"` PostMarketChange Change `json:"postMarketChange"` PostMarketTime int `json:"postMarketTime"` PostMarketPrice Change `json:"postMarketPrice"` PostMarketSource string `json:"postMarketSource"` RegularMarketChangePercent Change `json:"regularMarketChangePercent"` RegularMarketChange Change `json:"regularMarketChange"` RegularMarketTime int `json:"regularMarketTime"` RegularMarketPrice Change `json:"regularMarketPrice"` RegularMarketSource string `json:"regularMarketSource"` RegularMarketDayHigh Change `json:"regularMarketDayHigh"` RegularMarketDayLow Change `json:"regularMarketDayLow"` RegularMarketVolume Change `json:"regularMarketVolume"` AverageDailyVolume10Day Change `json:"averageDailyVolume10Day"` AverageDailyVolume3Month Change `json:"averageDailyVolume3Month"` RegularMarketPreviousClose Change `json:"regularMarketPreviousClose"` RegularMarketOpen Change `json:"regularMarketOpen"` StrikePrice Change `json:"strikePrice"` OpenInterest Change `json:"openInterest"` Exchange string `json:"exchange"` ExchangeName string `json:"exchangeName"` QuoteType string `json:"quoteType"` QuoteSourceName string `json:"quoteSourceName"` ExchangeDataDelayedBy int `json:"exchangeDataDelayedBy"` MarketState string `json:"marketState"` Symbol string `json:"symbol"` ShortName string `json:"shortName"` LongName string `json:"longName"` Currency string `json:"currency"` CurrencySymbol string `json:"currencySymbol"` PriceHint Change `json:"priceHint"` Volume24Hr Change `json:"volume24Hr"` VolumeAllCurrencies Change `json:"volumeAllCurrencies"` CirculatingSupply Change `json:"circulatingSupply"` MarketCap Change `json:"marketCap"` }
type TotalValueLocked ¶
Click to show internal directories.
Click to hide internal directories.