fix profit pointer check

This commit is contained in:
c9s 2022-06-13 10:33:28 +08:00
parent 8cf57cae29
commit 28666d4e98
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -718,6 +718,8 @@ func (environ *Environment) RecordPosition(position *types.Position, trade types
return
}
// set profit info to position
if profit != nil {
if position.Strategy == "" && profit.Strategy != "" {
position.Strategy = profit.Strategy
}
@ -725,6 +727,7 @@ func (environ *Environment) RecordPosition(position *types.Position, trade types
if position.StrategyInstanceID == "" && profit.StrategyInstanceID != "" {
position.StrategyInstanceID = profit.StrategyInstanceID
}
}
if profit != nil {
if err := environ.PositionService.Insert(position, trade, profit.Profit); err != nil {