From 01bdef502bbfac47801e758950bdd3f7f6d3a6c3 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 28 Jun 2021 14:32:28 +0800 Subject: [PATCH] indicator: rename consts for max ma values --- pkg/indicator/ewma.go | 8 ++++---- pkg/indicator/sma.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/indicator/ewma.go b/pkg/indicator/ewma.go index 54f6a0c1a..6cdf378ff 100644 --- a/pkg/indicator/ewma.go +++ b/pkg/indicator/ewma.go @@ -9,8 +9,8 @@ import ( "github.com/c9s/bbgo/pkg/types" ) -const MaxEWMAValues = 1_000 -const EWMAValueTruncateSize = 500 +const MaxNumOfEWMA = 1_000 +const MaxNumOfEWMATruncateSize = 500 //go:generate callbackgen -type EWMA type EWMA struct { @@ -27,8 +27,8 @@ func (inc *EWMA) Update(value float64) { if len(inc.Values) == 0 { inc.Values.Push(value) return - } else if len(inc.Values) > MaxEWMAValues { - inc.Values = inc.Values[EWMAValueTruncateSize:] + } else if len(inc.Values) > MaxNumOfEWMA { + inc.Values = inc.Values[MaxNumOfEWMATruncateSize:] } ema := (1-multiplier)*inc.Last() + multiplier*value diff --git a/pkg/indicator/sma.go b/pkg/indicator/sma.go index 0533a0d92..1d3c0a7b6 100644 --- a/pkg/indicator/sma.go +++ b/pkg/indicator/sma.go @@ -9,8 +9,8 @@ import ( "github.com/c9s/bbgo/pkg/types" ) -const MaxSMAValues = 1_000 -const SMAValueTruncateSize = 500 +const MaxNumOfSMA = 1_000 +const MaxNumOfSMATruncateSize = 500 var zeroTime time.Time @@ -48,8 +48,8 @@ func (inc *SMA) calculateAndUpdate(kLines []types.KLine) { } inc.Values.Push(sma) - if len(inc.Values) > MaxSMAValues { - inc.Values = inc.Values[SMAValueTruncateSize:] + if len(inc.Values) > MaxNumOfSMA { + inc.Values = inc.Values[MaxNumOfSMATruncateSize:] } inc.EndTime = kLines[index].EndTime