moon

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConstantBases = []ConstantBase{
	{"2020-", time.Unix(1577836800, 0)},
	{"2017-", time.Unix(1483228800, 0)},
}
View Source
var DefaultGoals = []Goal{
	{"$100k", 100000},
	{"$150k", 150000},
	{"$200k", 200000},
	{"$250k", 250000},
	{"$300k", 300000},
	{"$500k", 500000},
	{"$1m", 1000000},
}
View Source
var DefaultRelativeBases = []RelativeBase{
	{"Month", time.Duration(-30) * time.Hour * 24},
	{"Quarter", time.Duration(-90) * time.Hour * 24},
	{"Half-Year", time.Duration(-182) * time.Hour * 24},
	{"Year", time.Duration(-365) * time.Hour * 24},
}

Functions

func CDPR

func CDPR(days, gain float64) float64

Types

type Base

type Base interface {
	From(now time.Time) time.Time
	Label() string
}

Base is a temporal point of comparison used for price projection.

type Column

type Column struct {
	Base          Base
	StartingDate  time.Time
	StartingPrice coindesk.Price
	Gain          float64
	CDPR          float64
	Projections   Projection
}

func (*Column) Column added in v0.0.3

func (c *Column) Column() (entries []string)

type ConstantBase

type ConstantBase struct {
	Name string    `koanf:"name"`
	Time time.Time `koanf:"time"`
}

ConstantBase is a base that is a constant time, e.g. 2020-01-01.

func (ConstantBase) From

func (cb ConstantBase) From(_ time.Time) time.Time

func (ConstantBase) Label

func (cb ConstantBase) Label() string

type Goal

type Goal struct {
	Name  string  `koanf:"name"`
	Value float64 `koanf:"value"`
}

type Math

type Math struct {
	Asset        coindesk.Asset
	CurrentPrice coindesk.Price
	Columns      []Column
	Goals        []Goal
	Labels       []string
}

func NewMath

func NewMath(asset coindesk.Asset, goals []Goal, bases []Base) (m Math)

func (*Math) Refresh

func (m *Math) Refresh(ctx context.Context) (err error)

type Projection

type Projection struct {
	Dates []time.Time
}

func ProjectDates

func ProjectDates(
	from time.Time, currentPrice float64, cdpr float64, goals []Goal,
) (p Projection)

type RelativeBase

type RelativeBase struct {
	Name   string        `koanf:"name"`
	Offset time.Duration `koanf:"offset"`
}

RelativeBase is a base that is relative, e.g. "90 days ago."

func (RelativeBase) From

func (rb RelativeBase) From(now time.Time) time.Time

func (RelativeBase) Label

func (rb RelativeBase) Label() string

Jump to

Keyboard shortcuts

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