refactor: ewo use SeriesExtend

This commit is contained in:
zenix 2022-06-29 22:02:50 +09:00
parent 70f4676340
commit 0141f81086

View File

@ -279,8 +279,8 @@ func (s *Strategy) SetupIndicators(store *bbgo.MarketDataStore) {
}) })
s.ma5 = types.NewSeries(ema5) s.ma5 = ema5
s.ma34 = types.NewSeries(ema34) s.ma34 = ema34
} else if s.UseSma { } else if s.UseSma {
sma5 := &indicator.SMA{IntervalWindow: window5} sma5 := &indicator.SMA{IntervalWindow: window5}
sma34 := &indicator.SMA{IntervalWindow: window34} sma34 := &indicator.SMA{IntervalWindow: window34}
@ -300,8 +300,8 @@ func (s *Strategy) SetupIndicators(store *bbgo.MarketDataStore) {
sma34.Update(cloze) sma34.Update(cloze)
} }
}) })
s.ma5 = types.NewSeries(sma5) s.ma5 = sma5
s.ma34 = types.NewSeries(sma34) s.ma34 = sma34
} else { } else {
evwma5 := &VWEMA{ evwma5 := &VWEMA{
PV: &indicator.EWMA{IntervalWindow: window5}, PV: &indicator.EWMA{IntervalWindow: window5},
@ -355,7 +355,7 @@ func (s *Strategy) SetupIndicators(store *bbgo.MarketDataStore) {
sig.Update(s.ewo.Last()) sig.Update(s.ewo.Last())
} }
}) })
s.ewoSignal = types.NewSeries(sig) s.ewoSignal = sig
} else if s.UseSma { } else if s.UseSma {
sig := &indicator.SMA{IntervalWindow: windowSignal} sig := &indicator.SMA{IntervalWindow: windowSignal}
store.OnKLineWindowUpdate(func(interval types.Interval, _ types.KLineWindow) { store.OnKLineWindowUpdate(func(interval types.Interval, _ types.KLineWindow) {
@ -373,7 +373,7 @@ func (s *Strategy) SetupIndicators(store *bbgo.MarketDataStore) {
sig.Update(s.ewo.Last()) sig.Update(s.ewo.Last())
} }
}) })
s.ewoSignal = types.NewSeries(sig) s.ewoSignal = sig
} else { } else {
sig := &VWEMA{ sig := &VWEMA{
PV: &indicator.EWMA{IntervalWindow: windowSignal}, PV: &indicator.EWMA{IntervalWindow: windowSignal},