Fix test case

This commit is contained in:
なるみ 2021-05-12 14:39:10 +08:00
parent ca0061856d
commit f1d88188e8
2 changed files with 6 additions and 2 deletions

View File

@ -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)
}
})

View File

@ -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)
}
})