diff --git a/pkg/bbgo/persistence.go b/pkg/bbgo/persistence.go index c151df185..3cc177463 100644 --- a/pkg/bbgo/persistence.go +++ b/pkg/bbgo/persistence.go @@ -76,6 +76,16 @@ func (p *Persistence) Save(val interface{}, subIDs ...string) error { return store.Save(val) } +func (p *Persistence) Sync(obj interface{}) error { + id := callID(obj) + if len(id) == 0 { + return nil + } + + ps := p.Facade.Get() + return storePersistenceFields(obj, id, ps) +} + type StructFieldIterator func(tag string, ft reflect.StructField, fv reflect.Value) error func iterateFieldsByTag(obj interface{}, tagName string, cb StructFieldIterator) error { diff --git a/pkg/strategy/bollmaker/strategy.go b/pkg/strategy/bollmaker/strategy.go index 5d91ac6b7..ac4e311eb 100644 --- a/pkg/strategy/bollmaker/strategy.go +++ b/pkg/strategy/bollmaker/strategy.go @@ -266,11 +266,12 @@ func (s *Strategy) Suspend(ctx context.Context) error { log.WithError(err).Errorf("graceful cancel order error") s.Notify("graceful cancel order error") } else { - s.Notify("All orders cancelled.") + s.Notify("All orders are cancelled.") } s.tradeCollector.Process() - return nil + + return s.Persistence.Sync(s) } func (s *Strategy) Resume(ctx context.Context) error {