indicator/macd: drop the legacy func calculateMACD

This commit is contained in:
c9s 2022-07-14 10:36:16 +08:00
parent a7b7ed6610
commit 0b07fb5a83
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 3 additions and 11 deletions

View File

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

View File

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