mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
indicator/macd: drop the legacy func calculateMACD
This commit is contained in:
parent
a7b7ed6610
commit
0b07fb5a83
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user