types: fix gross profit calculation

This commit is contained in:
c9s 2022-09-15 17:09:32 +08:00
parent 8bfd1f7f30
commit 0ead18a95b
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -194,12 +194,12 @@ func (s *ProfitStats) AddProfit(profit Profit) {
s.TodayPnL = s.TodayPnL.Add(profit.Profit)
s.TodayNetProfit = s.TodayNetProfit.Add(profit.NetProfit)
if profit.Profit.Sign() < 0 {
if profit.Profit.Sign() > 0 {
s.AccumulatedGrossProfit = s.AccumulatedGrossProfit.Add(profit.Profit)
s.TodayGrossProfit = s.TodayGrossProfit.Add(profit.Profit)
} else if profit.Profit.Sign() < 0 {
s.AccumulatedGrossLoss = s.AccumulatedGrossLoss.Add(profit.Profit)
s.TodayGrossLoss = s.TodayGrossLoss.Add(profit.Profit)
} else if profit.Profit.Sign() > 0 {
s.AccumulatedGrossProfit = s.AccumulatedGrossLoss.Add(profit.Profit)
s.TodayGrossProfit = s.TodayGrossProfit.Add(profit.Profit)
}
}