Merge pull request #1161 from c9s/fix/grid2/profit-fixer-init-order-id

FIX: [grid2] add initialOrderID check and try to fix profitStats.Since
This commit is contained in:
Yo-An Lin 2023-04-26 22:33:22 +08:00 committed by GitHub
commit a3f7e29321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,10 +51,15 @@ func (f *ProfitFixer) Fix(ctx context.Context, since, until time.Time, initialOr
continue
}
if profitStats.InitialOrderID == 0 {
if profitStats.InitialOrderID == 0 || order.OrderID < profitStats.InitialOrderID {
profitStats.InitialOrderID = order.OrderID
}
if profitStats.Since == nil || profitStats.Since.IsZero() || order.CreationTime.Time().Before(*profitStats.Since) {
ct := order.CreationTime.Time()
profitStats.Since = &ct
}
if order.Status != types.OrderStatusFilled {
continue
}