mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
indicator: rename consts for max ma values
This commit is contained in:
parent
4ccbb82237
commit
01bdef502b
|
@ -9,8 +9,8 @@ import (
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MaxEWMAValues = 1_000
|
const MaxNumOfEWMA = 1_000
|
||||||
const EWMAValueTruncateSize = 500
|
const MaxNumOfEWMATruncateSize = 500
|
||||||
|
|
||||||
//go:generate callbackgen -type EWMA
|
//go:generate callbackgen -type EWMA
|
||||||
type EWMA struct {
|
type EWMA struct {
|
||||||
|
@ -27,8 +27,8 @@ func (inc *EWMA) Update(value float64) {
|
||||||
if len(inc.Values) == 0 {
|
if len(inc.Values) == 0 {
|
||||||
inc.Values.Push(value)
|
inc.Values.Push(value)
|
||||||
return
|
return
|
||||||
} else if len(inc.Values) > MaxEWMAValues {
|
} else if len(inc.Values) > MaxNumOfEWMA {
|
||||||
inc.Values = inc.Values[EWMAValueTruncateSize:]
|
inc.Values = inc.Values[MaxNumOfEWMATruncateSize:]
|
||||||
}
|
}
|
||||||
|
|
||||||
ema := (1-multiplier)*inc.Last() + multiplier*value
|
ema := (1-multiplier)*inc.Last() + multiplier*value
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MaxSMAValues = 1_000
|
const MaxNumOfSMA = 1_000
|
||||||
const SMAValueTruncateSize = 500
|
const MaxNumOfSMATruncateSize = 500
|
||||||
|
|
||||||
var zeroTime time.Time
|
var zeroTime time.Time
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ func (inc *SMA) calculateAndUpdate(kLines []types.KLine) {
|
||||||
}
|
}
|
||||||
inc.Values.Push(sma)
|
inc.Values.Push(sma)
|
||||||
|
|
||||||
if len(inc.Values) > MaxSMAValues {
|
if len(inc.Values) > MaxNumOfSMA {
|
||||||
inc.Values = inc.Values[SMAValueTruncateSize:]
|
inc.Values = inc.Values[MaxNumOfSMATruncateSize:]
|
||||||
}
|
}
|
||||||
|
|
||||||
inc.EndTime = kLines[index].EndTime
|
inc.EndTime = kLines[index].EndTime
|
||||||
|
|
Loading…
Reference in New Issue
Block a user