mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-24 15:55:14 +00:00
bbgo: add context to LoadState
This commit is contained in:
parent
45a27ffe06
commit
a9b0270390
|
@ -101,7 +101,7 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := trader.LoadState(); err != nil {
|
if err := trader.LoadState(ctx); err != nil {
|
||||||
log.WithError(err).Error("failed to load strategy states")
|
log.WithError(err).Error("failed to load strategy states")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := trader.LoadState(); err != nil {
|
if err := trader.LoadState(ctx); err != nil {
|
||||||
log.WithError(err).Error("failed to load strategy states")
|
log.WithError(err).Error("failed to load strategy states")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,16 +365,14 @@ func (trader *Trader) Run(ctx context.Context) error {
|
||||||
return trader.environment.Connect(ctx)
|
return trader.environment.Connect(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (trader *Trader) LoadState() error {
|
func (trader *Trader) LoadState(ctx context.Context) error {
|
||||||
if trader.environment.BacktestService != nil {
|
if trader.environment.BacktestService != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if persistenceServiceFacade == nil {
|
isolation := GetIsolationFromContext(ctx)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ps := persistenceServiceFacade.Get()
|
ps := isolation.persistenceServiceFacade.Get()
|
||||||
|
|
||||||
log.Infof("loading strategies states...")
|
log.Infof("loading strategies states...")
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ func runConfig(basectx context.Context, cmd *cobra.Command, userConfig *bbgo.Con
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := trader.LoadState(); err != nil {
|
if err := trader.LoadState(tradingCtx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user