fix persistence unmarshalling issue

This commit is contained in:
c9s 2022-06-05 01:48:56 +08:00
parent 221a2d9dc7
commit c20e3fee4b
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 6 additions and 4 deletions

View File

@ -72,9 +72,6 @@ func iterateFieldsByTag(obj interface{}, tagName string, cb StructFieldIterator)
fv := sv.Field(i)
ft := st.Field(i)
fvt := fv.Type()
_ = fvt
// skip unexported fields
if !st.Field(i).IsExported() {
continue

View File

@ -63,7 +63,8 @@ func (store *RedisStore) Load(val interface{}) error {
return err
}
if len(data) == 0 {
// skip null data
if len(data) == 0 || data == "null" {
return ErrPersistenceNotExists
}

View File

@ -216,6 +216,10 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
s.Position = types.NewPositionFromMarket(s.Market)
}
if s.ProfitStats == nil {
s.ProfitStats = types.NewProfitStats(s.Market)
}
instanceID := s.InstanceID()
// Always update the position fields