diff --git a/pkg/indicator/sma_test.go b/pkg/indicator/sma_test.go index fb40716cc..a6ecc1324 100644 --- a/pkg/indicator/sma_test.go +++ b/pkg/indicator/sma_test.go @@ -4,9 +4,10 @@ import ( "encoding/json" "testing" + "github.com/stretchr/testify/assert" + "github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/types" - "github.com/stretchr/testify/assert" ) /* @@ -52,7 +53,11 @@ func Test_SMA(t *testing.T) { sma := SMA{ IntervalWindow: types.IntervalWindow{Window: 5}, } - sma.CalculateAndUpdate(tt.kLines) + + for _, k := range tt.kLines { + sma.PushK(k) + } + assert.InDelta(t, tt.want, sma.Last(), Delta) assert.InDelta(t, tt.next, sma.Index(1), Delta) sma.Update(tt.update) diff --git a/pkg/indicator/stoch_test.go b/pkg/indicator/stoch_test.go index 56839dadc..eb3d0206c 100644 --- a/pkg/indicator/stoch_test.go +++ b/pkg/indicator/stoch_test.go @@ -56,7 +56,10 @@ func TestSTOCH_update(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { kd := STOCH{IntervalWindow: types.IntervalWindow{Window: tt.window}} - kd.CalculateAndUpdate(tt.kLines) + + for _, k := range tt.kLines { + kd.PushK(k) + } got_k := kd.LastK() diff_k := math.Trunc((got_k-tt.want_k)*100) / 100