diff --git a/pkg/strategy/xmaker/strategy.go b/pkg/strategy/xmaker/strategy.go index 4449e519c..3c43bec9c 100644 --- a/pkg/strategy/xmaker/strategy.go +++ b/pkg/strategy/xmaker/strategy.go @@ -929,14 +929,16 @@ func (s *Strategy) CrossRun( }) s.tradeCollector.OnProfit(func(trade types.Trade, profit *types.Profit) { - if s.CircuitBreaker != nil { - s.CircuitBreaker.RecordProfit(profit.Profit, trade.Time.Time()) + if profit != nil { + 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) {