From 1091010f6425574cba84962ae0727aa70719685c Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 24 Jun 2021 20:16:53 +0800 Subject: [PATCH] support: move property configuration to the top --- pkg/strategy/support/strategy.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/strategy/support/strategy.go b/pkg/strategy/support/strategy.go index 7d4689d99..14bfa9cbe 100644 --- a/pkg/strategy/support/strategy.go +++ b/pkg/strategy/support/strategy.go @@ -246,6 +246,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se s.MovingAverageWindow = 99 } + if s.Sensitivity > 0 { volRange, err := s.ScaleQuantity.ByVolumeRule.Range() if err != nil { @@ -281,15 +282,16 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se return fmt.Errorf("standardIndicatorSet is nil, symbol %s", s.Symbol) } + var zeroiw = types.IntervalWindow{} + if s.LongTermMovingAverage != zeroiw { + s.longTermEMA = standardIndicatorSet.EWMA(s.LongTermMovingAverage) + } + s.orderStore = bbgo.NewOrderStore(s.Symbol) s.orderStore.BindStream(session.UserDataStream) s.triggerEMA = standardIndicatorSet.EWMA(types.IntervalWindow{Interval: s.Interval, Window: s.MovingAverageWindow}) - var zeroiw = types.IntervalWindow{} - if s.LongTermMovingAverage != zeroiw { - s.longTermEMA = standardIndicatorSet.EWMA(s.LongTermMovingAverage) - } if err := s.LoadState(); err != nil { return err