period

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: AGPL-3.0 Imports: 4 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPeriod = errors.New("invalid period")
)

Functions

This section is empty.

Types

type Symbol

type Symbol string
const (
	M1  Symbol = "M1"
	M3  Symbol = "M3"
	M5  Symbol = "M5"
	M15 Symbol = "M15"
	M30 Symbol = "M30"
	H1  Symbol = "H1"
	H2  Symbol = "H2"
	H4  Symbol = "H4"
	H6  Symbol = "H6"
	H8  Symbol = "H8"
	H12 Symbol = "H12"
	D1  Symbol = "D1"
	D3  Symbol = "D3"
	W1  Symbol = "W1"
)

func FromDuration

func FromDuration(d time.Duration) (Symbol, error)

func FromSeconds

func FromSeconds(i int64) (Symbol, error)

func FromString

func FromString(symbol string) (Symbol, error)

func Symbols

func Symbols() []Symbol

func UniqueArray

func UniqueArray(sym1, sym2 []Symbol) []Symbol

func (Symbol) CountBetweenTimes

func (s Symbol) CountBetweenTimes(t1, t2 time.Time) int64

CountBetweenTimes returns the number of candlesticks between times

func (Symbol) Duration

func (s Symbol) Duration() time.Duration

func (Symbol) IsAligned

func (s Symbol) IsAligned(t time.Time) bool

func (Symbol) Opt

func (s Symbol) Opt() *Symbol

func (Symbol) RoundInterval

func (per Symbol) RoundInterval(start, end *time.Time) (time.Time, time.Time)

RoundInterval takes an interval (represented by start, end) and returns the closest time before or equal to 'start' corresponding to the period and the closest time after or equal to 'end' corresponding to the period.

Example: if M1 then 1:30 to 2:30 will become 1:00 to 3:00.

func (Symbol) RoundTime

func (s Symbol) RoundTime(t time.Time) time.Time

func (Symbol) String

func (s Symbol) String() string

func (Symbol) Validate

func (s Symbol) Validate() error

Jump to

Keyboard shortcuts

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