Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvgOverTime ¶
type AvgOverTime struct {
// contains filtered or unexported fields
}
AvgOverTime maintains change rate in the last avgInterval.
AvgOverTime takes changes with their own intervals, containers recent changes that happened in the last avgInterval, then calculates the change rate by (sum of changes) / (sum of intervals).
func NewAvgOverTime ¶
func NewAvgOverTime(interval time.Duration) *AvgOverTime
NewAvgOverTime returns an AvgOverTime with given interval.
func (*AvgOverTime) Add ¶
func (aot *AvgOverTime) Add(delta float64, interval time.Duration)
Add adds recent change to AvgOverTime.
func (*AvgOverTime) Get ¶
func (aot *AvgOverTime) Get() float64
Get returns change rate in the last interval.
func (*AvgOverTime) IsFull ¶
func (aot *AvgOverTime) IsFull() bool
IsFull returns whether AvgOverTime is full
func (*AvgOverTime) Set ¶
func (aot *AvgOverTime) Set(avg float64)
Set sets AvgOverTime to the given average.
type EMA ¶
type EMA struct {
// contains filtered or unexported fields
}
EMA works as an exponential moving average filter. References: https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average.
type HMA ¶
type HMA struct {
// contains filtered or unexported fields
}
HMA works as hull moving average There are at most `size` data points for calculating. References: https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/hull-moving-average
type MaxFilter ¶
type MaxFilter struct {
// contains filtered or unexported fields
}
MaxFilter works as a maximum filter with specified window size. There are at most `size` data points for calculating.
type MedianFilter ¶
type MedianFilter struct {
// contains filtered or unexported fields
}
MedianFilter works as a median filter with specified window size. There are at most `size` data points for calculating. References: https://en.wikipedia.org/wiki/Median_filter.
func NewMedianFilter ¶
func NewMedianFilter(size int) *MedianFilter
NewMedianFilter returns a MedianFilter.
func (*MedianFilter) Get ¶
func (r *MedianFilter) Get() float64
Get returns the median of the data set.
type MovingAvg ¶
type MovingAvg interface { // Add adds a data point to the data set. Add(data float64) // Get returns the moving average. Get() float64 // Reset cleans the data set. Reset() // Set = Reset + Add Set(data float64) }
MovingAvg provides moving average. Ref: https://en.wikipedia.org/wiki/Moving_average
type TimeMedian ¶
type TimeMedian struct {
// contains filtered or unexported fields
}
TimeMedian is AvgOverTime + MedianFilter Size of MedianFilter should be larger than double size of AvgOverTime to denoisy. Delay is aotSize * mfSize * reportInterval/4 and the min filled period is aotSize * reportInterval, which is not related with mfSize
func NewTimeMedian ¶
func NewTimeMedian(aotSize, mfSize, reportInterval int) *TimeMedian
NewTimeMedian returns a TimeMedian with given size.
func (*TimeMedian) Add ¶
func (t *TimeMedian) Add(delta float64, interval time.Duration)
Add adds recent change to TimeMedian.
func (*TimeMedian) Get ¶
func (t *TimeMedian) Get() float64
Get returns change rate in the median of the several intervals.
func (*TimeMedian) GetFilledPeriod ¶
func (t *TimeMedian) GetFilledPeriod() int
GetFilledPeriod returns filled period.
func (*TimeMedian) GetInstantaneous ¶
func (t *TimeMedian) GetInstantaneous() float64
GetInstantaneous returns instantaneous speed
type WMA ¶
type WMA struct {
// contains filtered or unexported fields
}
WMA works as a weight with specified window size. There are at most `size` data points for calculating. References:https://en.wikipedia.org/wiki/Moving_average#Weighted_moving_average