mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 08:15:15 +00:00
bbgo: add debug ewma and sma
This commit is contained in:
parent
30b82390b7
commit
d763a3c415
|
@ -23,13 +23,8 @@ var (
|
|||
)
|
||||
|
||||
func init() {
|
||||
if v, ok := util.GetEnvVarBool("DEBUG_EWMA"); ok {
|
||||
debugEWMA = v
|
||||
}
|
||||
|
||||
if v, ok := util.GetEnvVarBool("DEBUG_SMA"); ok {
|
||||
debugSMA = v
|
||||
}
|
||||
util.SetEnvVarBool("DEBUG_EWMA", &debugEWMA)
|
||||
util.SetEnvVarBool("DEBUG_SMA", &debugSMA)
|
||||
}
|
||||
|
||||
type StandardIndicatorSet struct {
|
||||
|
@ -69,7 +64,7 @@ func NewStandardIndicatorSet(symbol string, store *MarketDataStore) *StandardInd
|
|||
set.ewma[iw] = &indicator.EWMA{IntervalWindow: iw}
|
||||
set.ewma[iw].Bind(store)
|
||||
|
||||
// if debug ewma is enabled, we add the debug handler
|
||||
// if debug EWMA is enabled, we add the debug handler
|
||||
if debugEWMA {
|
||||
set.ewma[iw].OnUpdate(func(value float64) {
|
||||
log.Infof("%s EWMA %s: %f", symbol, iw.String(), value)
|
||||
|
|
|
@ -38,6 +38,15 @@ func GetEnvVarInt(n string) (int, bool) {
|
|||
return num, true
|
||||
}
|
||||
|
||||
func SetEnvVarBool(n string, v *bool) bool {
|
||||
b, ok := GetEnvVarBool(n)
|
||||
if ok {
|
||||
*v = b
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
func GetEnvVarBool(n string) (bool, bool) {
|
||||
str, ok := os.LookupEnv(n)
|
||||
if !ok {
|
||||
|
|
Loading…
Reference in New Issue
Block a user