indicators

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignalNeutral = 0
	SignalBuy     = 1
	SignalSell    = -1
	CrossAbove    = 1
	CrossBelow    = -1
)

Variables

This section is empty.

Functions

func BatchCalculate added in v0.0.3

func BatchCalculate(ind Indicator, indices []int) []decimal.Decimal

BatchCalculate calculates an indicator for a range of indices in parallel NOTE: This only works for non-recursive indicators (like SMA, RSI, but NOT EMA) unless the cache is already populated or the indicator handles concurrency internally.

func ClearCache

func ClearCache(indicator cachedIndicator)

func GetCacheCapacity

func GetCacheCapacity(indicator cachedIndicator) int

func GetCacheSize

func GetCacheSize(indicator cachedIndicator) int

func Max

func Max(a, b int) int

func Min

func Min(a, b int) int

func MultiCalculate added in v0.0.3

func MultiCalculate(index int, indicators ...Indicator) []decimal.Decimal

MultiCalculate calculates multiple indicators for a given index in parallel

func NewCache

func NewCache(initialSize int) *cache

func NewPivotPointsIndicator

func NewPivotPointsIndicator(s *series.TimeSeries) *pivotPointsIndicator

NewPivotPointsIndicator returns an indicator that calculates standard Pivot Points. It usually uses the previous day's H, L, C to calculate today's levels.

func RegisterMetadata added in v0.0.3

func RegisterMetadata(name string, meta IndicatorMetadata)

RegisterMetadata registers metadata for an indicator name

Types

type DerivativeIndicator

type DerivativeIndicator struct {
	Indicator Indicator
}

DerivativeIndicator returns an indicator that calculates the derivative of the underlying Indicator. The derivative is defined as the difference between the value at the previous index and the value at the current index. Eg series [1, 1, 2, 3, 5, 8] -> [0, 0, 1, 1, 2, 3]

func (DerivativeIndicator) Calculate

func (di DerivativeIndicator) Calculate(index int) decimal.Decimal

Calculate returns the derivative of the underlying indicator. At index 0, it will always return 0.

type FloatIndicator added in v0.0.3

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

FloatIndicator wraps a slice of float64 as a GenericIndicator

func NewFloatIndicator added in v0.0.3

func NewFloatIndicator(values []float64) FloatIndicator

func (FloatIndicator) Calculate added in v0.0.3

func (fi FloatIndicator) Calculate(index int) float64

type GenericIndicator added in v0.0.3

type GenericIndicator[T any] interface {
	Calculate(int) T
}

GenericIndicator is a generic interface for indicators

type GenericSMA added in v0.0.3

type GenericSMA[T Numeric] struct {
	// contains filtered or unexported fields
}

GenericSMA is a generic Simple Moving Average

func NewGenericSMA added in v0.0.3

func NewGenericSMA[T Numeric](indicator GenericIndicator[T], window int, zero T, add func(T, T) T, div func(T, float64) T) *GenericSMA[T]

func (*GenericSMA[T]) Calculate added in v0.0.3

func (s *GenericSMA[T]) Calculate(index int) T

type IchimokuCloudResult

type IchimokuCloudResult struct {
	TenkanSen   decimal.Decimal
	KijunSen    decimal.Decimal
	SenkouSpanA decimal.Decimal
	SenkouSpanB decimal.Decimal
	ChikouSpan  decimal.Decimal
}

type IchimokuIndicator

type IchimokuIndicator interface {
	Indicator
	TenkanSen(index int) decimal.Decimal
	KijunSen(index int) decimal.Decimal
	SenkouSpanA(index int) decimal.Decimal
	SenkouSpanB(index int) decimal.Decimal
	ChikouSpan(index int) decimal.Decimal
	Cloud(index int) IchimokuCloudResult
}

func NewIchimokuIndicator

func NewIchimokuIndicator(s *series.TimeSeries) IchimokuIndicator

type Indicator

type Indicator interface {
	Calculate(int) decimal.Decimal
}

Indicator is an interface that describes a methodology by which to analyze a trading record for a specific property or trend. For example. MovingAverageIndicator implements the Indicator interface and, for a given index in the timeSeries, returns the current moving average of the prices in that series.

func NewADLineIndicator

func NewADLineIndicator(s *series.TimeSeries) Indicator

NewADLineIndicator returns an indicator that calculates the Accumulation/Distribution Line. https://www.investopedia.com/terms/a/accumulationdistributionplus.asp

func NewADXIndicator

func NewADXIndicator(s *series.TimeSeries, period int) Indicator

func NewALMAIndicator added in v0.0.3

func NewALMAIndicator(indicator Indicator, window int, offset, sigma float64) Indicator

NewALMAIndicator returns a new Arnaud Legoux Moving Average

func NewATRRatioIndicator added in v0.0.3

func NewATRRatioIndicator(atr, price Indicator) Indicator

func NewATRRatioIndicatorFromSeries added in v0.0.3

func NewATRRatioIndicatorFromSeries(s *series.TimeSeries, atrWindow int) Indicator

func NewAroonDownIndicator

func NewAroonDownIndicator(indicator Indicator, window int) Indicator

NewAroonDownIndicator returns a derivative indicator that will return a value based on the number of ticks since the lowest price in the window https://www.investopedia.com/terms/a/aroon.asp

Note: this indicator should be constructed with a either a LowPriceIndicator or a derivative thereof

func NewAroonUpIndicator

func NewAroonUpIndicator(indicator Indicator, window int) Indicator

NewAroonUpIndicator returns a derivative indicator that will return a value based on the number of ticks since the highest price in the window https://www.investopedia.com/terms/a/aroon.asp

Note: this indicator should be constructed with a either a HighPriceIndicator or a derivative thereof

func NewAverageGainsIndicator

func NewAverageGainsIndicator(indicator Indicator, window int) Indicator

NewAverageGainsIndicator Returns a new average gains indicator, which returns the average gains in the given window based on the given indicator.

func NewAverageLossesIndicator

func NewAverageLossesIndicator(indicator Indicator, window int) Indicator

NewAverageLossesIndicator Returns a new average losses indicator, which returns the average losses in the given window based on the given indicator.

func NewAveragePriceIndicator added in v0.0.3

func NewAveragePriceIndicator(series *series.TimeSeries) Indicator

func NewAverageTrueRangeIndicator

func NewAverageTrueRangeIndicator(series *series.TimeSeries, window int) Indicator

NewAverageTrueRangeIndicator returns a base indicator that calculates the average true range of the underlying over a window https://www.investopedia.com/terms/a/atr.asp

func NewAwesomeOscillatorIndicator

func NewAwesomeOscillatorIndicator(s *series.TimeSeries, windowFast, windowSlow int) Indicator

func NewBollingerBandwidthIndicator added in v0.0.3

func NewBollingerBandwidthIndicator(indicator Indicator, window int, sigma float64) Indicator

NewBollingerBandwidthIndicator returns an indicator which calculates the width of bollinger bands

func NewBollingerLowerBandIndicator

func NewBollingerLowerBandIndicator(indicator Indicator, window int, sigma float64) Indicator

NewBollingerLowerBandIndicator returns a a derivative indicator which returns the lower bound of a bollinger band on the underlying indicator

func NewBollingerUpperBandIndicator

func NewBollingerUpperBandIndicator(indicator Indicator, window int, sigma float64) Indicator

NewBollingerUpperBandIndicator a a derivative indicator which returns the upper bound of a bollinger band on the underlying indicator

func NewCCIIndicator

func NewCCIIndicator(ts *series.TimeSeries, window int) Indicator

NewCCIIndicator Returns a new Commodity Channel Index Indicator http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:commodity_channel_index_cci

func NewChandeMomentumOscillatorIndicator added in v0.0.3

func NewChandeMomentumOscillatorIndicator(indicator Indicator, window int) Indicator

NewChandeMomentumOscillatorIndicator returns a new Chande Momentum Oscillator

func NewClosePriceIndicator

func NewClosePriceIndicator(series *series.TimeSeries) Indicator

NewClosePriceIndicator returns an Indicator which returns the close price of a candle for a given index

func NewConstantIndicator

func NewConstantIndicator(constant float64) Indicator

NewConstantIndicator returns an indicator which always returns the same value for any index. It's useful when combined with other, fluxuating indicators to determine when an indicator has crossed a threshold.

func NewCumulativeGainsIndicator

func NewCumulativeGainsIndicator(indicator Indicator, window int) Indicator

NewCumulativeGainsIndicator returns a derivative indicator which returns all gains made in a base indicator for a given window.

func NewCumulativeLossesIndicator

func NewCumulativeLossesIndicator(indicator Indicator, window int) Indicator

NewCumulativeLossesIndicator returns a derivative indicator which returns all losses in a base indicator for a given window.

func NewDEMAIndicator

func NewDEMAIndicator(s *series.TimeSeries, window int) Indicator

func NewDefaultAwesomeOscillatorIndicator

func NewDefaultAwesomeOscillatorIndicator(s *series.TimeSeries) Indicator

func NewDerivativeIndicator

func NewDerivativeIndicator(indicator Indicator) Indicator

NewDerivativeIndicator returns an indicator that calculates the derivative of the underlying Indicator.

func NewDifferenceIndicator

func NewDifferenceIndicator(minuend, subtrahend Indicator) Indicator

NewDifferenceIndicator returns an indicator which returns the difference between one indicator (minuend) and a second indicator (subtrahend).

func NewDominantCyclePeriod added in v0.0.3

func NewDominantCyclePeriod(indicator Indicator) Indicator

func NewEMAIndicator

func NewEMAIndicator(indicator Indicator, window int) Indicator

NewEMAIndicator returns a derivative indicator which returns the average of the current and preceding values in the given windowSize, with values closer to current index given more weight. A more in-depth explanation can be found here: http://www.investopedia.com/terms/e/ema.asp

func NewFAMAIndicator added in v0.0.3

func NewFAMAIndicator(indicator Indicator, fastLimit, slowLimit float64) Indicator

NewFAMAIndicator returns the Following Adaptive Moving Average based on MAMA

func NewFastStochasticIndicator

func NewFastStochasticIndicator(series *series.TimeSeries, timeframe int) Indicator

NewFastStochasticIndicator returns a derivative Indicator which returns the fast stochastic indicator (%K) for the given window. https://www.investopedia.com/terms/s/stochasticoscillator.asp

func NewFixedDecimalIndicator

func NewFixedDecimalIndicator(vals ...decimal.Decimal) Indicator

func NewFixedIndicator

func NewFixedIndicator(vals ...float64) Indicator

NewFixedIndicator returns an indicator with a fixed set of values that are returned when an index is passed in

func NewGainIndicator

func NewGainIndicator(indicator Indicator) Indicator

NewGainIndicator returns a derivative indicator that returns the gains in the underlying indicator in the last bar, if any. If the delta is negative, zero is returned

func NewHMAIndicator

func NewHMAIndicator(indicator Indicator, window int) Indicator

func NewHTTrendline added in v0.0.3

func NewHTTrendline(indicator Indicator) Indicator

func NewHighPriceIndicator

func NewHighPriceIndicator(series *series.TimeSeries) Indicator

NewHighPriceIndicator returns an Indicator which returns the high price of a candle for a given index

func NewHilbertTransform added in v0.0.3

func NewHilbertTransform(indicator Indicator) Indicator

func NewKAMAIndicator

func NewKAMAIndicator(s *series.TimeSeries, window int) Indicator

func NewKVOIndicator

func NewKVOIndicator(s *series.TimeSeries) Indicator

NewKVOIndicator returns an indicator that calculates the Klinger Volume Oscillator. https://www.investopedia.com/terms/k/klingeroscillator.asp

func NewKeltnerChannelLowerIndicator

func NewKeltnerChannelLowerIndicator(series *series.TimeSeries, window int) Indicator

func NewKeltnerChannelUpperIndicator

func NewKeltnerChannelUpperIndicator(series *series.TimeSeries, window int) Indicator

func NewLossIndicator

func NewLossIndicator(indicator Indicator) Indicator

NewLossIndicator returns a derivative indicator that returns the losses in the underlying indicator in the last bar, if any. If the delta is positive, zero is returned

func NewLowPriceIndicator

func NewLowPriceIndicator(series *series.TimeSeries) Indicator

NewLowPriceIndicator returns an Indicator which returns the low price of a candle for a given index

func NewMACDHistogramIndicator

func NewMACDHistogramIndicator(macdIdicator Indicator, signalLinewindow int) Indicator

NewMACDHistogramIndicator returns a derivative Indicator based on the MACDIndicator, the result of which is the macd indicator minus it's signalLinewindow EMA. A more in-depth explanation can be found here: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:macd-histogram

func NewMACDIndicator

func NewMACDIndicator(baseIndicator Indicator, shortwindow, longwindow int) Indicator

NewMACDIndicator returns a derivative Indicator which returns the difference between two EMAIndicators with long and short windows. It's useful for gauging the strength of price movements. A more in-depth explanation can be found here: http://www.investopedia.com/terms/m/macd.asp

func NewMAMAIndicator added in v0.0.3

func NewMAMAIndicator(indicator Indicator, fastLimit, slowLimit float64) Indicator

NewMAMAIndicator returns a MESA Adaptive Moving Average. It also provides FAMA (Following Adaptive Moving Average) as a separate indicator if needed. This implementation returns MAMA.

func NewMFIIndicator

func NewMFIIndicator(s *series.TimeSeries, window int) Indicator

func NewMMAIndicator

func NewMMAIndicator(indicator Indicator, window int) Indicator

NewMMAIndicator returns a derivative indciator which returns the modified moving average of the underlying indictator. An in-depth explanation can be found here: https://en.wikipedia.org/wiki/Moving_average#Modified_moving_average

func NewMaximumDrawdownIndicator

func NewMaximumDrawdownIndicator(ind Indicator, window int) Indicator

NewMaximumDrawdownIndicator returns a derivative Indicator which returns the maximum drawdown of the underlying indicator over a window. Maximum drawdown is defined as the maximum observed loss from peak of an underlying indicator in a given timeframe. Maximum drawdown is given as a percentage of the peak. Use a window value of -1 to include all values present in the underlying indicator. See: https://www.investopedia.com/terms/m/maximum-drawdown-mdd.asp

func NewMaximumValueIndicator

func NewMaximumValueIndicator(ind Indicator, window int) Indicator

NewMaximumValueIndicator returns a derivative Indicator which returns the maximum value present in a given window. Use a window value of -1 to include all values in the underlying indicator.

func NewMeanDeviationIndicator

func NewMeanDeviationIndicator(indicator Indicator, window int) Indicator

NewMeanDeviationIndicator returns a derivative Indicator which returns the mean deviation of a base indicator in a given window. Mean deviation is an average of all values on the base indicator from the mean of that indicator.

func NewMedianPriceIndicator added in v0.0.3

func NewMedianPriceIndicator(series *series.TimeSeries) Indicator

func NewMinimumValueIndicator

func NewMinimumValueIndicator(ind Indicator, window int) Indicator

NewMinimumValueIndicator returns a derivative Indicator which returns the minimum value present in a given window. Use a window value of -1 to include all values in the underlying indicator.

func NewMomentumIndicator

func NewMomentumIndicator(s *series.TimeSeries, period int) Indicator

func NewOBVIndicator

func NewOBVIndicator(s *series.TimeSeries) Indicator

func NewOpenPriceIndicator

func NewOpenPriceIndicator(series *series.TimeSeries) Indicator

NewOpenPriceIndicator returns an Indicator which returns the open price of a candle for a given index

func NewParabolicSARIndicator

func NewParabolicSARIndicator(s *series.TimeSeries) Indicator

func NewPercentChangeIndicator

func NewPercentChangeIndicator(indicator Indicator) Indicator

NewPercentChangeIndicator returns a derivative indicator which returns the percent change (positive or negative) made in a base indicator up until the given indicator

func NewRMAIndicator added in v0.0.3

func NewRMAIndicator(indicator Indicator, window int) Indicator

func NewROCIndicator

func NewROCIndicator(s *series.TimeSeries, period int) Indicator

func NewRelativeStrengthIndexIndicator

func NewRelativeStrengthIndexIndicator(indicator Indicator, timeframe int) Indicator

NewRelativeStrengthIndexIndicator returns a derivative Indicator which returns the relative strength index of the base indicator in a given time frame. A more in-depth explanation of relative strength index can be found here: https://www.investopedia.com/terms/r/rsi.asp

func NewRelativeStrengthIndicator

func NewRelativeStrengthIndicator(indicator Indicator, timeframe int) Indicator

NewRelativeStrengthIndicator returns a derivative Indicator which returns the relative strength of the base indicator in a given time frame. Relative strength is the average again of up periods during the time frame divided by the average loss of down period during the same time frame

func NewRelativeVigorIndexIndicator

func NewRelativeVigorIndexIndicator(series *series.TimeSeries) Indicator

NewRelativeVigorIndexIndicator returns an Indicator which returns the index of the relative vigor of the prices of a sercurity. Relative Vigor Index is simply the difference of the previous four days' close and open prices divided by the difference between the previous four days high and low prices. A more in-depth explanation of relative vigor index can be found here: https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/relative-vigor-index

func NewRelativeVigorSignalLine

func NewRelativeVigorSignalLine(series *series.TimeSeries) Indicator

NewRelativeVigorSignalLine returns an Indicator intended to be used in conjunction with Relative vigor index, which returns the average value of the last 4 indices of the RVI indicator.

func NewSimpleMovingAverage

func NewSimpleMovingAverage(indicator Indicator, window int) Indicator

NewSimpleMovingAverage returns a derivative Indicator which returns the average of the current value and preceding values in the given windowSize.

func NewSlowStochasticIndicator

func NewSlowStochasticIndicator(k Indicator, window int) Indicator

NewSlowStochasticIndicator returns a derivative Indicator which returns the slow stochastic indicator (%D) for the given window. https://www.investopedia.com/terms/s/stochasticoscillator.asp

func NewStandardDeviationIndicator

func NewStandardDeviationIndicator(ind Indicator) Indicator

NewStandardDeviationIndicator calculates the standard deviation of a base indicator. See https://www.investopedia.com/terms/s/standarddeviation.asp

func NewSuperTrendIndicator

func NewSuperTrendIndicator(s *series.TimeSeries, window int, multiplier float64) Indicator

NewSuperTrendIndicator returns an indicator that calculates the SuperTrend. https://www.tradingview.com/support/solutions/43000634738-supertrend/

func NewT3Indicator added in v0.0.3

func NewT3Indicator(indicator Indicator, window int, vFactor float64) Indicator

NewT3Indicator returns a new Tillson T3 Moving Average

func NewTEMAIndicator

func NewTEMAIndicator(s *series.TimeSeries, window int) Indicator

func NewTRIMAIndicator added in v0.0.3

func NewTRIMAIndicator(indicator Indicator, window int) Indicator

func NewTrendlineIndicator

func NewTrendlineIndicator(indicator Indicator, window int) Indicator

NewTrendlineIndicator returns an indicator whose output is the slope of the trend line given by the values in the window.

func NewTrueRangeIndicator

func NewTrueRangeIndicator(series *series.TimeSeries) Indicator

NewTrueRangeIndicator returns a base indicator which calculates the true range at the current point in time for a series https://www.investopedia.com/terms/a/atr.asp

func NewTypicalPriceIndicator

func NewTypicalPriceIndicator(series *series.TimeSeries) Indicator

NewTypicalPriceIndicator returns an Indicator which returns the typical price of a candle for a given index. The typical price is an average of the high, low, and close prices for a given candle.

func NewUltimateOscillatorIndicator

func NewUltimateOscillatorIndicator(s *series.TimeSeries, period1, period2, period3 int) Indicator

func NewUnstableIndicator added in v0.0.3

func NewUnstableIndicator(indicator Indicator, unstablePeriod int) Indicator

NewUnstableIndicator wraps an indicator and returns ZERO for any index within the unstable period.

func NewVIDYAIndicator added in v0.0.3

func NewVIDYAIndicator(indicator Indicator, window int) Indicator

NewVIDYAIndicator returns a new Variable Index Dynamic Average

func NewVWAPIndicator

func NewVWAPIndicator(s *series.TimeSeries) Indicator

NewVWAPIndicator returns an indicator that calculates the Volume Weighted Average Price. This implementation is cumulative since the start of the time series. https://www.investopedia.com/terms/v/vwap.asp

func NewVWMAIndicator added in v0.0.3

func NewVWMAIndicator(indicator, volume Indicator, window int) Indicator

NewVWMAIndicator returns a Volume Weighted Moving Average

func NewVWMAIndicatorFromSeries added in v0.0.3

func NewVWMAIndicatorFromSeries(s *series.TimeSeries, window int) Indicator

NewVWMAIndicatorFromSeries is a helper to create VWMA from series

func NewVarianceIndicator

func NewVarianceIndicator(ind Indicator) Indicator

NewVarianceIndicator provides a way to find the variance in a base indicator, where variances is the sum of squared deviations from the mean at any given index in the time series.

func NewVolumeIndicator

func NewVolumeIndicator(series *series.TimeSeries) Indicator

NewVolumeIndicator returns an indicator which returns the volume of a candle for a given index

func NewVolumeROCIndicator

func NewVolumeROCIndicator(s *series.TimeSeries, period int) Indicator

NewVolumeROCIndicator returns an indicator that calculates the Volume Rate of Change.

func NewVortexIndicator

func NewVortexIndicator(s *series.TimeSeries, period int) Indicator

func NewWMAIndicator

func NewWMAIndicator(indicator Indicator, window int) Indicator

NewWMAIndicator returns a new Weighted Moving Average

func NewWeightedCloseIndicator added in v0.0.3

func NewWeightedCloseIndicator(series *series.TimeSeries) Indicator

func NewWilliamsRIndicator

func NewWilliamsRIndicator(s *series.TimeSeries, window int) Indicator

func NewWindowedStandardDeviationIndicator

func NewWindowedStandardDeviationIndicator(ind Indicator, window int) Indicator

NewWindowedStandardDeviationIndicator returns a indicator which calculates the standard deviation of the underlying indicator over a window

func NewWindowedVWAPIndicator

func NewWindowedVWAPIndicator(s *series.TimeSeries, window int) Indicator

NewWindowedVWAPIndicator returns an indicator that calculates the VWAP over a fixed window.

func NewZigZagIndicator

func NewZigZagIndicator(s *series.TimeSeries, percent float64) Indicator

NewZigZagIndicator returns an indicator that calculates the ZigZag. It requires a percentage change (e.g. 0.05 for 5%) to form a new leg.

type IndicatorBuilder added in v0.0.3

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

IndicatorBuilder is a fluent API for building indicators

func NewIndicatorBuilder added in v0.0.3

func NewIndicatorBuilder(s *series.TimeSeries) *IndicatorBuilder

NewIndicatorBuilder starts a new indicator pipeline with a close price indicator

func (*IndicatorBuilder) BollingerLower added in v0.0.3

func (b *IndicatorBuilder) BollingerLower(window int, sigma float64) *IndicatorBuilder

BollingerLower adds a Bollinger Lower Band to the pipeline

func (*IndicatorBuilder) BollingerUpper added in v0.0.3

func (b *IndicatorBuilder) BollingerUpper(window int, sigma float64) *IndicatorBuilder

BollingerUpper adds a Bollinger Upper Band to the pipeline

func (*IndicatorBuilder) Build added in v0.0.3

func (b *IndicatorBuilder) Build() Indicator

Build returns the final indicator

func (*IndicatorBuilder) EMA added in v0.0.3

func (b *IndicatorBuilder) EMA(window int) *IndicatorBuilder

EMA adds an Exponential Moving Average to the pipeline

func (*IndicatorBuilder) MACD added in v0.0.3

func (b *IndicatorBuilder) MACD(fast, slow int) *IndicatorBuilder

MACD adds a MACD indicator to the pipeline

func (*IndicatorBuilder) RSI added in v0.0.3

func (b *IndicatorBuilder) RSI(window int) *IndicatorBuilder

RSI adds a Relative Strength Index to the pipeline

func (*IndicatorBuilder) SMA added in v0.0.3

func (b *IndicatorBuilder) SMA(window int) *IndicatorBuilder

SMA adds a Simple Moving Average to the pipeline

type IndicatorMetadata added in v0.0.3

type IndicatorMetadata struct {
	Name        string
	Category    string
	Description string
	Inputs      []string
	Lookback    int
}

IndicatorMetadata describes an indicator's properties

func GetMetadata added in v0.0.3

func GetMetadata(name string) (IndicatorMetadata, error)

GetMetadata returns metadata for an indicator name

type Numeric added in v0.0.3

type Numeric interface {
	~float64 | ~int | ~int64 | decimal.Decimal
}

Numeric is a constraint for types that support basic arithmetic

type PivotPointResult

type PivotPointResult struct {
	Pivot      decimal.Decimal
	R1, R2, R3 decimal.Decimal
	S1, S2, S3 decimal.Decimal
}

type SelfDescribingIndicator added in v0.0.3

type SelfDescribingIndicator interface {
	Indicator
	Lookback() int
	Metadata() IndicatorMetadata
}

SelfDescribingIndicator is an Indicator that can describe its requirements and properties

type SignalIndicator added in v0.0.3

type SignalIndicator interface {
	CalculateSignal(int) int
}

func CombineSignals added in v0.0.3

func CombineSignals(signals ...SignalIndicator) []SignalIndicator

func NewCrossoverSignal added in v0.0.3

func NewCrossoverSignal(shortTerm, longTerm Indicator, crossType int) SignalIndicator

func NewMACDSignal added in v0.0.3

func NewMACDSignal(macd, signal Indicator) SignalIndicator

func NewMultiSignal added in v0.0.3

func NewMultiSignal(signals []SignalIndicator, voteThreshold int) SignalIndicator

func NewRSISignal added in v0.0.3

func NewRSISignal(rsi Indicator, overbought, oversold float64) SignalIndicator

func NewSupertrendSignal added in v0.0.3

func NewSupertrendSignal(supertrend Indicator) SignalIndicator

func NewThresholdSignal added in v0.0.3

func NewThresholdSignal(indicator Indicator, upper, lower float64) SignalIndicator

type StreamingEMA added in v0.0.3

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

StreamingEMA is a streaming version of EMA

func NewStreamingEMA added in v0.0.3

func NewStreamingEMA(window int) *StreamingEMA

func (*StreamingEMA) Calculate added in v0.0.3

func (s *StreamingEMA) Calculate(index int) decimal.Decimal

func (*StreamingEMA) Next added in v0.0.3

type StreamingIndicator added in v0.0.3

type StreamingIndicator interface {
	Indicator
	Next(val decimal.Decimal) decimal.Decimal
}

StreamingIndicator is an interface for indicators that can be updated with new values in real-time

type StreamingSMA added in v0.0.3

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

StreamingSMA is a streaming version of SMA

func NewStreamingSMA added in v0.0.3

func NewStreamingSMA(window int) *StreamingSMA

func (*StreamingSMA) Calculate added in v0.0.3

func (s *StreamingSMA) Calculate(index int) decimal.Decimal

func (*StreamingSMA) Next added in v0.0.3

type TimeSeriesIndicator added in v0.0.3

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

TimeSeriesIndicator is a helper to access TimeSeries from within indicators if needed

func NewTimeSeriesIndicator added in v0.0.3

func NewTimeSeriesIndicator(s *series.TimeSeries) *TimeSeriesIndicator

func (*TimeSeriesIndicator) Calculate added in v0.0.3

func (tsi *TimeSeriesIndicator) Calculate(index int) decimal.Decimal

Jump to

Keyboard shortcuts

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