Documentation ¶
Index ¶
- Constants
- func StraightRates(intRates []*InterestRate) map[time.Time]float64
- func WeightedRates(intRates []*InterestRate, dateInit, dateFinal time.Time, holidays []time.Time, ...) (map[time.Time]float64, int)
- type AssetQuotation
- type AssetQuotationFull
- type Author
- type BenchmarkedIndex
- type BenchmarkedIndexValue
- type Change
- type Coin
- type CoinSymbolAndName
- type Coins
- type CryptoIndex
- type CryptoIndexConstituent
- type CryptoIndexMintAmount
- type CurrencyChange
- type DB
- func (db *DB) AddAssetQuotationsToBatch(quotations []*AssetQuotation) error
- func (db *DB) ExistInterestRate(symbol, date string) bool
- func (db *DB) Flush() error
- func (db *DB) GetAllTrades(t time.Time, maxTrades int) ([]dia.Trade, error)
- func (db *DB) GetAssetPriceUSD(asset dia.Asset, timestamp time.Time) (price float64, err error)
- func (db *DB) GetAssetPriceUSDCache(asset dia.Asset) (price float64, err error)
- func (db *DB) GetAssetPriceUSDLatest(asset dia.Asset) (price float64, err error)
- func (db *DB) GetAssetQuotation(asset dia.Asset, timestamp time.Time) (*AssetQuotation, error)
- func (db *DB) GetAssetQuotationCache(asset dia.Asset) (*AssetQuotation, error)
- func (db *DB) GetAssetQuotationLatest(asset dia.Asset) (*AssetQuotation, error)
- func (db *DB) GetAssetsMarketCap(asset dia.Asset) (float64, error)
- func (db *DB) GetAvailablePairs(exchange string) ([]dia.ExchangePair, error)
- func (db *DB) GetBenchmarkedIndexValuesInflux(symbol string, starttime time.Time, endtime time.Time) (BenchmarkedIndex, error)
- func (db *DB) GetCVIInflux(starttime time.Time, endtime time.Time, symbol string) ([]dia.CviDataPoint, error)
- func (db *DB) GetCommitByDate(user, repository string, date time.Time) (GithubCommit, error)
- func (db *DB) GetCommitByHash(user, repository, hash string) (GithubCommit, error)
- func (db *DB) GetCompoundedAvg(symbol string, date time.Time, calDays, daysPerYear int, rounding int) (*InterestRate, error)
- func (db *DB) GetCompoundedAvgDIARange(symbol string, dateInit, dateFinal time.Time, calDays, daysPerYear int, ...) (values []*InterestRate, err error)
- func (db *DB) GetCompoundedAvgRange(symbol string, dateInit, dateFinal time.Time, calDays, daysPerYear int, ...) (values []*InterestRate, err error)
- func (db *DB) GetCompoundedIndex(symbol string, date time.Time, daysPerYear int, rounding int) (*InterestRate, error)
- func (db *DB) GetCompoundedIndexRange(symbol string, dateInit, dateFinal time.Time, daysPerYear int, rounding int) (values []*InterestRate, err error)
- func (db *DB) GetCompoundedRate(symbol string, dateInit, date time.Time, daysPerYear int, rounding int) (*InterestRate, error)
- func (db *DB) GetCryptoIndex(starttime time.Time, endtime time.Time, name string) ([]CryptoIndex, error)
- func (db *DB) GetCryptoIndexConstituentPrice(symbol string, date time.Time) (float64, error)
- func (db *DB) GetCryptoIndexConstituents(starttime time.Time, endtime time.Time, asset dia.Asset, indexSymbol string) ([]CryptoIndexConstituent, error)
- func (db *DB) GetCurrencyChange() (*Change, error)
- func (db *DB) GetDefiProtocol(name string) (dia.DefiProtocol, error)
- func (db *DB) GetDefiProtocols() ([]dia.DefiProtocol, error)
- func (db *DB) GetDefiRateInflux(starttime time.Time, endtime time.Time, asset string, protocol string) ([]dia.DefiRate, error)
- func (db *DB) GetDefiStateInflux(starttime time.Time, endtime time.Time, protocol string) (retval []dia.DefiProtocolState, err error)
- func (db *DB) GetExchanges() (allExchanges []string)
- func (db *DB) GetFarmingPoolData(starttime, endtime time.Time, protocol, poolID string) ([]FarmingPool, error)
- func (db *DB) GetFarmingPools() ([]FarmingPoolType, error)
- func (db *DB) GetFilterPoints(filter string, exchange string, symbol string, scale string, ...) (*Points, error)
- func (db *DB) GetFirstDate(symbol string) (time.Time, error)
- func (db *DB) GetFirstTradeDate(table string) (time.Time, error)
- func (db *DB) GetForeignPriceYesterday(symbol, source string) (float64, error)
- func (db *DB) GetForeignQuotationInflux(symbol, source string, timestamp time.Time) (ForeignQuotation, error)
- func (db *DB) GetForeignSymbolsInflux(source string) (symbols []SymbolShort, err error)
- func (db *DB) GetIndexPrice(asset dia.Asset, time time.Time) (trade *dia.Trade, err error)
- func (db *DB) GetInterestRate(symbol, date string) (*InterestRate, error)
- func (db *DB) GetInterestRateRange(symbol, dateInit, dateFinal string) ([]*InterestRate, error)
- func (db *DB) GetIssuer(symbol string) (string, error)
- func (db *DB) GetItinBySymbol(symbol string) (dia.ItinToken, error)
- func (db *DB) GetLastPriceBefore(asset dia.Asset, filter string, exchange string, timestamp time.Time) (Price, error)
- func (db *DB) GetLastTradeTimeForExchange(asset dia.Asset, exchange string) (*time.Time, error)
- func (db *DB) GetLastTrades(asset dia.Asset, exchange string, maxTrades int) ([]dia.Trade, error)
- func (db *DB) GetLatestCommit(user, repository string) (GithubCommit, error)
- func (db *DB) GetLatestSupply(symbol string) (*dia.Supply, error)
- func (db *DB) GetOldTradesFromInflux(table string, exchange string, verified bool, timeInit, timeFinal time.Time) ([]dia.Trade, error)
- func (db *DB) GetOptionMeta(baseCurrency string) ([]dia.OptionMeta, error)
- func (db *DB) GetOptionOrderbookDataInflux(t dia.OptionMeta) (dia.OptionOrderbookDatum, error)
- func (db *DB) GetPaxgQuotationGrams() (*Quotation, error)
- func (db *DB) GetPaxgQuotationOunces() (*Quotation, error)
- func (db *DB) GetPrice(asset dia.Asset, exchange string) (float64, error)
- func (db *DB) GetPrice14d(asset dia.Asset, exchange string) (float64, error)
- func (db *DB) GetPrice1h(asset dia.Asset, exchange string) (float64, error)
- func (db *DB) GetPrice30d(asset dia.Asset, exchange string) (float64, error)
- func (db *DB) GetPrice7d(asset dia.Asset, exchange string) (float64, error)
- func (db *DB) GetPriceUSD(symbol string) (float64, error)
- func (db *DB) GetPriceYesterday(asset dia.Asset, exchange string) (float64, error)
- func (db *DB) GetQuotation(symbol string) (*Quotation, error)
- func (db *DB) GetRates() []string
- func (db *DB) GetRatesMeta() (RatesMeta []InterestRateMeta, err error)
- func (db *DB) GetSortedAssetQuotations(assets []dia.Asset) ([]AssetQuotation, error)
- func (db *DB) GetStockQuotation(symbol string, timestamp time.Time) (StockQuotation, error)
- func (db *DB) GetSupply(symbol string, starttime, endtime time.Time) ([]dia.Supply, error)
- func (db *DB) GetSupplyInflux(asset dia.Asset, starttime time.Time, endtime time.Time) ([]dia.Supply, error)
- func (db *DB) GetSymbols(exchange string) ([]string, error)
- func (db *DB) GetTopAssetByMcap(symbol string, relDB *RelDB) (topAsset dia.Asset, err error)
- func (db *DB) GetTopAssetByVolume(symbol string, relDB *RelDB) (topAsset dia.Asset, err error)
- func (db *DB) GetTradeInflux(asset dia.Asset, exchange string, timestamp time.Time) (*dia.Trade, error)
- func (db *DB) GetTradePrice14d(asset dia.Asset, exchange string) (*dia.Trade, error)
- func (db *DB) GetTradePrice1h(asset dia.Asset, exchange string) (*dia.Trade, error)
- func (db *DB) GetTradePrice24h(asset dia.Asset, exchange string) (*dia.Trade, error)
- func (db *DB) GetTradePrice30d(asset dia.Asset, exchange string) (*dia.Trade, error)
- func (db *DB) GetTradePrice7d(asset dia.Asset, exchange string) (*dia.Trade, error)
- func (db *DB) GetTradePriceBefore(asset dia.Asset, exchange string, timestamp time.Time) (*dia.Trade, error)
- func (db *DB) GetTradesByExchanges(asset dia.Asset, exchanges []string, startTime, endTime time.Time, ...) ([]dia.Trade, error)
- func (db *DB) GetVolume(asset dia.Asset) (*float64, error)
- func (db *DB) GetVolumeInflux(asset dia.Asset, starttime time.Time, endtime time.Time) (float64, error)
- func (db *DB) RemoveExpiredOptionMeta(baseCurrency string) error
- func (db *DB) SaveCVIInflux(cviValue float64, observationTime time.Time) error
- func (db *DB) SaveETHCVIInflux(cviValue float64, observationTime time.Time) error
- func (db *DB) SaveFilterInflux(filter string, asset dia.Asset, exchange string, value float64, t time.Time) error
- func (db *DB) SaveForeignQuotationInflux(fq ForeignQuotation) error
- func (db *DB) SaveIndexEngineTimeInflux(tags map[string]string, fields map[string]interface{}, timestamp time.Time) error
- func (db *DB) SaveOptionOrderbookDatumInflux(t dia.OptionOrderbookDatum) error
- func (db *DB) SaveSupplyInflux(supply *dia.Supply) error
- func (db *DB) SaveTradeInflux(t *dia.Trade) error
- func (db *DB) SaveTradeInfluxToTable(t *dia.Trade, table string) error
- func (db *DB) SetAssetPriceUSD(asset dia.Asset, price float64, timestamp time.Time) error
- func (db *DB) SetAssetQuotation(quotation *AssetQuotation) error
- func (db *DB) SetAssetQuotationCache(quotation *AssetQuotation) (bool, error)
- func (db *DB) SetAvailablePairs(exchange string, pairs []dia.ExchangePair) error
- func (db *DB) SetBatchFiatPriceInflux(fiatQuotations []*FiatQuotation) error
- func (db *DB) SetCommit(commit GithubCommit) error
- func (db *DB) SetCryptoIndex(index *CryptoIndex) error
- func (db *DB) SetCryptoIndexConstituent(constituent *CryptoIndexConstituent, index dia.Asset) error
- func (db *DB) SetCurrencyChange(cc *Change) error
- func (db *DB) SetDefiProtocol(protocol dia.DefiProtocol) error
- func (db *DB) SetDefiRateInflux(rate *dia.DefiRate) error
- func (db *DB) SetDefiStateInflux(state *dia.DefiProtocolState) error
- func (db *DB) SetFarmingPool(pool *FarmingPool) error
- func (db *DB) SetFilter(filter string, asset dia.Asset, exchange string, value float64, t time.Time) error
- func (datastore *DB) SetInfluxClient(url string)
- func (db *DB) SetInterestRate(ir *InterestRate) error
- func (db *DB) SetItinData(token dia.ItinToken) error
- func (db *DB) SetLastTradeTimeForExchange(asset dia.Asset, exchange string, t time.Time) error
- func (db *DB) SetOptionMeta(optionMeta *dia.OptionMeta) error
- func (a *DB) SetPriceEUR(symbol string, price float64) error
- func (db *DB) SetPriceUSD(symbol string, price float64) error
- func (db *DB) SetQuotation(quotation *Quotation) error
- func (db *DB) SetQuotationEUR(quotation *Quotation) error
- func (db *DB) SetSingleFiatPriceRedis(fiatQuotation *FiatQuotation) error
- func (db *DB) SetStockQuotation(sq StockQuotation) error
- func (db *DB) SetSupply(supply *dia.Supply) error
- func (db *DB) Sum24HoursExchange(exchange string) (float64, error)
- func (db *DB) Sum24HoursInflux(asset dia.Asset, exchange string, filter string) (*float64, error)
- func (db *DB) WriteBatchInflux() error
- type Datastore
- type DefiScore
- type FarmingPool
- type FarmingPoolType
- type FiatQuotation
- type ForeignQuotation
- type GithubCommit
- type InterestRate
- type InterestRateMeta
- type Pairs
- type Point
- type Points
- type Price
- type Quotation
- type RelDB
- func (rdb *RelDB) Count() (count uint32, err error)
- func (rdb *RelDB) CountCache() (uint32, error)
- func (rdb *RelDB) GetActiveAsset(limit, skip int) (assets []dia.Asset, assetIds []string, err error)
- func (rdb *RelDB) GetActiveAssetCount() (count int, err error)
- func (rdb *RelDB) GetAllAssets(blockchain string) (assets []dia.Asset, err error)
- func (rdb *RelDB) GetAllBlockchains() ([]string, error)
- func (rdb *RelDB) GetAllNFTClasses(blockchain string) (nftClasses []dia.NFTClass, err error)
- func (rdb *RelDB) GetAsset(address, blockchain string) (asset dia.Asset, err error)
- func (rdb *RelDB) GetAssetByID(assetID string) (asset dia.Asset, err error)
- func (rdb *RelDB) GetAssetCache(assetID string) (dia.Asset, error)
- func (rdb *RelDB) GetAssetID(asset dia.Asset) (ID string, err error)
- func (rdb *RelDB) GetAssetVolume24H(asset dia.Asset) (volume float64, err error)
- func (rdb *RelDB) GetAssets(symbol string) (assets []dia.Asset, err error)
- func (rdb *RelDB) GetAssetsBySymbolName(symbol, name string) (assets []dia.Asset, err error)
- func (rdb *RelDB) GetBlockData(blockchain string, blocknumber int64) (dia.BlockData, error)
- func (rdb *RelDB) GetBlockchain(name string) (blockchain dia.BlockChain, err error)
- func (rdb *RelDB) GetByLimit(limit, skip uint32) (assets []dia.Asset, assetIds []string, err error)
- func (rdb *RelDB) GetExchangePair(exchange string, foreignname string) (dia.ExchangePair, error)
- func (rdb *RelDB) GetExchangePairCache(exchange string, foreignName string) (dia.ExchangePair, error)
- func (rdb *RelDB) GetExchangePairSymbols(exchange string) (pairs []dia.ExchangePair, err error)
- func (rdb *RelDB) GetExchangeSymbolAssetID(exchange string, symbol string) (assetID string, verified bool, err error)
- func (rdb *RelDB) GetExchangeSymbols(exchange string) (symbols []string, err error)
- func (rdb *RelDB) GetExchangesForSymbol(symbol string) (exchanges []string, err error)
- func (rdb *RelDB) GetFiatAssetBySymbol(symbol string) (asset dia.Asset, err error)
- func (rdb *RelDB) GetKeyAsset(asset dia.Asset) (string, error)
- func (rdb *RelDB) GetKeys(table string) (keys []string, err error)
- func (rdb *RelDB) GetLastBlockBlockscraper(blockchain string) (blockNumber int64, err error)
- func (rdb *RelDB) GetLastBlockNFTBid(nftclass dia.NFTClass) (blocknumber uint64, err error)
- func (rdb *RelDB) GetLastBlockNFTTradeScraper(nftclass dia.NFTClass) (blocknumber uint64, err error)
- func (rdb *RelDB) GetLastBlockheightTopshot(upperBound time.Time) (uint64, error)
- func (rdb *RelDB) GetLastNFTBid(address string, blockchain string, tokenID string, blockNumber uint64, ...) (nftBid dia.NFTBid, err error)
- func (rdb *RelDB) GetLastNFTOffer(address string, blockchain string, tokenID string, blockNumber uint64, ...) (offer dia.NFTOffer, err error)
- func (rdb *RelDB) GetNFT(address string, blockchain string, tokenID string) (dia.NFT, error)
- func (rdb *RelDB) GetNFTCategories() (categories []string, err error)
- func (rdb *RelDB) GetNFTClass(address string, blockchain string) (nftclass dia.NFTClass, err error)
- func (rdb *RelDB) GetNFTClassByID(id string) (nftclass dia.NFTClass, err error)
- func (rdb *RelDB) GetNFTClassID(address string, blockchain string) (ID string, err error)
- func (rdb *RelDB) GetNFTClasses(limit, offset uint64) (nftClasses []dia.NFTClass, err error)
- func (rdb *RelDB) GetNFTID(address string, blockchain string, tokenID string) (ID string, err error)
- func (rdb *RelDB) GetNFTPrice30Days(nftclass dia.NFTClass) (float64, error)
- func (rdb *RelDB) GetNFTTrades(nft dia.NFT) (trades []dia.NFTTrade, err error)
- func (rdb *RelDB) GetPage(pageNumber uint32) (assets []dia.Asset, hasNextPage bool, err error)
- func (rdb *RelDB) GetPairs(exchange string) (pairs []dia.ExchangePair, err error)
- func (rdb *RelDB) GetScraperConfig(ctx context.Context, scraperName string, config ScraperConfig) error
- func (rdb *RelDB) GetScraperState(ctx context.Context, scraperName string, state ScraperState) error
- func (rdb *RelDB) GetTopAssetByVolume(symbol string) (assets []dia.Asset, err error)
- func (rdb *RelDB) GetUnverifiedExchangeSymbols(exchange string) (symbols []string, err error)
- func (rdb *RelDB) IdentifyAsset(asset dia.Asset) (assets []dia.Asset, err error)
- func (rdb *RelDB) SetAsset(asset dia.Asset) error
- func (rdb *RelDB) SetAssetCache(asset dia.Asset) error
- func (rdb *RelDB) SetAssetVolume(assetVolume map[string]float64) error
- func (rdb *RelDB) SetBlockData(blockdata dia.BlockData) error
- func (rdb *RelDB) SetExchangePair(exchange string, pair dia.ExchangePair, cache bool) error
- func (rdb *RelDB) SetExchangePairCache(exchange string, pair dia.ExchangePair) error
- func (rdb *RelDB) SetExchangeSymbol(exchange string, symbol string) error
- func (rdb *RelDB) SetNFT(nft dia.NFT) error
- func (rdb *RelDB) SetNFTBid(bid dia.NFTBid) error
- func (rdb *RelDB) SetNFTClass(nftClass dia.NFTClass) error
- func (rdb *RelDB) SetNFTOffer(offer dia.NFTOffer) error
- func (rdb *RelDB) SetNFTTrade(trade dia.NFTTrade) error
- func (rdb *RelDB) SetScraperConfig(ctx context.Context, scraperName string, config ScraperConfig) error
- func (rdb *RelDB) SetScraperState(ctx context.Context, scraperName string, state ScraperState) error
- func (rdb *RelDB) UpdateNFTClassCategory(nftclassID string, category string) (bool, error)
- func (rdb *RelDB) VerifyExchangeSymbol(exchange string, symbol string, assetID string) (bool, error)
- type RelDatastore
- type ScraperConfig
- type ScraperState
- type StockQuotation
- type SymbolDetails
- type SymbolExchangeDetails
- type SymbolShort
Constants ¶
const ( WindowYesterday = 24 * 60 * 60 Window1h = 60 * 60 Window7d = 7 * 24 * 60 * 60 Window14d = 7 * 24 * 60 * 60 Window30d = 30 * 24 * 60 * 60 Window2 = 24 * 60 * 60 * 8 BufferTTL = 60 * 60 BiggestWindow = Window2 TimeOutRedis = time.Duration(time.Second*BiggestWindow + time.Second*BufferTTL) TimeOutAssetQuotation = time.Duration(time.Second * WindowYesterday) )
const (
TimeLayoutRedis = "2006-01-02 15:04:05 +0000 UTC"
)
const (
WindowVolume = 60 * 60 * 24
)
Variables ¶
This section is empty.
Functions ¶
func StraightRates ¶
func StraightRates(intRates []*InterestRate) map[time.Time]float64
StraightRates returns a map which maps a rate to each day in the time period. This includes (artificial) rate values for non-business days. intRates must be sorted by date in increasing order.
func WeightedRates ¶
func WeightedRates(intRates []*InterestRate, dateInit, dateFinal time.Time, holidays []time.Time, startIndex int) (map[time.Time]float64, int)
WeightedRates returns a map which maps a rate to each business day in the time period given by @dateInit and @dateFinal. Rates are weighted by the rate factor. intRates must be sorted by date in increasing order.
Types ¶
type AssetQuotation ¶ added in v1.2.0
AssetQuotation is the most recent price point information on an asset.
func (*AssetQuotation) MarshalBinary ¶ added in v1.2.0
func (aq *AssetQuotation) MarshalBinary() ([]byte, error)
MarshalBinary for quotations
func (*AssetQuotation) UnmarshalBinary ¶ added in v1.2.0
func (aq *AssetQuotation) UnmarshalBinary(data []byte) error
UnmarshalBinary for quotations
type AssetQuotationFull ¶ added in v1.2.0
type AssetQuotationFull struct { Symbol string Name string Address string Blockchain string Price float64 PriceYesterday float64 VolumeYesterdayUSD float64 Time time.Time Source string }
func (*AssetQuotationFull) MarshalBinary ¶ added in v1.2.0
func (aq *AssetQuotationFull) MarshalBinary() ([]byte, error)
MarshalBinary for quotations
func (*AssetQuotationFull) UnmarshalBinary ¶ added in v1.2.0
func (aq *AssetQuotationFull) UnmarshalBinary(data []byte) error
UnmarshalBinary for quotations
type BenchmarkedIndex ¶ added in v1.2.0
type BenchmarkedIndex struct { Name string Values []BenchmarkedIndexValue }
type BenchmarkedIndexValue ¶ added in v1.2.0
type Change ¶
type Change struct {
USD []CurrencyChange
}
func (*Change) UnmarshalBinary ¶
UnmarshalBinary -
type Coin ¶
type Coin struct { Symbol string Name string Price float64 PriceYesterday *float64 VolumeYesterdayUSD *float64 Time time.Time CirculatingSupply *float64 ITIN string }
func (*Coin) UnmarshalBinary ¶
type CoinSymbolAndName ¶
type Coins ¶
type Coins struct { CompleteCoinList []CoinSymbolAndName Change *Change Coins []Coin }
func (*Coins) UnmarshalBinary ¶
UnmarshalBinary -
type CryptoIndex ¶
type CryptoIndex struct { // The index has a price, hence is traded, hence must(?) correspond to some underlying asset // In case there is no underlying token, just fill the field @Symbol. Asset dia.Asset Value float64 Price float64 Price1h float64 Price24h float64 Price7d float64 Price14d float64 Price30d float64 Volume24hUSD float64 CirculatingSupply float64 Divisor float64 CalculationTime time.Time Constituents []CryptoIndexConstituent }
CryptoIndex is the container for API endpoint CryptoIndex
func (*CryptoIndex) MarshalBinary ¶
func (e *CryptoIndex) MarshalBinary() ([]byte, error)
MarshalBinary -
func (*CryptoIndex) UnmarshalBinary ¶
func (e *CryptoIndex) UnmarshalBinary(data []byte) error
UnmarshalBinary -
type CryptoIndexConstituent ¶
type CryptoIndexMintAmount ¶
type CurrencyChange ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func NewDataStore ¶
func NewDataStoreWithOptions ¶
func NewInfluxDataStore ¶
func NewRedisDataStore ¶
func (*DB) AddAssetQuotationsToBatch ¶ added in v1.2.0
func (db *DB) AddAssetQuotationsToBatch(quotations []*AssetQuotation) error
AddAssetQuotationsToBatch is a helper function that adds a slice of quotations to an influx batch.
func (*DB) ExistInterestRate ¶
ExistInterestRate returns true if a database entry with given date stamp exists, and false otherwise. @date should be a substring of a string formatted as "yyyy-mm-dd hh:mm:ss".
func (*DB) GetAllTrades ¶
GetAllTrades returns at most @maxTrades trades from influx with timestamp > @t. Only used by replayInflux option.
func (*DB) GetAssetPriceUSD ¶ added in v1.2.0
GetAssetPriceUSD returns the latest USD price of @asset before @timestamp.
func (*DB) GetAssetPriceUSDCache ¶ added in v1.2.0
GetAssetPriceUSDCache returns the latest price of @asset from the cache.
func (*DB) GetAssetPriceUSDLatest ¶ added in v1.2.0
GetAssetPriceUSDLatest returns the latest price of @asset.
func (*DB) GetAssetQuotation ¶ added in v1.2.0
GetAssetQuotation returns the latest full quotation for @asset before @timestamp.
func (*DB) GetAssetQuotationCache ¶ added in v1.2.0
func (db *DB) GetAssetQuotationCache(asset dia.Asset) (*AssetQuotation, error)
GetAssetQuotationCache returns the latest quotation for @asset from the redis cache.
func (*DB) GetAssetQuotationLatest ¶ added in v1.2.0
func (db *DB) GetAssetQuotationLatest(asset dia.Asset) (*AssetQuotation, error)
GetAssetQuotation returns the latest full quotation for @asset.
func (*DB) GetAssetsMarketCap ¶ added in v1.2.0
GetAssetsMarketCap returns the actual market cap of @asset.
func (*DB) GetAvailablePairs ¶ added in v1.2.0
func (db *DB) GetAvailablePairs(exchange string) ([]dia.ExchangePair, error)
GetAvailablePairs a slice of all pairs available in the exchange in the internal redis db
func (*DB) GetBenchmarkedIndexValuesInflux ¶ added in v1.2.0
func (*DB) GetCVIInflux ¶
func (*DB) GetCommitByDate ¶
GetCommitByDate returns the latest commit from @repository of github user @user before @date.
func (*DB) GetCommitByHash ¶
func (db *DB) GetCommitByHash(user, repository, hash string) (GithubCommit, error)
GetCommitByHash returns the commit from @repository of github user @user with hash @hash.
func (*DB) GetCompoundedAvg ¶
func (db *DB) GetCompoundedAvg(symbol string, date time.Time, calDays, daysPerYear int, rounding int) (*InterestRate, error)
GetCompoundedAvg returns the compounded average of the index @symbol over rolling @calDays calendar days.
func (*DB) GetCompoundedAvgDIARange ¶
func (db *DB) GetCompoundedAvgDIARange(symbol string, dateInit, dateFinal time.Time, calDays, daysPerYear int, rounding int) (values []*InterestRate, err error)
GetCompoundedAvgDIARange returns the compounded average DIA index of @symbol over rolling @calDays calendar days.
func (*DB) GetCompoundedAvgRange ¶
func (db *DB) GetCompoundedAvgRange(symbol string, dateInit, dateFinal time.Time, calDays, daysPerYear int, rounding int) (values []*InterestRate, err error)
GetCompoundedAvgRange returns the compounded average of the index @symbol over rolling @calDays calendar days.
func (*DB) GetCompoundedIndex ¶
func (db *DB) GetCompoundedIndex(symbol string, date time.Time, daysPerYear int, rounding int) (*InterestRate, error)
GetCompoundedIndex returns the compounded index over the maximal period of existence of @symbol
func (*DB) GetCompoundedIndexRange ¶
func (db *DB) GetCompoundedIndexRange(symbol string, dateInit, dateFinal time.Time, daysPerYear int, rounding int) (values []*InterestRate, err error)
GetCompoundedIndexRange returns the compounded average of the index @symbol over rolling @calDays calendar days.
func (*DB) GetCompoundedRate ¶
func (db *DB) GetCompoundedRate(symbol string, dateInit, date time.Time, daysPerYear int, rounding int) (*InterestRate, error)
GetCompoundedRate returns the compounded rate for the period @dateInit to @date. It computes the rate for all days for which an entry is present in the database. All other days are assumed to be holidays (or weekends).
func (*DB) GetCryptoIndex ¶
func (*DB) GetCryptoIndexConstituentPrice ¶
func (*DB) GetCryptoIndexConstituents ¶
func (db *DB) GetCryptoIndexConstituents(starttime time.Time, endtime time.Time, asset dia.Asset, indexSymbol string) ([]CryptoIndexConstituent, error)
GetCryptoIndexConstituents returns the constituent corresponding to @asset along with underlying information. Necessary and sufficient information is asset's address and blockchain.
func (*DB) GetCurrencyChange ¶
func (*DB) GetDefiProtocol ¶
func (db *DB) GetDefiProtocol(name string) (dia.DefiProtocol, error)
GetDefiProtocol returns the die protocol struct by name
func (*DB) GetDefiProtocols ¶
func (db *DB) GetDefiProtocols() ([]dia.DefiProtocol, error)
GetDefiProtocols returns a slice of all available DeFi protocols
func (*DB) GetDefiRateInflux ¶
func (*DB) GetDefiStateInflux ¶
func (*DB) GetExchanges ¶
GetExchanges returns all available trading places. Comment: Think about getting the exchanges from redis.
func (*DB) GetFarmingPoolData ¶
func (db *DB) GetFarmingPoolData(starttime, endtime time.Time, protocol, poolID string) ([]FarmingPool, error)
GetFarmingPoolData returns all farming pool states in the given time range time, balance, blocknumber, inputAssets, outputAssets, poolID, protocol, rate
func (*DB) GetFarmingPools ¶
func (db *DB) GetFarmingPools() ([]FarmingPoolType, error)
GetFarmingPools returns all farming pool states in the given time range time, balance, blocknumber, inputAssets, outputAssets, poolID, protocol, rate
func (*DB) GetFilterPoints ¶
func (db *DB) GetFilterPoints(filter string, exchange string, symbol string, scale string, starttime time.Time, endtime time.Time) (*Points, error)
GetFilterPoints returns filter points from either a specific exchange or all exchanges. symbol is mapped to the underlying asset with biggest market cap.
func (*DB) GetFirstDate ¶
GetFirstDate returns the oldest date written in the database for the rate with symbol @symbol
func (*DB) GetFirstTradeDate ¶ added in v1.2.0
func (*DB) GetForeignPriceYesterday ¶
GetForeignPriceYesterday returns the average price of @symbol on @source from yesterday
func (*DB) GetForeignQuotationInflux ¶
func (db *DB) GetForeignQuotationInflux(symbol, source string, timestamp time.Time) (ForeignQuotation, error)
GetForeignQuotationInflux returns the last quotation of @symbol before @timestamp
func (*DB) GetForeignSymbolsInflux ¶
func (db *DB) GetForeignSymbolsInflux(source string) (symbols []SymbolShort, err error)
GetForeignSymbolsInflux returns a list with all symbols available for quotation from @source, along with their ITIN.
func (*DB) GetIndexPrice ¶ added in v1.2.0
GetIndexPrice returns the price of index represented by @asset. If @asset only consists of a symbol, a different method for price retrieval has to be implemented.
func (*DB) GetInterestRate ¶
func (db *DB) GetInterestRate(symbol, date string) (*InterestRate, error)
GetInterestRate returns the interest rate value for the last time stamp before @date. If @date is an empty string it returns the rate at the latest time stamp. @symbol is the shorthand symbol for the requested interest rate. @date is a string in the format yyyy-mm-dd.
func (*DB) GetInterestRateRange ¶
func (db *DB) GetInterestRateRange(symbol, dateInit, dateFinal string) ([]*InterestRate, error)
GetInterestRateRange returns the interest rate values for a range of timestamps. @symbol is the shorthand symbol for the requested interest rate. @dateInit and @dateFinal are strings in the format yyyy-mm-dd.
func (*DB) GetLastPriceBefore ¶
func (*DB) GetLastTradeTimeForExchange ¶
func (*DB) GetLastTrades ¶
GetLastTrades returns the last @maxTrades of @asset on @exchange. If exchange is empty string it returns trades from all exchanges.
func (*DB) GetLatestCommit ¶
func (db *DB) GetLatestCommit(user, repository string) (GithubCommit, error)
GetLatestCommit returns the latest commit from influx. Returns empty struct and nil if no commits are in the database.
func (*DB) GetOldTradesFromInflux ¶ added in v1.2.0
func (db *DB) GetOldTradesFromInflux(table string, exchange string, verified bool, timeInit, timeFinal time.Time) ([]dia.Trade, error)
GetOldTradesFromInflux returns all recorded trades from @table done on @exchange between @timeInit and @timeFinal where the time interval is closed on the left and open on the right side. If @exchange is empty, trades across all exchanges are returned. If @verified is true, address and blockchain are also parsed for both assets.
func (*DB) GetOptionMeta ¶
func (db *DB) GetOptionMeta(baseCurrency string) ([]dia.OptionMeta, error)
func (*DB) GetOptionOrderbookDataInflux ¶
func (db *DB) GetOptionOrderbookDataInflux(t dia.OptionMeta) (dia.OptionOrderbookDatum, error)
func (*DB) GetPaxgQuotationGrams ¶
func (*DB) GetPaxgQuotationOunces ¶
func (*DB) GetPrice14d ¶
func (*DB) GetPrice30d ¶
func (*DB) GetPriceYesterday ¶
func (*DB) GetRates ¶
GetRates returns a (unique) slice of all rates that have been written into the database
func (*DB) GetRatesMeta ¶
func (db *DB) GetRatesMeta() (RatesMeta []InterestRateMeta, err error)
GetRatesMeta returns a list of all available rate symbols along with their first timestamp in the database.
func (*DB) GetSortedAssetQuotations ¶ added in v1.2.0
func (db *DB) GetSortedAssetQuotations(assets []dia.Asset) ([]AssetQuotation, error)
GetSortedQuotations returns quotations for all assets in @assets, sorted by 24h volume in descending order.
func (*DB) GetStockQuotation ¶ added in v1.2.0
GetStockQuotationInflux returns the last quotation of @symbol before @timestamp.
func (*DB) GetSupplyInflux ¶
func (db *DB) GetSupplyInflux(asset dia.Asset, starttime time.Time, endtime time.Time) ([]dia.Supply, error)
GetSupplyInflux returns supply and circulating supply of @asset. Needs asset.Address and asset.Blockchain. If no time range is given it returns the latest supply.
func (*DB) GetTopAssetByMcap ¶ added in v1.2.0
GetTopAssetByMcap returns the asset with highest market cap among all assets with symbol @symbol.
func (*DB) GetTopAssetByVolume ¶ added in v1.2.0
GetTopAssetByVolume returns the asset with highest volume among all assets with symbol @symbol. This method allows us to use all API endpoints called on a symbol.
func (*DB) GetTradeInflux ¶
func (db *DB) GetTradeInflux(asset dia.Asset, exchange string, timestamp time.Time) (*dia.Trade, error)
GetTradeInflux returns the latest trade of @asset on @exchange before @timestamp.
func (*DB) GetTradePrice14d ¶
func (*DB) GetTradePrice1h ¶
func (*DB) GetTradePrice24h ¶
func (*DB) GetTradePrice30d ¶
func (*DB) GetTradePrice7d ¶
func (*DB) GetTradePriceBefore ¶
func (*DB) GetTradesByExchanges ¶ added in v1.2.0
func (*DB) GetVolumeInflux ¶
func (db *DB) GetVolumeInflux(asset dia.Asset, starttime time.Time, endtime time.Time) (float64, error)
GetVolumeInflux returns the trade volume of @asset in the time range @starttime - @endtime. It uses the VOL filter from the filter services.
func (*DB) RemoveExpiredOptionMeta ¶
func (*DB) SaveCVIInflux ¶
func (*DB) SaveETHCVIInflux ¶
func (*DB) SaveFilterInflux ¶
func (db *DB) SaveFilterInflux(filter string, asset dia.Asset, exchange string, value float64, t time.Time) error
SaveFilterInflux stores a filter point in influx.
func (*DB) SaveForeignQuotationInflux ¶
func (db *DB) SaveForeignQuotationInflux(fq ForeignQuotation) error
SaveForeignQuotationInflux stores a quotation which is not from DIA to an influx batch
func (*DB) SaveIndexEngineTimeInflux ¶ added in v1.2.0
func (*DB) SaveOptionOrderbookDatumInflux ¶
func (db *DB) SaveOptionOrderbookDatumInflux(t dia.OptionOrderbookDatum) error
func (*DB) SaveTradeInflux ¶
SaveTradeInflux stores a trade in influx. Flushed when more than maxPoints in batch. Wrapper around SaveTradeInfluxToTable.
func (*DB) SaveTradeInfluxToTable ¶ added in v1.2.0
SaveTradeInfluxToTable stores a trade in influx into @table. Flushed when more than maxPoints in batch.
func (*DB) SetAssetPriceUSD ¶ added in v1.2.0
SetAssetPriceUSD stores the price of @asset in influx and the caching layer. The latter only holds the most recent price point.
func (*DB) SetAssetQuotation ¶ added in v1.2.0
func (db *DB) SetAssetQuotation(quotation *AssetQuotation) error
SetAssetQuotation stores the full quotation of @asset into influx and cache.
func (*DB) SetAssetQuotationCache ¶ added in v1.2.0
func (db *DB) SetAssetQuotationCache(quotation *AssetQuotation) (bool, error)
SetAssetQuotationCache stores @quotation in redis cache
func (*DB) SetAvailablePairs ¶ added in v1.2.0
func (db *DB) SetAvailablePairs(exchange string, pairs []dia.ExchangePair) error
SetAvailablePairs stores @pairs in redis TO DO: Setter and getter should act on RelDB
func (*DB) SetBatchFiatPriceInflux ¶ added in v1.2.0
func (db *DB) SetBatchFiatPriceInflux(fiatQuotations []*FiatQuotation) error
func (*DB) SetCommit ¶
func (db *DB) SetCommit(commit GithubCommit) error
SetCommit stores a github commit in influx
func (*DB) SetCryptoIndex ¶
func (db *DB) SetCryptoIndex(index *CryptoIndex) error
func (*DB) SetCryptoIndexConstituent ¶
func (db *DB) SetCryptoIndexConstituent(constituent *CryptoIndexConstituent, index dia.Asset) error
func (*DB) SetCurrencyChange ¶
func (*DB) SetDefiProtocol ¶
func (db *DB) SetDefiProtocol(protocol dia.DefiProtocol) error
SetDefiProtocol writes @protocol into redis
func (*DB) SetDefiStateInflux ¶
func (db *DB) SetDefiStateInflux(state *dia.DefiProtocolState) error
func (*DB) SetFarmingPool ¶
func (db *DB) SetFarmingPool(pool *FarmingPool) error
func (*DB) SetFilter ¶
func (db *DB) SetFilter(filter string, asset dia.Asset, exchange string, value float64, t time.Time) error
SetFilter stores a filter point
func (*DB) SetInfluxClient ¶ added in v1.2.0
SetInfluxClient resets influx's client url to @url.
func (*DB) SetInterestRate ¶
func (db *DB) SetInterestRate(ir *InterestRate) error
SetInterestRate writes the interest rate struct ir into the Redis database and writes rate type into a set of all available rates (if not done yet).
func (*DB) SetLastTradeTimeForExchange ¶
func (*DB) SetOptionMeta ¶
func (db *DB) SetOptionMeta(optionMeta *dia.OptionMeta) error
func (*DB) SetQuotation ¶
func (*DB) SetQuotationEUR ¶
func (*DB) SetSingleFiatPriceRedis ¶ added in v1.2.0
func (db *DB) SetSingleFiatPriceRedis(fiatQuotation *FiatQuotation) error
func (*DB) SetStockQuotation ¶ added in v1.2.0
func (db *DB) SetStockQuotation(sq StockQuotation) error
SetStockQuotationInflux stores a stock quotation to an influx batch.
func (*DB) Sum24HoursExchange ¶
Sum24HoursExchange returns 24h trade volumes summed up for all assets on @exchange, using VOL120 filtered data from influx. TO DO: Rewrite for assets
func (*DB) Sum24HoursInflux ¶
Sum24HoursInflux returns the 24h volume of @asset on @exchange using the filter @filter.
func (*DB) WriteBatchInflux ¶
type Datastore ¶
type Datastore interface { SetInfluxClient(url string) GetVolume(asset dia.Asset) (*float64, error) // Deprecating SetPriceUSD(symbol string, price float64) error SetPriceEUR(symbol string, price float64) error GetPriceUSD(symbol string) (float64, error) GetQuotation(symbol string) (*Quotation, error) SetQuotation(quotation *Quotation) error SetQuotationEUR(quotation *Quotation) error SetBatchFiatPriceInflux(fqs []*FiatQuotation) error SetSingleFiatPriceRedis(fiatQuotation *FiatQuotation) error GetLatestSupply(string) (*dia.Supply, error) GetSupply(string, time.Time, time.Time) ([]dia.Supply, error) SetSupply(supply *dia.Supply) error GetSupplyInflux(dia.Asset, time.Time, time.Time) ([]dia.Supply, error) // Deprecating: GetPairs(exchange string) ([]dia.ExchangePair, error) GetSymbols(exchange string) ([]string, error) // Deprecating: GetExchangesForSymbol(symbol string) ([]string, error) // Deprecating: GetSymbolExchangeDetails(symbol string, exchange string) (*SymbolExchangeDetails, error) GetLastTradeTimeForExchange(asset dia.Asset, exchange string) (*time.Time, error) SetLastTradeTimeForExchange(asset dia.Asset, exchange string, t time.Time) error GetFirstTradeDate(table string) (time.Time, error) SaveTradeInflux(t *dia.Trade) error SaveTradeInfluxToTable(t *dia.Trade, table string) error GetTradeInflux(dia.Asset, string, time.Time) (*dia.Trade, error) SaveFilterInflux(filter string, asset dia.Asset, exchange string, value float64, t time.Time) error GetLastTrades(asset dia.Asset, exchange string, maxTrades int) ([]dia.Trade, error) GetAllTrades(t time.Time, maxTrades int) ([]dia.Trade, error) GetTradesByExchanges(symbol dia.Asset, exchange []string, startTime, endTime time.Time, maxTrades int) ([]dia.Trade, error) GetOldTradesFromInflux(table string, exchange string, verified bool, timeInit, timeFinal time.Time) ([]dia.Trade, error) Flush() error GetFilterPoints(filter string, exchange string, symbol string, scale string, starttime time.Time, endtime time.Time) (*Points, error) SetFilter(filterName string, asset dia.Asset, exchange string, value float64, t time.Time) error GetLastPriceBefore(asset dia.Asset, filter string, exchange string, timestamp time.Time) (Price, error) SetAvailablePairs(exchange string, pairs []dia.ExchangePair) error GetAvailablePairs(exchange string) ([]dia.ExchangePair, error) SetCurrencyChange(cc *Change) error GetCurrencyChange() (*Change, error) GetExchanges() []string SetOptionMeta(optionMeta *dia.OptionMeta) error GetOptionMeta(baseCurrency string) ([]dia.OptionMeta, error) SaveCVIInflux(float64, time.Time) error GetCVIInflux(time.Time, time.Time, string) ([]dia.CviDataPoint, error) GetVolumeInflux(dia.Asset, time.Time, time.Time) (float64, error) // Get24Volume(symbol string, exchange string) (float64, error) // Get24VolumeExchange(exchange string) (float64, error) Sum24HoursInflux(asset dia.Asset, exchange string, filter string) (*float64, error) Sum24HoursExchange(exchange string) (float64, error) // New Asset pricing methods: 23/02/2021 SetAssetPriceUSD(asset dia.Asset, price float64, timestamp time.Time) error GetAssetPriceUSD(asset dia.Asset, timestamp time.Time) (float64, error) GetAssetPriceUSDLatest(asset dia.Asset) (price float64, err error) SetAssetQuotation(quotation *AssetQuotation) error GetAssetQuotation(asset dia.Asset, timestamp time.Time) (*AssetQuotation, error) GetAssetQuotationLatest(asset dia.Asset) (*AssetQuotation, error) GetSortedAssetQuotations(assets []dia.Asset) ([]AssetQuotation, error) AddAssetQuotationsToBatch(quotations []*AssetQuotation) error SetAssetQuotationCache(quotation *AssetQuotation) (bool, error) GetAssetQuotationCache(asset dia.Asset) (*AssetQuotation, error) GetAssetPriceUSDCache(asset dia.Asset) (price float64, err error) GetTopAssetByMcap(symbol string, relDB *RelDB) (dia.Asset, error) GetTopAssetByVolume(symbol string, relDB *RelDB) (topAsset dia.Asset, err error) // Market Measures GetAssetsMarketCap(asset dia.Asset) (float64, error) // Interest rates' methods SetInterestRate(ir *InterestRate) error GetInterestRate(symbol, date string) (*InterestRate, error) GetInterestRateRange(symbol, dateInit, dateFinal string) ([]*InterestRate, error) GetRatesMeta() (RatesMeta []InterestRateMeta, err error) GetCompoundedIndex(symbol string, date time.Time, daysPerYear int, rounding int) (*InterestRate, error) GetCompoundedIndexRange(symbol string, dateInit, dateFinal time.Time, daysPerYear int, rounding int) ([]*InterestRate, error) GetCompoundedAvg(symbol string, date time.Time, calDays, daysPerYear int, rounding int) (*InterestRate, error) GetCompoundedAvgRange(symbol string, dateInit, dateFinal time.Time, calDays, daysPerYear int, rounding int) ([]*InterestRate, error) GetCompoundedAvgDIARange(symbol string, dateInit, dateFinal time.Time, calDays, daysPerYear int, rounding int) ([]*InterestRate, error) // Pool methods SetFarmingPool(pr *FarmingPool) error GetFarmingPoolData(starttime, endtime time.Time, protocol, poolID string) ([]FarmingPool, error) GetFarmingPools() ([]FarmingPoolType, error) // Itin methods SetItinData(token dia.ItinToken) error GetItinBySymbol(symbol string) (dia.ItinToken, error) // Defi rates SetDefiProtocol(dia.DefiProtocol) error GetDefiProtocol(string) (dia.DefiProtocol, error) GetDefiProtocols() ([]dia.DefiProtocol, error) GetDefiRateInflux(time.Time, time.Time, string, string) ([]dia.DefiRate, error) SetDefiRateInflux(rate *dia.DefiRate) error GetDefiStateInflux(time.Time, time.Time, string) ([]dia.DefiProtocolState, error) SetDefiStateInflux(state *dia.DefiProtocolState) error // Foreign quotation methods SaveForeignQuotationInflux(fq ForeignQuotation) error GetForeignQuotationInflux(symbol, source string, timestamp time.Time) (ForeignQuotation, error) GetForeignPriceYesterday(symbol, source string) (float64, error) GetForeignSymbolsInflux(source string) (symbols []SymbolShort, err error) // Gold token methods GetPaxgQuotationOunces() (*Quotation, error) GetPaxgQuotationGrams() (*Quotation, error) // Crypto Index methods GetCryptoIndex(time.Time, time.Time, string) ([]CryptoIndex, error) SetCryptoIndex(index *CryptoIndex) error GetCryptoIndexConstituents(time.Time, time.Time, dia.Asset, string) ([]CryptoIndexConstituent, error) SetCryptoIndexConstituent(*CryptoIndexConstituent, dia.Asset) error GetCryptoIndexConstituentPrice(symbol string, date time.Time) (float64, error) GetIndexPrice(asset dia.Asset, time time.Time) (*dia.Trade, error) SaveIndexEngineTimeInflux(map[string]string, map[string]interface{}, time.Time) error GetBenchmarkedIndexValuesInflux(string, time.Time, time.Time) (BenchmarkedIndex, error) // Github methods SetCommit(commit GithubCommit) error GetCommitByDate(user, repository string, date time.Time) (GithubCommit, error) GetCommitByHash(user, repository, hash string) (GithubCommit, error) GetLatestCommit(user, repository string) (GithubCommit, error) // Stock methods SetStockQuotation(sq StockQuotation) error GetStockQuotation(symbol string, timestamp time.Time) (StockQuotation, error) }
type FarmingPool ¶
type FarmingPool struct { // Rate is the pool rate. More information: https://docs.diadata.org/documentation/methodology/digital-assets/return-rates-in-crypto-farming Rate float64 // Balance is the total supply of pool token Balance float64 ProtocolName string BlockNumber int64 PoolID string // hold pool id respective to protocol TimeStamp time.Time // OutputAsset is the list of tokens that you get back for staking. OutputAsset []string InputAsset []string // some pools have more than 2 input assets }
func (*FarmingPool) MarshalBinary ¶
func (fp *FarmingPool) MarshalBinary() ([]byte, error)
func (*FarmingPool) UnmarshalBinary ¶
func (fp *FarmingPool) UnmarshalBinary(data []byte) error
type FarmingPoolType ¶
type FiatQuotation ¶ added in v1.2.0
type FiatQuotation struct { QuoteCurrency string BaseCurrency string Price float64 Source string Time time.Time }
func (*FiatQuotation) MarshalBinary ¶ added in v1.2.0
func (fq *FiatQuotation) MarshalBinary() ([]byte, error)
MarshalBinary for fiat quotations
func (*FiatQuotation) UnmarshalBinary ¶ added in v1.2.0
func (fq *FiatQuotation) UnmarshalBinary(data []byte) error
UnmarshalBinary for fiat quotations
type ForeignQuotation ¶
type ForeignQuotation struct { Symbol string Name string Price float64 PriceYesterday float64 VolumeYesterdayUSD float64 Source string Time time.Time ITIN string }
func (*ForeignQuotation) MarshalBinary ¶
func (fq *ForeignQuotation) MarshalBinary() ([]byte, error)
MarshalBinary -
func (*ForeignQuotation) UnmarshalBinary ¶
func (fq *ForeignQuotation) UnmarshalBinary(data []byte) error
UnmarshalBinary -
type GithubCommit ¶
type InterestRate ¶
type InterestRate struct { Symbol string Value float64 PublicationTime time.Time EffectiveDate time.Time Source string }
func (*InterestRate) MarshalBinary ¶
func (e *InterestRate) MarshalBinary() ([]byte, error)
MarshalBinary for interest rates
func (*InterestRate) UnmarshalBinary ¶
func (e *InterestRate) UnmarshalBinary(data []byte) error
UnmarshalBinary for interest rates
type InterestRateMeta ¶
type Pairs ¶
type Pairs struct {
Pairs []dia.ExchangePair
}
type Points ¶
type Points struct {
DataPoints []clientInfluxdb.Result
}
func (*Points) UnmarshalBinary ¶
type Quotation ¶
type Quotation struct { Symbol string Name string Price float64 PriceYesterday *float64 VolumeYesterdayUSD *float64 Source string Time time.Time ITIN string }
Quotation is deprecating. Going to be substituted by AssetQuotation
func (*Quotation) MarshalBinary ¶
MarshalBinary for quotations
func (*Quotation) UnmarshalBinary ¶
UnmarshalBinary for quotations
type RelDB ¶
type RelDB struct { URI string // contains filtered or unexported fields }
RelDB is a relative database with redis caching layer.
func NewCachingLayer ¶
NewCachingLayer returns a datastore with redis caching layer and without postgres client.
func NewPostgresDataStore ¶
NewPostgresDataStore returns a datastore with postgres client and without redis caching layer.
func NewRelDataStore ¶
NewRelDataStore returns a datastore with postgres client and redis cache.
func NewRelDataStoreWithOptions ¶
NewRelDataStoreWithOptions returns a postgres datastore and/or redis caching layer.
func (*RelDB) CountCache ¶ added in v1.2.0
CountCache returns the number of assets in the cache
func (*RelDB) GetActiveAsset ¶ added in v1.2.0
func (*RelDB) GetActiveAssetCount ¶ added in v1.2.0
func (*RelDB) GetAllAssets ¶ added in v1.2.0
GetAllAssets returns all assets on @blockchain from asset table.
func (*RelDB) GetAllBlockchains ¶ added in v1.2.0
GetAllBlockchains returns all blockchain names existent in the asset table.
func (*RelDB) GetAllNFTClasses ¶
GetAllNFTClasses returns all NFT classes on @blockchain.
func (*RelDB) GetAsset ¶ added in v1.2.0
GetAsset is the standard method in order to uniquely retrieve an asset from asset table.
func (*RelDB) GetAssetByID ¶ added in v1.2.0
GetAssetByID returns an asset by its uuid
func (*RelDB) GetAssetCache ¶ added in v1.2.0
GetAssetCache returns an asset by its asset_id as defined in asset table in postgres
func (*RelDB) GetAssetID ¶ added in v1.2.0
GetAssetID returns the unique identifier of @asset in postgres table asset, if the entry exists.
func (*RelDB) GetAssetVolume24H ¶ added in v1.2.0
func (*RelDB) GetAssets ¶ added in v1.2.0
GetAssets returns all assets which share the symbol ticker @symbol.
func (*RelDB) GetAssetsBySymbolName ¶ added in v1.2.0
GetAssetsBySymbolName returns a (possibly multiple) dia.Asset by its symbol and name from postgres. If @name is an empty string, it returns all assets with @symbol. If @symbol is an empty string, it returns all assets with @name.
func (*RelDB) GetBlockData ¶ added in v1.2.0
GetBlockData returns information on the block with @blocknumber on @blockchain.
func (*RelDB) GetBlockchain ¶ added in v1.2.0
func (rdb *RelDB) GetBlockchain(name string) (blockchain dia.BlockChain, err error)
func (*RelDB) GetByLimit ¶ added in v1.2.0
func (*RelDB) GetExchangePair ¶ added in v1.2.0
GetExchangePair returns the unique exchange pair given by @exchange and @foreignname from postgres. It also returns the underlying pair if existent.
func (*RelDB) GetExchangePairCache ¶ added in v1.2.0
func (rdb *RelDB) GetExchangePairCache(exchange string, foreignName string) (dia.ExchangePair, error)
GetExchangePairCache returns an exchange pair by @exchange and @foreigName
func (*RelDB) GetExchangePairSymbols ¶ added in v1.2.0
func (rdb *RelDB) GetExchangePairSymbols(exchange string) (pairs []dia.ExchangePair, err error)
GetExchangePairSymbols returns all foreign names on @exchange from exchangepair table.
func (*RelDB) GetExchangeSymbolAssetID ¶ added in v1.2.0
func (rdb *RelDB) GetExchangeSymbolAssetID(exchange string, symbol string) (assetID string, verified bool, err error)
GetExchangeSymbolAssetID returns the ID of the unique asset associated to @symbol on @exchange in case the symbol is verified. An empty string if not.
func (*RelDB) GetExchangeSymbols ¶ added in v1.2.0
GetExchangeSymbols returns all symbols traded on @exchange
func (*RelDB) GetExchangesForSymbol ¶ added in v1.2.0
func (*RelDB) GetFiatAssetBySymbol ¶ added in v1.2.0
GetFiatAssetBySymbol returns a fiat asset by its symbol. This is possible as fiat currencies are uniquely defined by their symbol.
func (*RelDB) GetKeyAsset ¶ added in v1.2.0
GetKeyAsset returns an asset's key in the redis cache of the asset table. @assetID refers to the primary key asset_id in the asset table.
func (*RelDB) GetKeys ¶
GetKeys returns a slice of strings holding the names of the keys of @table in postgres
func (*RelDB) GetLastBlockBlockscraper ¶ added in v1.2.0
GetLastBlockBlockscraper returns the last scraped block on @blockchain for block data scrapers.
func (*RelDB) GetLastBlockNFTBid ¶ added in v1.2.0
GetLastBlockNFTBid returns the last blocknumber that was scraped in @nftclass.
func (*RelDB) GetLastBlockNFTTradeScraper ¶ added in v1.2.0
func (*RelDB) GetLastBlockheightTopshot ¶ added in v1.2.0
GetLastBlockheightTopshot returns the last block number before timestamp given by @upperBound.
func (*RelDB) GetLastNFTBid ¶ added in v1.2.0
func (rdb *RelDB) GetLastNFTBid(address string, blockchain string, tokenID string, blockNumber uint64, blockPosition uint) (nftBid dia.NFTBid, err error)
GetLastNFTBid returns the last bid on the nft with @address and @tokenID. Here, 'last' refers to block number and block position smaller or equal (in the case of block number) than @blockNumber and @blockPosition resp.
func (*RelDB) GetLastNFTOffer ¶ added in v1.2.0
func (rdb *RelDB) GetLastNFTOffer(address string, blockchain string, tokenID string, blockNumber uint64, blockPosition uint) (offer dia.NFTOffer, err error)
GetLastNFTOffer returns the last offer on the nft with @address and @tokenID. Here, 'last' refers to block number and block position smaller or equal (in the case of block number) than @blockNumber and @blockPosition resp.
func (*RelDB) GetNFTCategories ¶
GetNFTCategories returns all available NFT categories.
func (*RelDB) GetNFTClass ¶
func (*RelDB) GetNFTClassByID ¶
func (*RelDB) GetNFTClassID ¶
func (*RelDB) GetNFTClasses ¶
GetNFTClassPage returns @limit NFT classes with @offset.
func (*RelDB) GetNFTPrice30Days ¶ added in v1.2.0
GetNFTPrice30Days returns the average price of all NFTs in @nftclass over the last 30 days.
func (*RelDB) GetNFTTrades ¶ added in v1.2.0
GetNFTTrades returns all trades done on @nft.
func (*RelDB) GetPage ¶ added in v1.2.0
GetPage returns assets per page number. @hasNext is true iff there is a non-empty next page.
func (*RelDB) GetPairs ¶ added in v1.2.0
func (rdb *RelDB) GetPairs(exchange string) (pairs []dia.ExchangePair, err error)
GetPairs returns all exchangepairs on @exchange. For exchange=="" it returns all exchangepairs across exchanges.
func (*RelDB) GetScraperConfig ¶ added in v1.2.0
func (*RelDB) GetScraperState ¶ added in v1.2.0
func (*RelDB) GetTopAssetByVolume ¶ added in v1.2.0
func (*RelDB) GetUnverifiedExchangeSymbols ¶ added in v1.2.0
GetUnverifiedExchangeSymbols returns all symbols from @exchange which haven't been verified yet.
func (*RelDB) IdentifyAsset ¶ added in v1.2.0
IdentifyAsset looks for all assets in postgres which match the non-null fields in @asset Comment 1: The only critical field is @Decimals, as this is initialized with 0, while an asset is allowed to have zero decimals as well (for instance sngls, trxc). Comment 2: Should we add a preprocessing step in which notation is corrected corresponding to the notation in the underlying contract on the blockchain? Comment 3: Can we improve this? How to treat cases like CoinBase emitting symbol name 'Wrapped Bitcoin' instead of the correct 'Wrapped BTC', or 'United States Dollar' instead of 'United States dollar'? On idea would be to add a table with alternative names for symbol tickers, so WBTC -> [Wrapped Bitcoin, Wrapped bitcoin, Wrapped BTC,...]
func (*RelDB) SetAssetCache ¶ added in v1.2.0
SetAssetCache stores @asset in redis, using its primary key in postgres as key. As a consequence, @asset is only cached iff it exists in postgres.
func (*RelDB) SetAssetVolume ¶
func (*RelDB) SetBlockData ¶ added in v1.2.0
SetBlockData stores @blockdata in postgres.
func (*RelDB) SetExchangePair ¶ added in v1.2.0
SetExchangePair adds @pair to exchangepair table. If cache==true, it is also cached into redis
func (*RelDB) SetExchangePairCache ¶ added in v1.2.0
func (rdb *RelDB) SetExchangePairCache(exchange string, pair dia.ExchangePair) error
SetExchangePairCache stores @pairs in redis
func (*RelDB) SetExchangeSymbol ¶ added in v1.2.0
SetExchangeSymbol writes unique data into exchangesymbol table if not yet in there.
func (*RelDB) SetNFTClass ¶
SetNFTClass stores @nftClass in postgres.
func (*RelDB) SetNFTOffer ¶ added in v1.2.0
SetNFTOffer stores @offer in postgres.
func (*RelDB) SetNFTTrade ¶
SetNFTTTrade stores @trade.
func (*RelDB) SetScraperConfig ¶ added in v1.2.0
func (*RelDB) SetScraperState ¶ added in v1.2.0
func (*RelDB) UpdateNFTClassCategory ¶
func (*RelDB) VerifyExchangeSymbol ¶ added in v1.2.0
func (rdb *RelDB) VerifyExchangeSymbol(exchange string, symbol string, assetID string) (bool, error)
VerifyExchangeSymbol verifies @symbol on @exchange and maps it uniquely to @assetID in asset table. It returns true if symbol,exchange is present and succesfully updated.
type RelDatastore ¶
type RelDatastore interface { // --- Assets methods --- // --------- Persistent --------- SetAsset(asset dia.Asset) error GetAsset(address, blockchain string) (dia.Asset, error) GetAssetByID(ID string) (dia.Asset, error) GetAssetsBySymbolName(symbol, name string) ([]dia.Asset, error) GetAllAssets(blockchain string) ([]dia.Asset, error) GetFiatAssetBySymbol(symbol string) (asset dia.Asset, err error) IdentifyAsset(asset dia.Asset) ([]dia.Asset, error) GetAssetID(asset dia.Asset) (string, error) GetPage(pageNumber uint32) ([]dia.Asset, bool, error) Count() (uint32, error) GetAssetVolume24H(asset dia.Asset) (float64, error) // --------------- asset methods for exchanges --------------- SetExchangePair(exchange string, pair dia.ExchangePair, cache bool) error GetExchangePair(exchange string, foreignname string) (exchangepair dia.ExchangePair, err error) GetExchangePairSymbols(exchange string) ([]dia.ExchangePair, error) GetPairs(exchange string) ([]dia.ExchangePair, error) SetExchangeSymbol(exchange string, symbol string) error GetExchangeSymbols(exchange string) ([]string, error) GetUnverifiedExchangeSymbols(exchange string) ([]string, error) VerifyExchangeSymbol(exchange string, symbol string, assetID string) (bool, error) GetExchangeSymbolAssetID(exchange string, symbol string) (string, bool, error) // ----------------- blockchain methods ------------------- GetBlockchain(name string) (dia.BlockChain, error) GetAllBlockchains() ([]string, error) // ------ Caching ------ SetAssetCache(asset dia.Asset) error GetAssetCache(assetID string) (dia.Asset, error) SetExchangePairCache(exchange string, pair dia.ExchangePair) error GetExchangePairCache(exchange string, foreignName string) (dia.ExchangePair, error) CountCache() (uint32, error) // ---------------- NFT methods ------------------- // NFT class methods SetNFTClass(nftClass dia.NFTClass) error GetAllNFTClasses(blockchain string) (nftClasses []dia.NFTClass, err error) GetNFTClasses(limit, offset uint64) (nftClasses []dia.NFTClass, err error) GetNFTClass(address string, blockchain string) (nftclass dia.NFTClass, err error) GetNFTClassID(address string, blockchain string) (ID string, err error) GetNFTClassByID(id string) (nftclass dia.NFTClass, err error) UpdateNFTClassCategory(nftclassID string, category string) (bool, error) GetNFTCategories() ([]string, error) // NFT methods SetNFT(nft dia.NFT) error GetNFT(address string, blockchain string, tokenID string) (dia.NFT, error) GetNFTID(address string, blockchain string, tokenID string) (string, error) // NFT trading and bidding methods SetNFTTrade(trade dia.NFTTrade) error GetNFTTrades(nft dia.NFT) ([]dia.NFTTrade, error) GetNFTPrice30Days(nftclass dia.NFTClass) (float64, error) GetLastBlockheightTopshot(upperBound time.Time) (uint64, error) GetLastBlockNFTTradeScraper(nftclass dia.NFTClass) (uint64, error) SetNFTBid(bid dia.NFTBid) error GetLastNFTBid(address string, blockchain string, tokenID string, blockNumber uint64, blockPosition uint) (dia.NFTBid, error) GetLastBlockNFTBid(nftclass dia.NFTClass) (uint64, error) SetNFTOffer(offer dia.NFTOffer) error GetLastNFTOffer(address string, blockchain string, tokenID string, blockNumber uint64, blockPosition uint) (offer dia.NFTOffer, err error) // General methods GetKeys(table string) ([]string, error) // Scraper config and state GetScraperState(ctx context.Context, scraperName string, state ScraperState) error SetScraperState(ctx context.Context, scraperName string, state ScraperState) error GetScraperConfig(ctx context.Context, scraperName string, config ScraperConfig) error SetScraperConfig(ctx context.Context, scraperName string, config ScraperConfig) error // Blockchain data SetBlockData(dia.BlockData) error GetBlockData(blockchain string, blocknumber int64) (dia.BlockData, error) GetLastBlockBlockscraper(blockchain string) (int64, error) }
RelDatastore is a (persistent) relational database with an additional redis caching layer
type ScraperConfig ¶ added in v1.2.0
type ScraperConfig interface{}
ScraperConfig is a JSON compatible struct to keep the configuration of a scraper
type ScraperState ¶ added in v1.2.0
type ScraperState interface{}
ScraperState is a JSON compatible struct to keep the state of a scraper
type StockQuotation ¶ added in v1.2.0
type SymbolDetails ¶
type SymbolDetails struct { Change *Change Coin Coin Rank int Exchanges []SymbolExchangeDetails Gfx1 *Points }
SymbolDetails is used for API return values
func (*SymbolDetails) MarshalBinary ¶
func (e *SymbolDetails) MarshalBinary() ([]byte, error)
MarshalBinary -
func (*SymbolDetails) UnmarshalBinary ¶
func (e *SymbolDetails) UnmarshalBinary(data []byte) error
UnmarshalBinary -
type SymbolExchangeDetails ¶
type SymbolShort ¶
SymbolShort is used in ForeignQuotation. TO DO: Switch from ITIN to Address/Identifier
Source Files ¶
- ForeignQuotation.go
- assets.go
- benchmarkedIndex.go
- blockscrapers.go
- currencyChange.go
- db.go
- defirates.go
- exchanges.go
- farmingpools.go
- fiatQuotation.go
- filters.go
- foreignTypes.go
- github.go
- index.go
- init.go
- itin.go
- nfts.go
- options.go
- pairs.go
- prices.go
- quotation.go
- rates.go
- relDB.go
- scrapers.go
- stockQuotation.go
- supplies.go
- symbols.go
- trades.go
- types.go
- volumes.go