mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
ignore service.ErrPersistenceNotExists error
This commit is contained in:
parent
57a9647401
commit
57c43936d6
|
@ -136,6 +136,10 @@ func loadPersistenceFields(obj interface{}, id string, persistence service.Persi
|
||||||
// inf := value.Interface()
|
// inf := value.Interface()
|
||||||
store := persistence.NewStore(id, tag)
|
store := persistence.NewStore(id, tag)
|
||||||
if err := store.Load(&newValueInf); err != nil {
|
if err := store.Load(&newValueInf); err != nil {
|
||||||
|
if err == service.ErrPersistenceNotExists {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,10 @@ func (trader *Trader) RunSingleExchangeStrategy(ctx context.Context, strategy Si
|
||||||
// 1) scan the struct fields and find the persistence field
|
// 1) scan the struct fields and find the persistence field
|
||||||
// 2) load the data and set the value into the persistence field.
|
// 2) load the data and set the value into the persistence field.
|
||||||
|
|
||||||
_ = trader.environment.PersistenceServiceFacade
|
ps := trader.environment.PersistenceServiceFacade.Get()
|
||||||
|
if err := loadPersistenceFields(strategy, strategy.ID(), ps); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return strategy.Run(ctx, orderExecutor, session)
|
return strategy.Run(ctx, orderExecutor, session)
|
||||||
}
|
}
|
||||||
|
@ -319,6 +322,7 @@ func (trader *Trader) Run(ctx context.Context) error {
|
||||||
router.executors[sessionID] = orderExecutor
|
router.executors[sessionID] = orderExecutor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ps := trader.environment.PersistenceServiceFacade.Get()
|
||||||
for _, strategy := range trader.crossExchangeStrategies {
|
for _, strategy := range trader.crossExchangeStrategies {
|
||||||
rs := reflect.ValueOf(strategy)
|
rs := reflect.ValueOf(strategy)
|
||||||
|
|
||||||
|
@ -332,6 +336,10 @@ func (trader *Trader) Run(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := loadPersistenceFields(strategy, strategy.ID(), ps); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := strategy.CrossRun(ctx, router, trader.environment.sessions); err != nil {
|
if err := strategy.CrossRun(ctx, router, trader.environment.sessions); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user