Merge pull request #234 from narumiruna/fix/macd-vwap-test-case

This commit is contained in:
Yo-An Lin 2021-05-12 16:52:49 +08:00 committed by GitHub
commit 4028c39dbf
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)
}
})