forked from rodrigo-brito/ninjabot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
obv.go
50 lines (40 loc) · 724 Bytes
/
obv.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package indicator
import (
"time"
"github.com/buugaaga/ninjabot/model"
"github.com/buugaaga/ninjabot/plot"
"github.com/markcheno/go-talib"
)
func OBV(color string) plot.Indicator {
return &obv{
Color: color,
}
}
type obv struct {
Color string
Values model.Series[float64]
Time []time.Time
}
func (e obv) Warmup() int {
return 0
}
func (e obv) Name() string {
return "OBV"
}
func (e obv) Overlay() bool {
return false
}
func (e *obv) Load(df *model.Dataframe) {
e.Values = talib.Obv(df.Close, df.Volume)
e.Time = df.Time
}
func (e obv) Metrics() []plot.IndicatorMetric {
return []plot.IndicatorMetric{
{
Color: e.Color,
Style: "line",
Values: e.Values,
Time: e.Time,
},
}
}