Documentation
¶
Index ¶
- func Average(data []float64) float64
- func EMA(current float64, period int, previousEMA float64) float64
- func SubSlices(slice1, slice2 []float64) []float64
- func TransverseEMA(slice []float64, period int) []float64
- func TransverseMACD(points []float64, params ...int) ([]float64, []float64)
- func Variance(data []float64) float64
- type MACDContainer
- type MACDParams
- type MetricStatisticsIndicator
- type MetricStatisticsIndicatorState
- type PriceIndicator
- type Statistics
- func (s *Statistics) AddPoint(p float64)
- func (s *Statistics) GetAverage() float64
- func (s *Statistics) GetLastValue() float64
- func (s *Statistics) GetStandardDeviation() float64
- func (s *Statistics) GetVariance() float64
- func (s *Statistics) HasRequiredNumberOfPoints() bool
- func (s *Statistics) RecalculateAverage(p float64)
- func (s *Statistics) RecalculateVariance(p float64)
- type VolumeIndicator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TransverseEMA ¶
TransverseEMA calculates exponential moving average of a slice for a certain period
func TransverseMACD ¶
TransverseMACD stands for moving average convergence divergence.
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 ¶
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 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)