xmaker: profit object can be nil

This commit is contained in:
c9s 2024-08-26 18:35:10 +08:00
parent f96e0d6552
commit 7367ea73b8
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -929,14 +929,16 @@ func (s *Strategy) CrossRun(
}) })
s.tradeCollector.OnProfit(func(trade types.Trade, profit *types.Profit) { s.tradeCollector.OnProfit(func(trade types.Trade, profit *types.Profit) {
if s.CircuitBreaker != nil { if profit != nil {
s.CircuitBreaker.RecordProfit(profit.Profit, trade.Time.Time()) if s.CircuitBreaker != nil {
s.CircuitBreaker.RecordProfit(profit.Profit, trade.Time.Time())
}
bbgo.Notify(profit)
s.ProfitStats.AddProfit(*profit)
s.Environment.RecordPosition(s.Position, trade, profit)
} }
bbgo.Notify(profit)
s.ProfitStats.AddProfit(*profit)
s.Environment.RecordPosition(s.Position, trade, profit)
}) })
s.tradeCollector.OnPositionUpdate(func(position *types.Position) { s.tradeCollector.OnPositionUpdate(func(position *types.Position) {