let SMA indicator and EWMA indicator use IntervalWindow type

This commit is contained in:
c9s 2020-10-29 07:51:23 +08:00
parent 2f8bffeaca
commit c71f013916
3 changed files with 4 additions and 6 deletions

View File

@ -42,7 +42,7 @@ func NewStandardIndicatorSet(symbol string, store *MarketDataStore) *StandardInd
func (set *StandardIndicatorSet) GetSMA(iw types.IntervalWindow) *indicator.SMA {
inc, ok := set.SMA[iw]
if !ok {
inc := &indicator.SMA{Interval: iw.Interval, Window: iw.Window}
inc := &indicator.SMA{IntervalWindow: iw}
inc.Bind(set.store)
set.SMA[iw] = inc
}
@ -54,7 +54,7 @@ func (set *StandardIndicatorSet) GetSMA(iw types.IntervalWindow) *indicator.SMA
func (set *StandardIndicatorSet) GetEWMA(iw types.IntervalWindow) *indicator.EWMA {
inc, ok := set.EWMA[iw]
if !ok {
inc := &indicator.EWMA{Interval: iw.Interval, Window: iw.Window}
inc := &indicator.EWMA{IntervalWindow: iw}
inc.Bind(set.store)
set.EWMA[iw] = inc
}

View File

@ -7,8 +7,7 @@ import (
)
type EWMA struct {
Interval types.Interval
Window int
types.IntervalWindow
Values Float64Slice
EndTime time.Time
}

View File

@ -15,8 +15,7 @@ func (s *Float64Slice) Push(v float64) {
var zeroTime time.Time
type SMA struct {
Interval types.Interval
Window int
types.IntervalWindow
Values Float64Slice
EndTime time.Time
}