Documentation ¶
Overview ¶
Package tango provides types and functions to calculate values of various market indicators.
Package tango provides types and functions to calculate values of various market indicators.
Index ¶
- Variables
- func Average(dd []decimal.Decimal) decimal.Decimal
- func MeanDeviation(dd []decimal.Decimal) decimal.Decimal
- func SquareRoot(d decimal.Decimal) decimal.Decimal
- func StandardDeviation(dd []decimal.Decimal) decimal.Decimal
- type Aroon
- type BB
- type Band
- type CCI
- type DEMA
- type EMA
- type HMA
- type MA
- type MAType
- type ROC
- type RSI
- type SMA
- type Stoch
- type StochRSI
- type Trend
- type WMA
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidIndicator is returned when indicator is invalid. ErrInvalidIndicator = errors.New("invalid indicator") // ErrInvalidLength is returned when incorrect length is provided. ErrInvalidLength = errors.New("invalid length") // ErrInvalidDataSize is returned when incorrect data size is provided. ErrInvalidDataSize = errors.New("invalid data size") // ErrInvalidTrend is returned when trend doesn't match any of the // available trends. ErrInvalidTrend = errors.New("invalid trend") // ErrInvalidBand is returned when band doesn't match any of the // available bands. ErrInvalidBand = errors.New("invalid band") // ErrInvalidMA is returned when ma doesn't match any of the // availabble ma types. ErrInvalidMA = errors.New("invalid moving average") )
Functions ¶
func MeanDeviation ¶
MeanDeviation calculates mean deviation of given slice.
func SquareRoot ¶
SquareRoot is a helper function that calculated the square root of decimal number.
Types ¶
type Aroon ¶
type Aroon struct {
// contains filtered or unexported fields
}
Aroon holds all the necessary information needed to calculate Aroon. The zero value is not usable.
func NewAroon ¶
NewAroon validates provided configuration options and creates new Aroon indicator instance.
func (Aroon) Calc ¶
func (aroon Aroon) Calc(dd []decimal.Decimal) ( uptrend decimal.Decimal, downtrend decimal.Decimal, err error, )
Calc calculates both Aroon trends from the provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/a/aroon.asp. All credits are due to Tushar Chande who developed Aroon indicator.
func (Aroon) CalcTrend ¶
CalcTrend calculates specified Aroon trend from the provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/a/aroon.asp. All credits are due to Tushar Chande who developed Aroon indicator.
type BB ¶
type BB struct {
// contains filtered or unexported fields
}
BB holds all the necessary information needed to calculate Bollinger Bands. The zero value is not usable.
func (BB) Calc ¶
func (bb BB) Calc(dd []decimal.Decimal) ( upper decimal.Decimal, lower decimal.Decimal, width decimal.Decimal, err error, )
Calc calculates all BB values from provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/b/bollingerbands.asp. All credits are due to John Bollinger who developed BB indicator.
func (BB) CalcBand ¶
CalcBand calculates specified BB value from provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/b/bollingerbands.asp. All credits are due to John Bollinger who developed BB indicator.
type Band ¶
type Band int
Band specifies which band should be used.
func (Band) MarshalText ¶
MarshalText turns band into appropriate string representation in JSON.
func (*Band) UnmarshalText ¶
UnmarshalText turns JSON string to appropriate band value.
type CCI ¶
type CCI struct {
// contains filtered or unexported fields
}
CCI holds all the necessary information needed to calculate commodity channel index. The zero value is not usable.
func NewCCI ¶
NewCCI validates provided configuration options and creates new CCI indicator. If provided factor is zero, default value is going to be used (0.015f).
func (CCI) Calc ¶
Calc calculates CCI from the provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/c/commoditychannelindex.asp. All credits are due to Donald Lambert who developed CCI indicator.
type DEMA ¶
type DEMA struct {
// contains filtered or unexported fields
}
DEMA holds all the necessary information needed to calculate double exponential moving average. The zero value is not usable.
func (DEMA) Calc ¶
Calc calculates DEMA from the provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/d/double-exponential-moving-average.asp. All credits are due to Patrick Mulloy who developed DEMA indicator.
type EMA ¶
type EMA struct {
// contains filtered or unexported fields
}
EMA holds all the necessary information needed to calculate exponential moving average. The zero value is not usable.
func (EMA) Calc ¶
Calc calculates EMA from the provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/e/ema.asp.
type HMA ¶
type HMA struct {
// contains filtered or unexported fields
}
HMA holds all the necessary information needed to calculate hull moving average. The zero value is not usable.
func (HMA) Calc ¶
Calc calculates HMA from the provided data points slice. Calculation is based on formula provided by fidelity. https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/hull-moving-average. All credits are due to Alan Hull who developed HMA indicator.
type MA ¶
type MA interface { // Calc should return calculation results based on provided data // points slice. Calc([]decimal.Decimal) (decimal.Decimal, error) // Count should determine the total amount data points required for // the calculation. Count() int }
MA is an interface that all moving averages implement.
type MAType ¶
type MAType int
MAType is a custom type that validates it to be only of existing moving average types.
const ( MATypeDoubleExponential MAType = iota + 1 MATypeExponential MATypeHull MATypeSimple MATypeWeighted )
Available moving average indicator types.
func (MAType) MarshalText ¶
MarshalText turns MAType into appropriate string representation in JSON.
func (*MAType) UnmarshalText ¶
UnmarshalText turns JSON string to appropriate moving average type value.
type ROC ¶
type ROC struct {
// contains filtered or unexported fields
}
ROC holds all the necessary information needed to calculate rate of change. The zero value is not usable.
func (ROC) Calc ¶
Calc calculates ROC from the provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/p/pricerateofchange.asp.
type RSI ¶
type RSI struct {
// contains filtered or unexported fields
}
RSI holds all the necessary information needed to calculate relative strength index. The zero value is not usable.
func (RSI) Calc ¶
Calc calculates RSI from the provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/r/rsi.asp. All credits are due to J. Welles Wilder Jr. who developed RSI indicator.
type SMA ¶
type SMA struct {
// contains filtered or unexported fields
}
SMA holds all the necessary information needed to calculate simple moving average. The zero value is not usable.
func (SMA) Calc ¶
Calc calculates SMA from the provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/s/sma.asp.
type Stoch ¶
type Stoch struct {
// contains filtered or unexported fields
}
Stoch holds all the necessary information needed to calculate stochastic oscillator. The zero value is not usable.
func (Stoch) Calc ¶
Calc calculates Stoch from the provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/s/stochasticoscillator.asp.
type StochRSI ¶
type StochRSI struct {
// contains filtered or unexported fields
}
StochRSI holds all the necessary information needed to calculate stoch relative strength index. The zero value is not usable.
func NewStochRSI ¶
NewStochRSI validates provided configuration options and creates new StochRSI indicator.
func (StochRSI) Calc ¶
Calc calculates StochRSI from the provided data slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/terms/s/stochrsi.asp.
type Trend ¶
type Trend int
Trend specifies which trend should be used.
func (Trend) MarshalText ¶
MarshalText turns trend into appropriate string representation.
func (*Trend) UnmarshalText ¶
UnmarshalText turns string to appropriate trend value.
type WMA ¶
type WMA struct {
// contains filtered or unexported fields
}
WMA holds all the necessary information needed to calculate weighted moving average. The zero value is not usable.
func (WMA) Calc ¶
Calc calculates WMA from the provided data points slice. Calculation is based on formula provided by investopedia. https://www.investopedia.com/articles/technical/060401.asp.