candlestick

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: AGPL-3.0 Imports: 5 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPeriodMismatch   = errors.New("period-mismatch")
	ErrCandlestickType  = errors.New("struct-not-candlestick")
	ErrExchangeMismatch = errors.New("exchange-mismatch")
	ErrPairMismatch     = errors.New("pair-mismatch")
)
View Source
var (
	ErrInvalidPriceType = errors.New("invalid-price-type")
)

Functions

func PriceByType

func PriceByType(open, high, low, close float64, pt PriceType) float64

Types

type Candlestick

type Candlestick struct {
	Open       float64 `bson:"open"     json:"open,omitempty"`
	High       float64 `bson:"high"     json:"high,omitempty"`
	Low        float64 `bson:"low"      json:"low,omitempty"`
	Close      float64 `bson:"close"    json:"close,omitempty"`
	Volume     float64 `bson:"volume"   json:"volume,omitempty"`
	Uncomplete bool    `bson:"complete" json:"uncomplete,omitempty"`
}

func MergeListIntoOneCandlestick

func MergeListIntoOneCandlestick(csl *List, per period.Symbol) (time.Time, Candlestick)

func (Candlestick) Equal

func (cs Candlestick) Equal(b Candlestick) bool

func (Candlestick) PriceByType

func (cs Candlestick) PriceByType(pt PriceType) float64

func (Candlestick) String

func (cs Candlestick) String() string

type List

type List struct {
	ExchangeName string
	PairSymbol   string
	Period       period.Symbol
	timeserie.TimeSerie[Candlestick]
}

func NewEmptyList

func NewEmptyList(exchangeName, pairSymbol string, period period.Symbol) *List

func NewEmptyListFrom

func NewEmptyListFrom(l *List) *List

func (List) AreMissing

func (cl List) AreMissing(end, start time.Time, limit uint) bool

AreMissing checks if there is missing candlesticks between two times Time order: start < end

func (List) Extract

func (l List) Extract(start, end time.Time, limit uint) *List

func (*List) HasUncomplete

func (l *List) HasUncomplete() bool

func (*List) Merge

func (l *List) Merge(l2 *List, options *timeserie.MergeOptions) error

func (*List) MustSet

func (l *List) MustSet(t time.Time, c Candlestick) *List

func (*List) ReplaceUncomplete

func (l *List) ReplaceUncomplete(l2 *List)

func (*List) Set

func (l *List) Set(t time.Time, c Candlestick) error

func (List) String

func (l List) String() string

type PriceType

type PriceType string
const (
	PriceTypeIsOpen  PriceType = "open"
	PriceTypeIsHigh  PriceType = "high"
	PriceTypeIsLow   PriceType = "low"
	PriceTypeIsClose PriceType = "close"
)

func (PriceType) String

func (pt PriceType) String() string

func (PriceType) Validate

func (pt PriceType) Validate() error

Jump to

Keyboard shortcuts

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