bollmaker: call persistence.Sync when position is changed

This commit is contained in:
c9s 2022-06-03 02:37:56 +08:00
parent 50d7d235a4
commit 7fce6a0fca
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -632,6 +632,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
s.tradeCollector.OnPositionUpdate(func(position *types.Position) {
log.Infof("position changed: %s", s.Position)
s.Notify(s.Position)
if err := s.Persistence.Sync(s); err != nil {
log.WithError(err).Errorf("can not sync state to persistence")
}
})
s.tradeCollector.BindStream(session.UserDataStream)