diff --git a/pkg/indicator/macd.go b/pkg/indicator/macd.go index 9a50d8b04..972164b50 100644 --- a/pkg/indicator/macd.go +++ b/pkg/indicator/macd.go @@ -51,15 +51,6 @@ func (inc *MACD) Update(x float64) { inc.Histogram.Push(macd - inc.SignalLine.Last()) } -// Deprecated -- this function is not used ??? ask @narumi -func (inc *MACD) calculateMACD(kLines []types.KLine, priceF KLinePriceMapper) float64 { - for _, k := range kLines { - inc.PushK(k) - } - - return inc.Values[len(inc.Values)-1] -} - func (inc *MACD) Last() float64 { if len(inc.Values) == 0 { return 0.0 diff --git a/pkg/indicator/macd_test.go b/pkg/indicator/macd_test.go index 6cf074fff..0088f9db9 100644 --- a/pkg/indicator/macd_test.go +++ b/pkg/indicator/macd_test.go @@ -41,8 +41,9 @@ func Test_calculateMACD(t *testing.T) { t.Run(tt.name, func(t *testing.T) { iw := types.IntervalWindow{Window: 9} macd := MACD{IntervalWindow: iw, ShortPeriod: 12, LongPeriod: 26} - priceF := KLineClosePriceMapper - got := macd.calculateMACD(tt.kLines, priceF) + macd.CalculateAndUpdate(tt.kLines) + + got := macd.Last() diff := math.Trunc((got-tt.want)*100) / 100 if diff != 0 { t.Errorf("calculateMACD() = %v, want %v", got, tt.want)