bbgo: add profit service to environment

This commit is contained in:
c9s 2022-03-05 13:40:20 +08:00
parent 1f1c26a9e5
commit 35b0d8dc0d

View File

@ -76,6 +76,7 @@ type Environment struct {
DatabaseService *service.DatabaseService DatabaseService *service.DatabaseService
OrderService *service.OrderService OrderService *service.OrderService
TradeService *service.TradeService TradeService *service.TradeService
ProfitService *service.ProfitService
BacktestService *service.BacktestService BacktestService *service.BacktestService
RewardService *service.RewardService RewardService *service.RewardService
SyncService *service.SyncService SyncService *service.SyncService
@ -170,6 +171,7 @@ func (environ *Environment) ConfigureDatabaseDriver(ctx context.Context, driver
environ.TradeService = &service.TradeService{DB: db} environ.TradeService = &service.TradeService{DB: db}
environ.RewardService = &service.RewardService{DB: db} environ.RewardService = &service.RewardService{DB: db}
environ.AccountService = &service.AccountService{DB: db} environ.AccountService = &service.AccountService{DB: db}
environ.ProfitService = &service.ProfitService{DB: db}
environ.SyncService = &service.SyncService{ environ.SyncService = &service.SyncService{
TradeService: environ.TradeService, TradeService: environ.TradeService,
@ -569,6 +571,17 @@ func (environ *Environment) Sync(ctx context.Context, userConfig ...*Config) err
return nil return nil
} }
func (environ *Environment) RecordProfit(strategyID, strategyInstanceID string, profit types.Profit) {
if environ.DatabaseService == nil {
return
}
if environ.ProfitService == nil {
return
}
}
func (environ *Environment) SyncSession(ctx context.Context, session *ExchangeSession, defaultSymbols ...string) error { func (environ *Environment) SyncSession(ctx context.Context, session *ExchangeSession, defaultSymbols ...string) error {
if environ.SyncService == nil { if environ.SyncService == nil {
return nil return nil