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,6 +929,7 @@ func (s *Strategy) CrossRun(
})
s.tradeCollector.OnProfit(func(trade types.Trade, profit *types.Profit) {
if profit != nil {
if s.CircuitBreaker != nil {
s.CircuitBreaker.RecordProfit(profit.Profit, trade.Time.Time())
}
@ -937,6 +938,7 @@ func (s *Strategy) CrossRun(
s.ProfitStats.AddProfit(*profit)
s.Environment.RecordPosition(s.Position, trade, profit)
}
})
s.tradeCollector.OnPositionUpdate(func(position *types.Position) {