diff --git a/pkg/bbgo/bootstrap.go b/pkg/bbgo/bootstrap.go index 717b1447a..78ec8eaeb 100644 --- a/pkg/bbgo/bootstrap.go +++ b/pkg/bbgo/bootstrap.go @@ -19,7 +19,7 @@ func BootstrapEnvironmentLightweight(ctx context.Context, environ *Environment, } if userConfig.Persistence != nil { - if err := ConfigurePersistence(ctx, userConfig.Persistence); err != nil { + if err := ConfigurePersistence(ctx, environ, userConfig.Persistence); err != nil { return errors.Wrap(err, "persistence configure error") } } @@ -41,7 +41,7 @@ func BootstrapEnvironment(ctx context.Context, environ *Environment, userConfig } if userConfig.Persistence != nil { - if err := ConfigurePersistence(ctx, userConfig.Persistence); err != nil { + if err := ConfigurePersistence(ctx, environ, userConfig.Persistence); err != nil { return errors.Wrap(err, "persistence configure error") } } @@ -55,4 +55,4 @@ func BootstrapEnvironment(ctx context.Context, environ *Environment, userConfig func BootstrapBacktestEnvironment(ctx context.Context, environ *Environment) error { return environ.ConfigureDatabase(ctx) -} +} \ No newline at end of file diff --git a/pkg/bbgo/environment.go b/pkg/bbgo/environment.go index ba41a051e..d35e12596 100644 --- a/pkg/bbgo/environment.go +++ b/pkg/bbgo/environment.go @@ -78,18 +78,19 @@ const ( // Environment presents the real exchange data layer type Environment struct { - DatabaseService *service.DatabaseService - OrderService *service.OrderService - TradeService *service.TradeService - ProfitService *service.ProfitService - PositionService *service.PositionService - BacktestService *service.BacktestService - RewardService *service.RewardService - MarginService *service.MarginService - SyncService *service.SyncService - AccountService *service.AccountService - WithdrawService *service.WithdrawService - DepositService *service.DepositService + DatabaseService *service.DatabaseService + OrderService *service.OrderService + TradeService *service.TradeService + ProfitService *service.ProfitService + PositionService *service.PositionService + BacktestService *service.BacktestService + RewardService *service.RewardService + MarginService *service.MarginService + SyncService *service.SyncService + AccountService *service.AccountService + WithdrawService *service.WithdrawService + DepositService *service.DepositService + PersistentService *service.PersistenceServiceFacade // startTime is the time of start point (which is used in the backtest) startTime time.Time @@ -984,4 +985,4 @@ func (session *ExchangeSession) getSessionSymbols(defaultSymbols ...string) ([]s } return session.FindPossibleSymbols() -} +} \ No newline at end of file diff --git a/pkg/bbgo/persistence.go b/pkg/bbgo/persistence.go index e87fd92a7..bbc7c75b4 100644 --- a/pkg/bbgo/persistence.go +++ b/pkg/bbgo/persistence.go @@ -102,7 +102,7 @@ func NewPersistenceServiceFacade(conf *PersistenceConfig) (*service.PersistenceS return facade, nil } -func ConfigurePersistence(ctx context.Context, conf *PersistenceConfig) error { +func ConfigurePersistence(ctx context.Context, environ *Environment, conf *PersistenceConfig) error { facade, err := NewPersistenceServiceFacade(conf) if err != nil { return err @@ -112,5 +112,6 @@ func ConfigurePersistence(ctx context.Context, conf *PersistenceConfig) error { isolation.persistenceServiceFacade = facade persistenceServiceFacade = facade + environ.PersistentService = facade return nil -} +} \ No newline at end of file diff --git a/pkg/strategy/grid2/strategy.go b/pkg/strategy/grid2/strategy.go index a7945acef..1f356d23e 100644 --- a/pkg/strategy/grid2/strategy.go +++ b/pkg/strategy/grid2/strategy.go @@ -1791,4 +1791,4 @@ func (s *Strategy) openOrdersMismatches(ctx context.Context, session *bbgo.Excha func roundUpMarketQuantity(market types.Market, v fixedpoint.Value) fixedpoint.Value { return v.Round(market.VolumePrecision, fixedpoint.Up) -} +} \ No newline at end of file