diff --git a/pkg/bbgo/environment.go b/pkg/bbgo/environment.go index c4996af06..981a059f0 100644 --- a/pkg/bbgo/environment.go +++ b/pkg/bbgo/environment.go @@ -587,6 +587,14 @@ func (environ *Environment) RecordPosition(position *types.Position, trade types return } + if position.Strategy == "" && profit.Strategy != "" { + position.Strategy = profit.Strategy + } + + if position.StrategyInstanceID == "" && profit.StrategyInstanceID != "" { + position.StrategyInstanceID = profit.StrategyInstanceID + } + if err := environ.PositionService.Insert(position, trade, profit.Profit); err != nil { log.WithError(err).Errorf("can not insert position record") }