Documentation
¶
Index ¶
Constants ¶
View Source
const ( ErrWindowsSize = "window size is wrong" ErrDataSetIsCold = "data set is cold" ErrNotEnoughData = "not enough data" )
Error messages.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Calculator ¶
type Calculator struct {
// contains filtered or unexported fields
}
Calculator is a simple moving average (SMA) calculator.
If a data set does not have enough values to calculate the SMA, the calculator is considered to be cold. If a data set contains enough values to calculate the SMA, the calculator is considered to be hot. A newly created calculator is cold.
func New ¶
func New(windowSize int) (c *Calculator, err error)
New is the constructor of the Calculator.
func (*Calculator) AddItemAndGetSMA ¶
func (c *Calculator) AddItemAndGetSMA(p ValueType) (sma ValueType, err error)
AddItemAndGetSMA inserts a new item into the data series and returns a new SMA value.
func (Calculator) IsCold ¶
func (c Calculator) IsCold() bool
IsCold checks whether the data set is cold.
Click to show internal directories.
Click to hide internal directories.