ohlc

package
v0.0.0-...-ab5ca81 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OHLC

type OHLC struct {
	Instrument string
	Open       decimal.Decimal `gorm:"type:decimal(13,6);"`
	High       decimal.Decimal `gorm:"type:decimal(13,6);"`
	HighTime   time.Time
	Low        decimal.Decimal `gorm:"type:decimal(13,6);"`
	LowTime    time.Time
	Close      decimal.Decimal `gorm:"type:decimal(13,6);"`
	Start      time.Time       `gorm:"index"`
	End        time.Time
	Duration   time.Duration `gorm:"index"`
	Gaps       bool
	// contains filtered or unexported fields
}

OHLC represents a full candle

func New

func New(instrument string, now time.Time, duration time.Duration, round bool) *OHLC

func ToHeikinAshi

func ToHeikinAshi(previous, now *OHLC) *OHLC

ToHeikinAshi calculates a Heikin Ashi candle from two OHLC candles

func (*OHLC) Age

func (o *OHLC) Age(now time.Time) time.Duration

func (*OHLC) CloseTick

func (o *OHLC) CloseTick() tick.Tick

func (*OHLC) Closed

func (o *OHLC) Closed() bool

Closed return true if candle is already closed (by time) or false if not.

func (*OHLC) ForceClose

func (o *OHLC) ForceClose()

func (*OHLC) HasGaps

func (o *OHLC) HasGaps() bool

func (*OHLC) HasPriceData

func (o *OHLC) HasPriceData() bool

func (*OHLC) HighTick

func (o *OHLC) HighTick() tick.Tick

func (*OHLC) LowTick

func (o *OHLC) LowTick() tick.Tick

func (*OHLC) NewPrice

func (o *OHLC) NewPrice(price decimal.Decimal, now time.Time) bool

NewPrice handles new price data Returns true if data was considered Returns false if the candle is already closed.

func (*OHLC) OpenTick

func (o *OHLC) OpenTick() tick.Tick

func (*OHLC) PerformanceFromOpenToHighAbsolute

func (o *OHLC) PerformanceFromOpenToHighAbsolute() decimal.Decimal

func (*OHLC) PerformanceFromOpenToLowAbsolute

func (o *OHLC) PerformanceFromOpenToLowAbsolute() decimal.Decimal

func (*OHLC) PerformanceInPercentage

func (o *OHLC) PerformanceInPercentage() decimal.Decimal

func (*OHLC) ReversionPerformanceFromHighAbsolute

func (o *OHLC) ReversionPerformanceFromHighAbsolute() decimal.Decimal

func (*OHLC) Store

func (o *OHLC) Store(gormDB *gorm.DB) error

func (*OHLC) String

func (o *OHLC) String() string

func (*OHLC) ToTicks

func (o *OHLC) ToTicks() []tick.Tick

ToTicks converts the OHLC candle to 4 ticks. It ensures the correct chronological order of high and low.

func (*OHLC) Validate

func (o *OHLC) Validate() error

func (*OHLC) VolatilityInPercentage

func (o *OHLC) VolatilityInPercentage() decimal.Decimal

type OHLCList

type OHLCList []OHLC

func (OHLCList) Len

func (e OHLCList) Len() int

func (OHLCList) Less

func (e OHLCList) Less(i, j int) bool

func (OHLCList) Swap

func (e OHLCList) Swap(i, j int)

Jump to

Keyboard shortcuts

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