xdepthmaker: fix stats fixer

This commit is contained in:
c9s 2024-03-06 18:12:24 +08:00
parent 441ebbdbe5
commit b6ddb49d0a
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -77,8 +77,11 @@ func (f *ProfitFixer) Fix(ctx context.Context, since, until time.Time, stats *ty
allTrades = types.SortTradesAscending(allTrades)
for _, trade := range allTrades {
stats.AddTrade(trade)
position.AddTrade(trade)
profit, netProfit, madeProfit := position.AddTrade(trade)
if madeProfit {
p := position.NewProfit(trade, profit, netProfit)
stats.AddProfit(p)
}
}
log.Infof("profitFixer done: profitStats and position are updated from %d trades", len(allTrades))