data

package
v0.0.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTestDbPath

func GetTestDbPath() string

Types

type Balance

type Balance struct {
	Timestamp     time.Time `db:"ts" json:"timestamp"`
	Wallet        string    `db:"wallet" json:"wallet"`
	Token         string    `db:"token" json:"token"`
	Address       string    `db:"address" json:"address"`
	Balance       float64   `db:"balance" json:"balance"`
	BalanceLocked float64   `db:"balance_locked" json:"balance_locked"`
	FiatValue     float64   `db:"fiat_value" json:"fiat_value"`
}

func (Balance) Add

func (b Balance) Add(x Balance) Balance

Add creates a new balance with a sum of the two

func (Balance) Id

func (b Balance) Id() string

Id is a unique key for this balance

func (Balance) PricePerToken

func (b Balance) PricePerToken() float64

PricePerToken returns price per token in fiat value

func (Balance) ShortAddr

func (b Balance) ShortAddr() string

ShortAddr returns the address

type BalanceQueryOptions

type BalanceQueryOptions struct {
	Days int
}

type Balances

type Balances struct {
	// contains filtered or unexported fields
}

func (Balances) BalanceChange

func (b Balances) BalanceChange(id string, days int) float64

BalanceChange will return change for balance with given id in pct (-1.0 to 1.0) between now and x days ago

func (Balances) ClosestSample

func (b Balances) ClosestSample(duration time.Duration) Balances

ClosestSample will find the sample closes to duration from now

func (Balances) ClosestSampleTuple

func (b Balances) ClosestSampleTuple(start time.Duration, end time.Duration) Balances

ClosestSampleTuple return 2 samples between start and end

func (Balances) Entries

func (b Balances) Entries() []Balance

func (Balances) FiatValueChange

func (b Balances) FiatValueChange(token string, days int) float64

FiatValueChange will return fiat value change in pct (-1.0 to 1.0) between now and x days ago for token

func (Balances) FilterByWallet

func (b Balances) FilterByWallet(name string) Balances

func (Balances) FilterId

func (b Balances) FilterId(id string) Balances

FilterId will return entries filtered by id

func (Balances) FilterToken

func (b Balances) FilterToken(token string) Balances

FilterToken will return entries filtered by token

func (Balances) FilterTokens added in v0.0.14

func (b Balances) FilterTokens(tokens []string) Balances

FilterTokens will return entries filtered by tokens

func (Balances) GetTimeSeries

func (b Balances) GetTimeSeries(amount int, interval time.Duration) []Balances

GetTimeSeries will return a set of balances over a given amount of intervals

func (Balances) GroupBySymbol

func (b Balances) GroupBySymbol() Balances

GroupBySymbol will group values by symbol

func (Balances) LastSample

func (b Balances) LastSample() Balances

LastSample will return the last sample

func (Balances) PricePerTokenChange

func (b Balances) PricePerTokenChange(token string, days int) float64

PricePerTokenChange will return token price value change in pct (-1.0 to 1.0) between now and x days ago for token

func (Balances) TokenBalance added in v0.0.20

func (b Balances) TokenBalance(token string) float64

func (Balances) Tokens added in v0.0.5

func (b Balances) Tokens() []string

Tokens will return all tokens in this series

func (Balances) TotalFiatValue

func (b Balances) TotalFiatValue() float64

func (Balances) TotalFiatValueChange

func (b Balances) TotalFiatValueChange(days int) float64

TotalFiatValueChange will return total fiat value change in pct (-1.0 to 1.0) between now and x days ago

func (Balances) Wallets added in v0.0.5

func (b Balances) Wallets() []string

Wallets will return all tokens in this series

type Db

type Db struct {
	// contains filtered or unexported fields
}

func FromFile

func FromFile(path string) (Db, error)

func GetTestDb

func GetTestDb() Db

func (*Db) GetBalances

func (d *Db) GetBalances(options BalanceQueryOptions) (Balances, error)

func (*Db) GetBalancesFromDate added in v0.0.26

func (d *Db) GetBalancesFromDate(from time.Time) (Balances, error)

func (*Db) GetSession

func (d *Db) GetSession() (db.Session, error)

func (*Db) InsertBalance

func (d *Db) InsertBalance(balance Balance) error

type TokenBalance

type TokenBalance struct {
	Wallet  string
	Symbol  string
	Address string
	Balance float64
	Locked  float64
}

type TokenPrice

type TokenPrice struct {
	Token string
	Price float32
	Fiat  string
}

type TokenPrices

type TokenPrices struct {
	Entries []TokenPrice
}

func (*TokenPrices) GetPrice

func (tp *TokenPrices) GetPrice(token string) float64

GetPrice returns price for a given token or 0 if not found

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL