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 Author
- type Change
- type Coin
- type CoinSymbolAndName
- type Coins
- type CryptoIndex
- type CryptoIndexConstituent
- type CryptoIndexMintAmount
- type CurrencyChange
- type DB
- func (db *DB) ExistInterestRate(symbol, date string) bool
- func (db *DB) Flush() error
- func (db *DB) GetAllSymbols() []string
- func (db *DB) GetAllTrades(t time.Time, maxTrades int) ([]dia.Trade, error)
- func (db *DB) GetAvailablePairsForExchange(exchange string) ([]dia.Pair, error)
- func (db *DB) GetCVIInflux(starttime time.Time, endtime time.Time, symbol string) ([]dia.CviDataPoint, error)
- func (db *DB) GetChartPoints7Days(symbol string) (r []Point, err error)
- func (db *DB) GetCoins() (*Coins, 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) GetConfigTogglePairDiscovery() (bool, 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, symbol string, indexSymbol string) ([]CryptoIndexConstituent, error)
- func (db *DB) GetCryptoIndexMintAmounts(symbol string) ([]CryptoIndexMintAmount, 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) GetExchangesForSymbol(symbol string) ([]string, error)
- 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) 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) 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(symbol string, filter string, exchange string, timestamp time.Time) (Price, error)
- func (db *DB) GetLastTradeTimeForExchange(symbol string, exchange string) (*time.Time, error)
- func (db *DB) GetLastTrades(symbol string, exchange string, maxTrades int) ([]dia.Trade, error)
- func (db *DB) GetLastTradesAllExchanges(symbol 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) GetOptionMeta(baseCurrency string) ([]dia.OptionMeta, error)
- func (db *DB) GetOptionOrderbookDataInflux(t dia.OptionMeta) (dia.OptionOrderbookDatum, error)
- func (db *DB) GetPairs(exchange string) ([]dia.Pair, error)
- func (db *DB) GetPaxgQuotationGrams() (*Quotation, error)
- func (db *DB) GetPaxgQuotationOunces() (*Quotation, error)
- func (db *DB) GetPrice(symbol string, exchange string) (float64, error)
- func (db *DB) GetPrice14d(symbol string, exchange string) (float64, error)
- func (db *DB) GetPrice1h(symbol string, exchange string) (float64, error)
- func (db *DB) GetPrice30d(symbol string, exchange string) (float64, error)
- func (db *DB) GetPrice7d(symbol string, exchange string) (float64, error)
- func (db *DB) GetPriceUSD(symbol string) (float64, error)
- func (db *DB) GetPriceYesterday(symbol string, 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) GetSupply(symbol string, starttime, endtime time.Time) ([]dia.Supply, error)
- func (db *DB) GetSupplyInflux(symbol string, starttime time.Time, endtime time.Time) ([]dia.Supply, error)
- func (db *DB) GetSymbolDetails(symbol string) (*SymbolDetails, error)
- func (db *DB) GetSymbolExchangeDetails(symbol string, exchange string) (*SymbolExchangeDetails, error)
- func (db *DB) GetSymbols(exchange string) ([]string, error)
- func (db *DB) GetSymbolsByExchange(e string) []string
- func (db *DB) GetTradeInflux(symbol string, exchange string, timestamp time.Time) (*dia.Trade, error)
- func (db *DB) GetTradePrice14d(symbol string, exchange string) (*dia.Trade, error)
- func (db *DB) GetTradePrice1h(symbol string, exchange string) (*dia.Trade, error)
- func (db *DB) GetTradePrice24h(symbol string, exchange string) (*dia.Trade, error)
- func (db *DB) GetTradePrice30d(symbol string, exchange string) (*dia.Trade, error)
- func (db *DB) GetTradePrice7d(symbol string, exchange string) (*dia.Trade, error)
- func (db *DB) GetTradePriceBefore(symbol string, exchange string, timestamp time.Time) (*dia.Trade, error)
- func (db *DB) GetVolume(symbol string) (*float64, error)
- func (db *DB) GetVolumeExchange(symbol string, exchange string) (*float64, error)
- func (db *DB) GetVolumeInflux(symbol string, 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, symbol string, exchange string, value float64, t time.Time) error
- func (db *DB) SaveForeignQuotationInflux(fq ForeignQuotation) 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) SetAvailablePairsForExchange(exchange string, pairs []dia.Pair) error
- func (db *DB) SetCommit(commit *GithubCommit) error
- func (db *DB) SetCryptoIndex(index *CryptoIndex) error
- func (db *DB) SetCryptoIndexConstituent(constituent *CryptoIndexConstituent, indexSymbol string) 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, symbol string, exchange string, volume float64, t time.Time) error
- func (db *DB) SetInterestRate(ir *InterestRate) error
- func (db *DB) SetItinData(token dia.ItinToken) error
- func (db *DB) SetLastTradeTimeForExchange(symbol string, 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) SetPriceZSET(symbol string, exchange string, price float64, t time.Time) error
- func (db *DB) SetQuotation(quotation *Quotation) error
- func (db *DB) SetQuotationEUR(quotation *Quotation) error
- func (db *DB) SetSupply(supply *dia.Supply) error
- func (db *DB) SetVolume(symbol string, exchange string, volume float64, t time.Time) error
- func (db *DB) Sum24HoursExchange(exchange string) (float64, error)
- func (db *DB) Sum24HoursInflux(symbol string, exchange string, filter string) (*float64, error)
- func (db *DB) SymbolsWithASupply() ([]string, error)
- func (db *DB) UpdateSymbolDetails(symbol string, rank int)
- func (db *DB) WriteBatchInflux() error
- type Datastore
- type DefiScore
- type FarmingPool
- type FarmingPoolType
- type ForeignQuotation
- type GithubCommit
- type InterestRate
- type InterestRateMeta
- type Pairs
- type Point
- type Points
- type Price
- type Quotation
- type RelDB
- func (rdb *RelDB) GetAllNFTClasses(blockchain string) (nftClasses []dia.NFTClass, err error)
- func (rdb *RelDB) GetKeys(table string) (keys []string, err error)
- func (rdb *RelDB) GetLastBlockNFTTrade(nft dia.NFT) (*big.Int, error)
- func (rdb *RelDB) GetNFT(address common.Address, blockchain string, tokenID string) (dia.NFT, error)
- func (rdb *RelDB) GetNFTCategories() (categories []string, err error)
- func (rdb *RelDB) GetNFTClass(address common.Address, blockchain string) (nftclass dia.NFTClass, err error)
- func (rdb *RelDB) GetNFTClassByID(id string) (nftclass dia.NFTClass, err error)
- func (rdb *RelDB) GetNFTClassID(address common.Address, blockchain string) (ID string, err error)
- func (rdb *RelDB) GetNFTClasses(limit, offset uint64) (nftClasses []dia.NFTClass, err error)
- func (rdb *RelDB) SetNFT(nft dia.NFT) error
- func (rdb *RelDB) SetNFTClass(nftClass dia.NFTClass) error
- func (rdb *RelDB) SetNFTTrade(trade dia.NFTTrade) error
- func (rdb *RelDB) UpdateNFTClassCategory(nftclassID string, category string) (bool, error)
- type RelDatastore
- 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 + BufferTTL)) )
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 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 { Name string 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) 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) GetAllSymbols ¶
func (*DB) GetAllTrades ¶
GetAllTrades returns at most @maxTrades trades from influx with timestamp > @t. Only used by replayInflux option.
func (*DB) GetAvailablePairsForExchange ¶
GetAvailablePairsForExchange a slice of all pairs available in the exchange in the internal redis db
func (*DB) GetCVIInflux ¶
func (*DB) GetChartPoints7Days ¶
> SELECT MEAN(value) FROM filters WHERE "symbol"='BTC' and "filter"='MA120' GROUP BY TIME(10m) ORDER by time desc limit 10;
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) GetConfigTogglePairDiscovery ¶
func (*DB) GetCryptoIndex ¶
func (*DB) GetCryptoIndexConstituentPrice ¶
func (*DB) GetCryptoIndexConstituents ¶
func (*DB) GetCryptoIndexMintAmounts ¶
func (db *DB) GetCryptoIndexMintAmounts(symbol string) ([]CryptoIndexMintAmount, error)
WIP: Returns the amounts of constituents tokens needed to mint an index token For now we hard-code amounts. TO DO: Set and Get data to and from influx/config
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) GetExchangesForSymbol ¶
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
func (*DB) GetFirstDate ¶
GetFirstDate returns the oldest date written in the database for the rate with symbol @symbol
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) 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 ¶
func (*DB) GetLastTradesAllExchanges ¶
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) 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) 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) GetSupplyInflux ¶
func (*DB) GetSymbolDetails ¶
func (db *DB) GetSymbolDetails(symbol string) (*SymbolDetails, error)
func (*DB) GetSymbolExchangeDetails ¶
func (db *DB) GetSymbolExchangeDetails(symbol string, exchange string) (*SymbolExchangeDetails, error)
func (*DB) GetSymbolsByExchange ¶
func (*DB) GetTradeInflux ¶
func (*DB) GetTradePrice14d ¶
func (*DB) GetTradePrice1h ¶
func (*DB) GetTradePrice24h ¶
func (*DB) GetTradePrice30d ¶
func (*DB) GetTradePrice7d ¶
func (*DB) GetTradePriceBefore ¶
func (*DB) GetVolumeExchange ¶
func (*DB) GetVolumeInflux ¶
func (db *DB) GetVolumeInflux(symbol string, starttime time.Time, endtime time.Time) (float64, error)
GetVolumeInflux returns the trade volume of @symbol 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) SaveForeignQuotationInflux ¶
func (db *DB) SaveForeignQuotationInflux(fq ForeignQuotation) error
SaveForeignQuotationInflux stores a quotation which is not from DIA to an influx batch
func (*DB) SaveOptionOrderbookDatumInflux ¶
func (db *DB) SaveOptionOrderbookDatumInflux(t dia.OptionOrderbookDatum) error
func (*DB) SetAvailablePairsForExchange ¶
SetAvailablePairsForExchange stores a json containing all pairs available in the exchange in the internal redis db
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, indexSymbol string) 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) 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) SetPriceZSET ¶
func (*DB) SetQuotation ¶
func (*DB) SetQuotationEUR ¶
func (*DB) Sum24HoursExchange ¶
Sum24HoursExchange returns 24h trade volumes summed up for all assets on @exchange, using VOL120 filtered data from influx.
func (*DB) Sum24HoursInflux ¶
Sum24HoursInflux returns the 24h volume of @symbol on @exchange using the filter @filter.
func (*DB) SymbolsWithASupply ¶
func (*DB) UpdateSymbolDetails ¶
func (*DB) WriteBatchInflux ¶
type Datastore ¶
type Datastore interface { SetVolume(symbol string, exchange string, volume float64, t time.Time) error GetVolume(symbol string) (*float64, error) SymbolsWithASupply() ([]string, error) 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 GetLatestSupply(string) (*dia.Supply, error) GetSupply(string, time.Time, time.Time) ([]dia.Supply, error) SetSupply(supply *dia.Supply) error SetPriceZSET(symbol string, exchange string, price float64, t time.Time) error GetChartPoints7Days(symbol string) ([]Point, error) GetPairs(exchange string) ([]dia.Pair, error) GetSymbols(exchange string) ([]string, error) GetExchangesForSymbol(symbol string) ([]string, error) GetSymbolExchangeDetails(symbol string, exchange string) (*SymbolExchangeDetails, error) GetLastTradeTimeForExchange(symbol string, exchange string) (*time.Time, error) SetLastTradeTimeForExchange(symbol string, exchange string, t time.Time) error SaveTradeInflux(t *dia.Trade) error GetTradeInflux(string, string, time.Time) (*dia.Trade, error) SaveFilterInflux(filter string, symbol string, exchange string, value float64, t time.Time) error GetLastTrades(symbol string, exchange string, maxTrades int) ([]dia.Trade, error) GetLastTradesAllExchanges(string, int) ([]dia.Trade, error) GetAllTrades(t time.Time, maxTrades int) ([]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, symbol string, exchange string, value float64, t time.Time) error GetLastPriceBefore(symbol string, filter string, exchange string, timestamp time.Time) (Price, error) SetAvailablePairsForExchange(exchange string, pairs []dia.Pair) error GetAvailablePairsForExchange(exchange string) ([]dia.Pair, error) SetCurrencyChange(cc *Change) error GetCurrencyChange() (*Change, error) GetAllSymbols() []string GetSymbolsByExchange(string) []string GetCoins() (*Coins, error) GetSymbolDetails(symbol string) (*SymbolDetails, error) UpdateSymbolDetails(symbol string, rank int) GetConfigTogglePairDiscovery() (bool, 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) GetSupplyInflux(string, time.Time, time.Time) ([]dia.Supply, error) GetVolumeInflux(string, time.Time, time.Time) (float64, error) // Get24Volume(symbol string, exchange string) (float64, error) // Get24VolumeExchange(exchange string) (float64, error) Sum24HoursExchange(exchange string) (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, string, string) ([]CryptoIndexConstituent, error) SetCryptoIndexConstituent(*CryptoIndexConstituent, string) error GetCryptoIndexConstituentPrice(symbol string, date time.Time) (float64, error) GetCryptoIndexMintAmounts(symbol string) ([]CryptoIndexMintAmount, 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) }
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 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 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 }
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) GetAllNFTClasses ¶
GetAllNFTClasses returns all NFT classes on @blockchain.
func (*RelDB) GetKeys ¶
GetKeys returns a slice of strings holding the names of the keys of @table in postgres
func (*RelDB) GetLastBlockNFTTrade ¶
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) SetNFTClass ¶
SetNFTClass stores @nftClass in postgres.
type RelDatastore ¶
type RelDatastore interface { // NFT 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 common.Address, blockchain string) (nftclass dia.NFTClass, err error) GetNFTClassID(address common.Address, blockchain string) (ID string, err error) GetNFTClassByID(id string) (nftclass dia.NFTClass, err error) UpdateNFTClassCategory(nftclassID string, category string) (bool, error) GetNFTCategories() ([]string, error) SetNFT(nft dia.NFT) error GetNFT(address common.Address, blockchain string, tokenID string) (dia.NFT, error) SetNFTTrade(trade dia.NFTTrade) error GetLastBlockNFTTrade(nft dia.NFT) (*big.Int, error) // General methods GetKeys(table string) ([]string, error) }
RelDatastore is a (persistent) relational database with an additional redis caching layer
type SymbolDetails ¶
type SymbolDetails struct { Change *Change Coin Coin Rank int Exchanges []SymbolExchangeDetails Gfx1 *Points }
func (*SymbolDetails) MarshalBinary ¶
func (e *SymbolDetails) MarshalBinary() ([]byte, error)
MarshalBinary -
func (*SymbolDetails) UnmarshalBinary ¶
func (e *SymbolDetails) UnmarshalBinary(data []byte) error
UnmarshalBinary -