bbgo: add TestIndicatorSet_EWMA test

This commit is contained in:
c9s 2023-06-30 11:02:42 +08:00
parent ea1025d790
commit a3a1586e24
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -37,7 +37,7 @@ func TestIndicatorSet_closeCache(t *testing.T) {
assert.Equal(t, close1m, close1m2) assert.Equal(t, close1m, close1m2)
} }
func TestIndicatorSet_rsi(t *testing.T) { func TestIndicatorSet_RSI(t *testing.T) {
indicatorSet := newTestIndicatorSet() indicatorSet := newTestIndicatorSet()
rsi1m := indicatorSet.RSI(types.IntervalWindow{Interval: types.Interval1m, Window: 7}) rsi1m := indicatorSet.RSI(types.IntervalWindow{Interval: types.Interval1m, Window: 7})
@ -46,3 +46,13 @@ func TestIndicatorSet_rsi(t *testing.T) {
rsiLast := rsi1m.Last(0) rsiLast := rsi1m.Last(0)
assert.InDelta(t, 80, rsiLast, 0.0000001) assert.InDelta(t, 80, rsiLast, 0.0000001)
} }
func TestIndicatorSet_EWMA(t *testing.T) {
indicatorSet := newTestIndicatorSet()
ema1m := indicatorSet.EWMA(types.IntervalWindow{Interval: types.Interval1m, Window: 7})
assert.NotNil(t, ema1m)
emaLast := ema1m.Last(0)
assert.InDelta(t, 19424.224853515625, emaLast, 0.0000001)
}