candlestick

package
v0.0.0-...-e7652ed Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: AGPL-3.0 Imports: 6 Imported by: 1

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 FromProtoBuf

func FromProtoBuf(pbc *proto.Candlestick) (time.Time, Candlestick, error)

func (Candlestick) Equal

func (cs Candlestick) Equal(b Candlestick) bool

func (Candlestick) PriceByType

func (cs Candlestick) PriceByType(pt PriceType) float64

func (Candlestick) ToProfoBuff

func (cs Candlestick) ToProfoBuff(t time.Time) *proto.Candlestick

type List

type List struct {
	// contains filtered or unexported fields
}

func NewEmptyList

func NewEmptyList(id ListID) *List

func NewList

func NewList(id ListID, candlesticks ...TimedCandlestick) (*List, error)

func (*List) Delete

func (l *List) Delete(t ...time.Time)

func (List) ExchangeName

func (l List) ExchangeName() string

func (List) Extract

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

func (List) First

func (l List) First() (TimedCandlestick, bool)

func (List) FirstN

func (l List) FirstN(limit uint) *List

func (List) Get

func (l List) Get(t time.Time) (Candlestick, bool)

func (*List) HasUncomplete

func (l *List) HasUncomplete() bool

func (List) ID

func (l List) ID() ListID

func (List) Last

func (l List) Last() (TimedCandlestick, bool)

func (List) Len

func (l List) Len() int

func (List) LoadFromProtoBuf

func (l List) LoadFromProtoBuf(cs []*proto.Candlestick) error

func (*List) Loop

func (l *List) Loop(callback func(t time.Time, cs Candlestick) (bool, error)) error

func (*List) Merge

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

func (*List) MergeTimeSeries

func (l *List) MergeTimeSeries(ts timeserie.TimeSerie, options *timeserie.MergeOptions) error

func (List) PairSymbol

func (l List) PairSymbol() string

func (List) Period

func (l List) Period() period.Symbol

func (*List) ReplaceUncomplete

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

func (*List) Set

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

func (List) String

func (l List) String() string

type ListID

type ListID struct {
	ExchangeName string
	PairSymbol   string
	Period       period.Symbol
}

func (ListID) String

func (lid ListID) 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

type TimedCandlestick

type TimedCandlestick struct {
	Time time.Time
	Candlestick
}

func MergeListIntoOneCandlestick

func MergeListIntoOneCandlestick(csl *List, per period.Symbol) TimedCandlestick

Jump to

Keyboard shortcuts

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