timeserie

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeRangeInvalid       = fmt.Errorf("time range invalid")
	ErrTimeRangeStartAfterEnd = fmt.Errorf("%w: start after end", ErrTimeRangeInvalid)
)
View Source
var (
	ErrTimeStampAlreadyExists error = errors.New("timestamp-already-exists")
)

Functions

func TimeRangesToString

func TimeRangesToString(tr []TimeRange) string

Types

type MergeOptions

type MergeOptions struct {
	ErrorOnCollision bool
}

type TimeRange

type TimeRange struct {
	Start, End time.Time
}

TimeRange is a structure representing the slot of time, from start to end

func MergeTimeRanges

func MergeTimeRanges(tr1, tr2 []TimeRange) ([]TimeRange, error)

func OrderTimeRanges

func OrderTimeRanges(tr []TimeRange) []TimeRange

func (TimeRange) Validate

func (tr TimeRange) Validate() error

type TimeSerie

type TimeSerie[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any]() *TimeSerie[T]

func (TimeSerie[T]) AreMissing

func (ts TimeSerie[T]) AreMissing(start, end time.Time, interval time.Duration, limit uint) bool

AreMissing checks if there is missing candlesticks between two times

func (*TimeSerie[T]) Delete

func (ts *TimeSerie[T]) Delete(t ...time.Time)

func (TimeSerie[T]) Extract

func (ts TimeSerie[T]) Extract(start, end time.Time, limit int) *TimeSerie[T]

func (TimeSerie[T]) First

func (ts TimeSerie[T]) First() (time.Time, T, bool)

func (TimeSerie[T]) FirstN

func (ts TimeSerie[T]) FirstN(limit uint) *TimeSerie[T]

func (*TimeSerie[T]) Get

func (ts *TimeSerie[T]) Get(t time.Time) (T, bool)

func (TimeSerie[T]) GetMissingRanges

func (ts TimeSerie[T]) GetMissingRanges(start, end time.Time, interval time.Duration, limit uint) []TimeRange

func (TimeSerie[T]) GetMissingTimes

func (ts TimeSerie[T]) GetMissingTimes(start, end time.Time, interval time.Duration, limit uint) []time.Time

GetMissingTimes returns an array of missing time in the timeserie

func (TimeSerie[T]) Last

func (ts TimeSerie[T]) Last() (time.Time, T, bool)

func (*TimeSerie[T]) Len

func (ts *TimeSerie[T]) Len() int

func (*TimeSerie[T]) Loop

func (ts *TimeSerie[T]) Loop(callback func(time.Time, T) (bool, error)) error

func (*TimeSerie[T]) Merge

func (ts *TimeSerie[T]) Merge(ts2 TimeSerie[T], options *MergeOptions) error

func (*TimeSerie[T]) Set

func (ts *TimeSerie[T]) Set(t time.Time, d T) *TimeSerie[T]

Jump to

Keyboard shortcuts

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