Skip to content

Commit

Permalink
indicator/macd: drop the legacy func calculateMACD
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jul 14, 2022
1 parent a7b7ed6 commit 0b07fb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
9 changes: 0 additions & 9 deletions pkg/indicator/macd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pkg/indicator/macd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0b07fb5

Please sign in to comment.