From f1d88188e86c30727e7688b9b1f54e566ec4e5c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=82=8B=E3=81=BF?= Date: Wed, 12 May 2021 14:39:10 +0800 Subject: [PATCH] Fix test case --- pkg/indicator/macd_test.go | 4 +++- pkg/indicator/vwap_test.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) 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) } })