mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
bbgo: assign strategy instance id fields automatically
This commit is contained in:
parent
6088f7b542
commit
08ae53ba16
|
@ -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")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user