mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
Merge pull request #1075 from c9s/bhwu/add-persistence-to-env
FEATURE: add persistence service to environment
This commit is contained in:
commit
8039068d51
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user