tests.
This commit is contained in:
parent
4f381fa4dc
commit
6533e951e7
8 changed files with 309 additions and 16 deletions
|
|
@ -35,6 +35,17 @@ func (sma SMASeries) Len() int {
|
|||
return sma.InnerSeries.Len()
|
||||
}
|
||||
|
||||
// GetPeriod returns the window size.
|
||||
func (sma SMASeries) GetPeriod(defaults ...int) int {
|
||||
if sma.Period == 0 {
|
||||
if len(defaults) > 0 {
|
||||
return defaults[0]
|
||||
}
|
||||
return DefaultSimpleMovingAveragePeriod
|
||||
}
|
||||
return sma.Period
|
||||
}
|
||||
|
||||
// GetValue gets a value at a given index.
|
||||
func (sma SMASeries) GetValue(index int) (x, y float64) {
|
||||
if sma.InnerSeries == nil {
|
||||
|
|
@ -59,17 +70,6 @@ func (sma SMASeries) GetLastValue() (x, y float64) {
|
|||
return
|
||||
}
|
||||
|
||||
// GetPeriod returns the window size.
|
||||
func (sma SMASeries) GetPeriod(defaults ...int) int {
|
||||
if sma.Period == 0 {
|
||||
if len(defaults) > 0 {
|
||||
return defaults[0]
|
||||
}
|
||||
return DefaultSimpleMovingAveragePeriod
|
||||
}
|
||||
return sma.Period
|
||||
}
|
||||
|
||||
func (sma SMASeries) getAverage(index int) float64 {
|
||||
period := sma.GetPeriod()
|
||||
floor := MaxInt(0, index-period)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue