indicator

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlatTrend float64 = 0
	UpTrend   float64 = 1
	DownTrend float64 = -1
)

Variables

This section is empty.

Functions

func TrendWithFlatMaxDiffInPercent added in v0.7.0

func TrendWithFlatMaxDiffInPercent(val bool) func(*Trend)

TrendWithFlatMaxDiffInPercent allows to pass flatMaxDiff in percent. The default value is false

Types

type AverageTrueRange

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

AverageTrueRange represents indicator to calculate Average True Range (ATR) https://en.wikipedia.org/wiki/Average_true_range

func (*AverageTrueRange) Calculate

func (ind *AverageTrueRange) Calculate(index int) float64

type AverageVolume added in v0.3.0

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

AverageVolume is a indicator to calculate average volume for given smoothInterval using simple moving average

func NewAverageVolume added in v0.3.0

func NewAverageVolume(series *timeseries.TimeSeries, period int) *AverageVolume

func (*AverageVolume) Calculate added in v0.3.0

func (av *AverageVolume) Calculate(index int) float64

type ExponentialMovingAverage added in v0.4.0

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

ExponentialMovingAverage represents indicator to calculate Exponential Moving Average (EMA)

func NewExponentialMovingAverage added in v0.4.0

func NewExponentialMovingAverage(series *timeseries.TimeSeries, smoothInterval int) (*ExponentialMovingAverage, error)

func (*ExponentialMovingAverage) Calculate added in v0.4.0

func (a *ExponentialMovingAverage) Calculate(index int) float64

type Indicator

type Indicator interface {
	Calculate(index int) float64 // index of trading candle
}

Indicator represents interface for indicators

func NewAverageTrueRange

func NewAverageTrueRange(series *timeseries.TimeSeries, period int) Indicator

type MockIndicator added in v0.2.0

type MockIndicator struct {
	mock.Mock
}

MockIndicator is an autogenerated mock type for the Indicator type

func (*MockIndicator) Calculate added in v0.2.0

func (_m *MockIndicator) Calculate(index int) float64

Calculate provides a mock function with given fields: index

type Trend added in v0.6.0

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

Trend returns a trend direction. It bases on fast (with shorter period) and slow EMA. flatMaxDiff allows setting max difference between fast and slow EMA when Calculate returns the flat.

func NewTrend added in v0.6.0

func NewTrend(
	fastEMAIndicator Indicator,
	slowEMAIndicator Indicator,
	flatMaxDiff float64,
	opts ...TrendOption,
) *Trend

func (*Trend) Calculate added in v0.6.0

func (t *Trend) Calculate(index int) float64

type TrendOption added in v0.7.0

type TrendOption func(*Trend)

type VolumeWeightedAveragePrice added in v0.5.0

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

VolumeWeightedAveragePrice represents indicator to calculate volume-weighted average price (VWAP). More details https://en.wikipedia.org/wiki/Volume-weighted_average_price

func NewVolumeWeightedAveragePrice added in v0.5.0

func NewVolumeWeightedAveragePrice(series *timeseries.TimeSeries) *VolumeWeightedAveragePrice

NewVolumeWeightedAveragePrice creates VolumeWeightedAveragePrice

func (*VolumeWeightedAveragePrice) Calculate added in v0.5.0

func (v *VolumeWeightedAveragePrice) Calculate(index int) float64

Calculate returns VWAP value for candle with given index

Jump to

Keyboard shortcuts

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