Documentation
¶
Index ¶
- Variables
- func TimeRangesToString(tr []TimeRange) string
- type MergeOptions
- type TimeRange
- type TimeSerie
- func (ts TimeSerie[T]) AreMissing(start, end time.Time, interval time.Duration, limit uint) bool
- func (ts *TimeSerie[T]) Delete(t ...time.Time)
- func (ts TimeSerie[T]) Extract(start, end time.Time, limit int) *TimeSerie[T]
- func (ts TimeSerie[T]) First() (time.Time, T, bool)
- func (ts TimeSerie[T]) FirstN(limit uint) *TimeSerie[T]
- func (ts *TimeSerie[T]) Get(t time.Time) (T, bool)
- func (ts TimeSerie[T]) GetMissingRanges(start, end time.Time, interval time.Duration, limit uint) []TimeRange
- func (ts TimeSerie[T]) GetMissingTimes(start, end time.Time, interval time.Duration, limit uint) []time.Time
- func (ts TimeSerie[T]) Last() (time.Time, T, bool)
- func (ts *TimeSerie[T]) Len() int
- func (ts *TimeSerie[T]) Loop(callback func(time.Time, T) (bool, error)) error
- func (ts *TimeSerie[T]) MarshalJSON() ([]byte, error)
- func (ts *TimeSerie[T]) Merge(ts2 TimeSerie[T], options *MergeOptions) error
- func (ts *TimeSerie[T]) Set(t time.Time, d T) *TimeSerie[T]
- func (ts TimeSerie[T]) String() string
- func (ts TimeSerie[T]) ToArray() []T
- func (ts TimeSerie[T]) ToList() []T
- func (ts *TimeSerie[T]) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTimeRangeInvalid is returned when the time range is invalid. ErrTimeRangeInvalid = fmt.Errorf("time range invalid") // ErrTimeRangeStartAfterEnd is returned when the start time is after the end time. ErrTimeRangeStartAfterEnd = fmt.Errorf("%w: start after end", ErrTimeRangeInvalid) )
var ( // ErrTimeStampAlreadyExists is returned when trying to set a timestamp that already exists. ErrTimeStampAlreadyExists = errors.New("timestamp-already-exists") )
Functions ¶
func TimeRangesToString ¶
TimeRangesToString returns a string representation of the time ranges.
Types ¶
type MergeOptions ¶
type MergeOptions struct {
// ErrorOnCollision returns an error if there is a collision between the two TimeSeries.
ErrorOnCollision bool
}
MergeOptions are options for the Merge function.
type TimeRange ¶
TimeRange is a structure representing the slot of time, from start to end.
func MergeTimeRanges ¶
MergeTimeRanges merges two time ranges together.
func OrderTimeRanges ¶
OrderTimeRanges returns a list of TimeRange ordered by start time.
func TimeRangesFromMissingTimes ¶
TimeRangesFromMissingTimes return missing time ranges from a list of times.
type TimeSerie ¶
type TimeSerie[T any] struct { // contains filtered or unexported fields }
TimeSerie is a time serie data structure that can be used to store data over time.
func (TimeSerie[T]) AreMissing ¶
AreMissing checks if there is missing candlesticks between two times.
func (*TimeSerie[T]) Get ¶
Get gets a value at a specific time. The second return value is false if the value for this specific time does not exist.
func (TimeSerie[T]) GetMissingRanges ¶
func (ts TimeSerie[T]) GetMissingRanges(start, end time.Time, interval time.Duration, limit uint) []TimeRange
GetMissingRanges returns an array of missing time ranges in the timeserie.
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]) Loop ¶
Loop loops over every elements of the TimeSerie in time order and calls the callback function.
func (*TimeSerie[T]) MarshalJSON ¶
MarshalJSON marshals the TimeSerie into a JSON object.
func (*TimeSerie[T]) Merge ¶
func (ts *TimeSerie[T]) Merge(ts2 TimeSerie[T], options *MergeOptions) error
Merge merges two TimeSeries together.
func (TimeSerie[T]) String ¶ added in v1.1.0
String returns a string representation of the TimeSerie.
func (TimeSerie[T]) ToArray ¶ added in v1.1.0
func (ts TimeSerie[T]) ToArray() []T
ToArray converts the TimeSerie to an array of values.
func (TimeSerie[T]) ToList ¶
func (ts TimeSerie[T]) ToList() []T
ToList returns an ordered list of the TimeSerie.
func (*TimeSerie[T]) UnmarshalJSON ¶
UnmarshalJSON unmarshals the TimeSerie from a JSON object.