indicators

package
v0.0.0-...-bc78c8b Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Average

func Average(data []float64) float64

Average calculates the average of a set of float64 numbers

func EMA

func EMA(current float64, period int, previousEMA float64) float64

EMA calculates the Exponential Moving Average

func SubSlices

func SubSlices(slice1, slice2 []float64) []float64

SubSlices subtracts two slices.

func TransverseEMA

func TransverseEMA(slice []float64, period int) []float64

TransverseEMA calculates exponential moving average of a slice for a certain period

func TransverseMACD

func TransverseMACD(points []float64, params ...int) ([]float64, []float64)

TransverseMACD stands for moving average convergence divergence.

func Variance

func Variance(data []float64) float64

Variance calculates the variance of a set of float64 numbers

Types

type MACDContainer

type MACDContainer struct {
	FastEMA   []float64
	SlowEMA   []float64
	MACD      []float64
	LagEMA    []float64
	Histogram []float64
	// contains filtered or unexported fields
}

MACDContainer calculates and stores MACD values

func NewMACDContainer

func NewMACDContainer(macdParams MACDParams, params ...[]float64) *MACDContainer

NewMACDContainer returns an instance of MACDContainer

func (*MACDContainer) AddPoint

func (mc *MACDContainer) AddPoint(p float64)

AddPoint users new point to calculate new MACD value

func (*MACDContainer) GetLastHistogramPoint

func (mc *MACDContainer) GetLastHistogramPoint() float64

GetLastHistogramPoint returns last histogram point calculated

func (*MACDContainer) GetLastMacdAndSignal

func (mc *MACDContainer) GetLastMacdAndSignal() (float64, float64)

GetLastMacdAndSignal returns the last MACD and signal values calculated

type MACDParams

type MACDParams struct {
	Fast int
	Slow int
	Lag  int
}

MACDParams has params to calculate MACD

type MetricStatisticsIndicator

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

func NewMetricStatisticsIndicator

func NewMetricStatisticsIndicator(options domain.StatisticsOptions) *MetricStatisticsIndicator

func (*MetricStatisticsIndicator) AddMetricValue

func (m *MetricStatisticsIndicator) AddMetricValue(value float32)

AddValue appends close price to statistics

func (*MetricStatisticsIndicator) GetState

func (m *MetricStatisticsIndicator) GetState() interface{}

GetState returns the state value

type MetricStatisticsIndicatorState

type MetricStatisticsIndicatorState struct {
	HasRequiredPoints bool

	Value             float64
	Average           float64
	StandardDeviation float64

	Change                  float64
	ChangeAverage           float64
	ChangeStandardDeviation float64

	Acceleration                  float64
	AccelerationAverage           float64
	AccelerationStandardDeviation float64
}

type PriceIndicator

type PriceIndicator struct {
	*MetricStatisticsIndicator
}

func NewPriceIndicator

func NewPriceIndicator(metricIndicator *MetricStatisticsIndicator) *PriceIndicator

func (*PriceIndicator) AddValue

func (pi *PriceIndicator) AddValue(ohlc *domain.OHLC)

type Statistics

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

Statistics receives points and do statitics calculations

func NewStatistics

func NewStatistics(options domain.StatisticsOptions) *Statistics

NewStatistics returns a Statitics instance

func (*Statistics) AddPoint

func (s *Statistics) AddPoint(p float64)

AddPoint recalculate values of interest

func (*Statistics) GetAverage

func (s *Statistics) GetAverage() float64

GetAverage returns the current standard deviation of data sample

func (*Statistics) GetLastValue

func (s *Statistics) GetLastValue() float64

GetLastValue returns the last point value added

func (*Statistics) GetStandardDeviation

func (s *Statistics) GetStandardDeviation() float64

GetStandardDeviation returns the current standard deviation of data sample

func (*Statistics) GetVariance

func (s *Statistics) GetVariance() float64

GetVariance returns the current variation of data sample

func (*Statistics) HasRequiredNumberOfPoints

func (s *Statistics) HasRequiredNumberOfPoints() bool

HasRequiredNumberOfPoints check whether the number of points hold are the same of required in options

func (*Statistics) RecalculateAverage

func (s *Statistics) RecalculateAverage(p float64)

RecalculateAverage calculates new average using the old average and the new sample value

func (*Statistics) RecalculateVariance

func (s *Statistics) RecalculateVariance(p float64)

RecalculateVariance calculates new variance using the old variance and the new sample value

type VolumeIndicator

type VolumeIndicator struct {
	*MetricStatisticsIndicator
}

func NewVolumeIndicator

func NewVolumeIndicator(metricIndicator *MetricStatisticsIndicator) *VolumeIndicator

func (*VolumeIndicator) AddValue

func (vi *VolumeIndicator) AddValue(ohlc *domain.OHLC)

Jump to

Keyboard shortcuts

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