move bbo monitor to bbgo package

This commit is contained in:
c9s 2024-09-27 17:53:21 +08:00
parent c8823e977f
commit 79b636fa02
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
4 changed files with 10 additions and 5 deletions

View File

@ -1,4 +1,4 @@
package twap package bbgo
import ( import (
"time" "time"

View File

@ -1,6 +1,6 @@
// Code generated by "callbackgen -type BboMonitor"; DO NOT EDIT. // Code generated by "callbackgen -type BboMonitor"; DO NOT EDIT.
package twap package bbgo
import ( import (
"github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/types"

View File

@ -207,6 +207,7 @@ type Strategy struct {
HedgeExchange string `json:"hedgeExchange"` HedgeExchange string `json:"hedgeExchange"`
UpdateInterval types.Duration `json:"updateInterval"` UpdateInterval types.Duration `json:"updateInterval"`
UpdateLayers int `json:"updateLayers"`
HedgeInterval types.Duration `json:"hedgeInterval"` HedgeInterval types.Duration `json:"hedgeInterval"`
@ -346,6 +347,10 @@ func (s *Strategy) Defaults() error {
s.UpdateInterval = types.Duration(5 * time.Second) s.UpdateInterval = types.Duration(5 * time.Second)
} }
if s.UpdateLayers == 0 {
s.UpdateLayers = 5
}
if s.FullReplenishInterval == 0 { if s.FullReplenishInterval == 0 {
s.FullReplenishInterval = types.Duration(10 * time.Minute) s.FullReplenishInterval = types.Duration(10 * time.Minute)
} }
@ -426,7 +431,7 @@ func (s *Strategy) quoteWorker(ctx context.Context) {
return return
} }
if time.Since(lastOrderReplenishTime) < 10*time.Second { if time.Since(lastOrderReplenishTime) < 15*time.Second {
continue continue
} }
@ -435,7 +440,7 @@ func (s *Strategy) quoteWorker(ctx context.Context) {
s.updateQuote(ctx, 0) s.updateQuote(ctx, 0)
case types.BookSignalUpdate: case types.BookSignalUpdate:
s.updateQuote(ctx, 5) s.updateQuote(ctx, s.UpdateLayers)
} }
lastOrderReplenishTime = time.Now() lastOrderReplenishTime = time.Now()

View File

@ -231,7 +231,7 @@ func (e *FixedQuantityExecutor) orderUpdater(ctx context.Context) {
ticker := time.NewTimer(e.updateInterval) ticker := time.NewTimer(e.updateInterval)
defer ticker.Stop() defer ticker.Stop()
monitor := NewBboMonitor() monitor := bbgo.NewBboMonitor()
for { for {
select { select {