-
-
Notifications
You must be signed in to change notification settings - Fork 296
/
seriesbase_imp.go
158 lines (121 loc) · 3.35 KB
/
seriesbase_imp.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package types
import (
"github.com/c9s/bbgo/pkg/datatype/floats"
)
// SeriesBase is a wrapper of the Series interface
// You can assign a data container that implements the Series interface
// And this SeriesBase struct provides the implemented methods for manipulating your data
type SeriesBase struct {
Series
}
func (s *SeriesBase) Index(i int) float64 {
return s.Last(i)
}
func (s *SeriesBase) Last(i int) float64 {
if s.Series == nil {
return 0
}
return s.Series.Last(i)
}
func (s *SeriesBase) Length() int {
if s.Series == nil {
return 0
}
return s.Series.Length()
}
func (s *SeriesBase) Sum(limit ...int) float64 {
return Sum(s, limit...)
}
func (s *SeriesBase) Mean(limit ...int) float64 {
return Mean(s, limit...)
}
func (s *SeriesBase) Abs() SeriesExtend {
return Abs(s)
}
func (s *SeriesBase) Predict(lookback int, offset ...int) float64 {
return Predict(s, lookback, offset...)
}
func (s *SeriesBase) NextCross(b Series, lookback int) (int, float64, bool) {
return NextCross(s, b, lookback)
}
func (s *SeriesBase) CrossOver(b Series) BoolSeries {
return CrossOver(s, b)
}
func (s *SeriesBase) CrossUnder(b Series) BoolSeries {
return CrossUnder(s, b)
}
func (s *SeriesBase) Highest(lookback int) float64 {
return Highest(s, lookback)
}
func (s *SeriesBase) Lowest(lookback int) float64 {
return Lowest(s, lookback)
}
func (s *SeriesBase) Add(b interface{}) SeriesExtend {
return Add(s, b)
}
func (s *SeriesBase) Minus(b interface{}) SeriesExtend {
return Sub(s, b)
}
func (s *SeriesBase) Div(b interface{}) SeriesExtend {
return Div(s, b)
}
func (s *SeriesBase) Mul(b interface{}) SeriesExtend {
return Mul(s, b)
}
func (s *SeriesBase) Dot(b interface{}, limit ...int) float64 {
return Dot(s, b, limit...)
}
func (s *SeriesBase) Array(limit ...int) []float64 {
return Array(s, limit...)
}
func (s *SeriesBase) Reverse(limit ...int) floats.Slice {
return Reverse(s, limit...)
}
func (s *SeriesBase) Change(offset ...int) SeriesExtend {
return Change(s, offset...)
}
func (s *SeriesBase) PercentageChange(offset ...int) SeriesExtend {
return PercentageChange(s, offset...)
}
func (s *SeriesBase) Stdev(params ...int) float64 {
return Stdev(s, params...)
}
func (s *SeriesBase) Rolling(window int) *RollingResult {
return Rolling(s, window)
}
func (s *SeriesBase) Shift(offset int) SeriesExtend {
return Shift(s, offset)
}
func (s *SeriesBase) Skew(length int) float64 {
return Skew(s, length)
}
func (s *SeriesBase) Variance(length int) float64 {
return Variance(s, length)
}
func (s *SeriesBase) Covariance(b Series, length int) float64 {
return Covariance(s, b, length)
}
func (s *SeriesBase) Correlation(b Series, length int, method ...CorrFunc) float64 {
return Correlation(s, b, length, method...)
}
func (s *SeriesBase) AutoCorrelation(length int, lag ...int) float64 {
return AutoCorrelation(s, length, lag...)
}
func (s *SeriesBase) Rank(length int) SeriesExtend {
return Rank(s, length)
}
func (s *SeriesBase) Sigmoid() SeriesExtend {
return Sigmoid(s)
}
func (s *SeriesBase) Softmax(window int) SeriesExtend {
return Softmax(s, window)
}
func (s *SeriesBase) Entropy(window int) float64 {
return Entropy(s, window)
}
func (s *SeriesBase) CrossEntropy(b Series, window int) float64 {
return CrossEntropy(s, b, window)
}
func (s *SeriesBase) Filter(b func(int, float64) bool, length int) SeriesExtend {
return Filter(s, b, length)
}