moon

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CDPR

func CDPR(days, gain float64) float64

Types

type Base

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

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
}

type ConstantBase

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

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) GetStartingPrice added in v0.0.7

func (cb ConstantBase) GetStartingPrice() float64

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) GetStartingPrice added in v0.0.7

func (rb RelativeBase) GetStartingPrice() float64

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