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 ¶
This section is empty.
Types ¶
type CurrentPrice ¶
type CurrentPrice struct {
USD float64 `json:"usd"`
}
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
func GetCryptoPriceCache ¶
func GetCryptoPriceCache(client *redis.Client, ctx context.Context, ticker string) (GeckoPriceResults, error)
GetCryptoPriceCache attempt to use cache to get info
type MarketData ¶
type MarketData struct { CurrentPrice CurrentPrice `json:"current_price"` PriceChange float64 `json:"price_change_24h"` PriceChangePercent float64 `json:"price_change_percentage_24h"` }
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"` 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"` }
Click to show internal directories.
Click to hide internal directories.