bbgo: assign strategy instance id fields automatically

This commit is contained in:
c9s 2022-03-11 16:24:29 +08:00
parent 6088f7b542
commit 08ae53ba16

View File

@ -587,6 +587,14 @@ func (environ *Environment) RecordPosition(position *types.Position, trade types
return 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 { if err := environ.PositionService.Insert(position, trade, profit.Profit); err != nil {
log.WithError(err).Errorf("can not insert position record") log.WithError(err).Errorf("can not insert position record")
} }