diff --git a/pkg/indicator/macd_test.go b/pkg/indicator/macd_test.go index c78213c2f..6fb80b4fe 100644 --- a/pkg/indicator/macd_test.go +++ b/pkg/indicator/macd_test.go @@ -1,6 +1,7 @@ package indicator import ( + "math" "testing" "github.com/c9s/bbgo/pkg/types" @@ -36,7 +37,8 @@ func Test_calculateMACD(t *testing.T) { macd := MACD{IntervalWindow: iw, ShortPeriod: 12, LongPeriod: 26} priceF := KLineClosePriceMapper got := macd.calculateMACD(tt.kLines, priceF) - if got != tt.want { + diff := math.Trunc((got-tt.want)*100) / 100 + if diff != 0 { t.Errorf("calculateMACD() = %v, want %v", got, tt.want) } }) diff --git a/pkg/indicator/vwap_test.go b/pkg/indicator/vwap_test.go index 1c14a8be0..f3be41d40 100644 --- a/pkg/indicator/vwap_test.go +++ b/pkg/indicator/vwap_test.go @@ -1,6 +1,7 @@ package indicator import ( + "math" "testing" "github.com/c9s/bbgo/pkg/types" @@ -54,7 +55,8 @@ func Test_calculateVWAP(t *testing.T) { vwap := VWAP{IntervalWindow: types.IntervalWindow{Window: tt.window}} priceF := KLineTypicalPriceMapper got := vwap.calculateVWAP(tt.kLines, priceF) - if got != tt.want { + diff := math.Trunc((got-tt.want)*100) / 100 + if diff != 0 { t.Errorf("calculateVWAP() = %v, want %v", got, tt.want) } })