Documentation
¶
Index ¶
- func GetAssets(ctx context.Context, dataChannel chan AssetData, sendData *bool) error
- func GetCoinDetails(ctx context.Context, id string, dataChannel chan CoinData) error
- func GetCoinHistory(ctx context.Context, id string, intervalChannel chan string, ...) error
- func GetFavouritePrices(ctx context.Context, favourites map[string]bool, dataChannel chan CoinData) error
- func GetLivePrice(ctx context.Context, id string, dataChannel chan string) error
- func GetPercentageChangeForDuration(coinData geckoTypes.CoinsMarketItem, duration string) float64
- type AssetData
- type CoinCapAsset
- type CoinCapData
- type CoinData
- type CoinDetails
- type CoinID
- type CoinIDMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCoinDetails ¶
GetCoinDetails fetches details for a coin specified by id and sends the data on dataChannel
func GetCoinHistory ¶
func GetCoinHistory(ctx context.Context, id string, intervalChannel chan string, dataChannel chan CoinData) error
GetCoinHistory gets price history of a coin specified by id, for an interval received through the interval channel. The default interval is set as 24 Hours
func GetFavouritePrices ¶
func GetFavouritePrices(ctx context.Context, favourites map[string]bool, dataChannel chan CoinData) error
GetFavouritePrices gets coin prices for coins specified by favourites. This data is returned on the dataChannel.
func GetLivePrice ¶
GetLivePrice uses a websocket to stream realtime prices of a coin specified by id. The prices are sent on the dataChannel
func GetPercentageChangeForDuration ¶
func GetPercentageChangeForDuration(coinData geckoTypes.CoinsMarketItem, duration string) float64
GetPercentageChangeForDuration returns price change percentage given a CoinsMarketItem and a duration, If the specified duration does not exist, 24 Hour change percent is returned
Types ¶
type AssetData ¶
type AssetData struct {
TopCoinData [][]float64
MaxPrices []float64
MinPrices []float64
TopCoins []string
AllCoinData geckoTypes.CoinsMarket
}
AssetData is used to hold details of multiple coins and the price history of top ranked coins along with their names
type CoinCapAsset ¶
type CoinCapAsset struct {
ID string `json:"id"`
Rank string `json:"rank"`
Symbol string `json:"symbol"`
Name string `json:"name"`
Supply string `json:"supply"`
MaxSupply string `json:"maxSupply"`
MarketCapUsd string `json:"marketCapUsd"`
VolumeUsd24Hr string `json:"volumeUsd24Hr"`
PriceUsd string `json:"priceUsd"`
ChangePercent24Hr string `json:"changePercent24Hr"`
Vwap24Hr string `json:"vwap24Hr"`
Explorer string `json:"explorer"`
}
CoinCapAsset is used to marshal asset data from coinCap APIs
type CoinCapData ¶
type CoinCapData struct {
Data []CoinCapAsset `json:"data"`
Timestamp uint `json:"timestamp"`
}
CoinCapData is used to marshall multiple assets from CoinCap APIs
type CoinData ¶
type CoinData struct {
Type string
PriceHistory []float64
MinPrice float64
MaxPrice float64
Details CoinDetails
Favourites map[string]float64
}
CoinData Holds data pertaining to a single coin. This is used to serve per coin details. It additionally holds a map of favourite coins.
type CoinDetails ¶
type CoinDetails struct {
Name string
Symbol string
Rank string
BlockTime string
MarketCap float64
Website string
Explorers [][]string
ATH float64
ATHDate string
ATL float64
ATLDate string
High24 float64
Low24 float64
TotalVolume float64
ChangePercents [][]string
TotalSupply float64
CurrentSupply float64
LastUpdate string
}
CoinDetails holds information about a coin