Merge pull request #1157 from c9s/fix/load-state

FIX: add context to LoadState
This commit is contained in:
Yo-An Lin 2023-04-25 18:42:16 +08:00 committed by GitHub
commit 152149fcee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 8 deletions

View File

@ -101,7 +101,7 @@ func main() {
return
}
if err := trader.LoadState(); err != nil {
if err := trader.LoadState(ctx); err != nil {
log.WithError(err).Error("failed to load strategy states")
return
}

View File

@ -109,7 +109,7 @@ func main() {
return
}
if err := trader.LoadState(); err != nil {
if err := trader.LoadState(ctx); err != nil {
log.WithError(err).Error("failed to load strategy states")
return
}

View File

@ -365,16 +365,14 @@ func (trader *Trader) Run(ctx context.Context) error {
return trader.environment.Connect(ctx)
}
func (trader *Trader) LoadState() error {
func (trader *Trader) LoadState(ctx context.Context) error {
if trader.environment.BacktestService != nil {
return nil
}
if persistenceServiceFacade == nil {
return nil
}
isolation := GetIsolationFromContext(ctx)
ps := persistenceServiceFacade.Get()
ps := isolation.persistenceServiceFacade.Get()
log.Infof("loading strategies states...")

View File

@ -163,7 +163,7 @@ func runConfig(basectx context.Context, cmd *cobra.Command, userConfig *bbgo.Con
return err
}
if err := trader.LoadState(); err != nil {
if err := trader.LoadState(tradingCtx); err != nil {
return err
}