Skip to content

Commit

Permalink
fix bollinger indicator history kline push
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jan 24, 2024
1 parent 884b8f2 commit dd07bc7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pkg/bbgo/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ func (environ *Environment) ConfigureDatabase(ctx context.Context, config *Confi
dbDriver = "mysql"
}

if dbDriver == "" {
return fmt.Errorf("either env DB_DRIVER or config.Driver is not set")
// database is optional
if dbDriver == "" || dbDSN == "" {
return nil
}

return environ.ConfigureDatabaseDriver(ctx, dbDriver, dbDSN, extraPkgNames...)
Expand Down
3 changes: 2 additions & 1 deletion pkg/indicator/v2/boll.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ func BOLL(source types.Float64Source, window int, k float64) *BOLLStream {
SMA: sma,
StdDev: stdDev,
}
s.Bind(source, s)

// on band update
s.Float64Series.OnUpdate(func(band float64) {
mid := s.SMA.Last(0)
s.UpBand.PushAndEmit(mid + band)
s.DownBand.PushAndEmit(mid - band)
})

s.Bind(source, s)
return s
}

Expand Down

0 comments on commit dd07bc7

Please sign in to comment.