grid2: check profitStats.Since for the since time range

This commit is contained in:
c9s 2023-04-26 23:34:56 +08:00
parent 2efdee9347
commit f1919a2b43
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -31,14 +31,12 @@ func (f *ProfitFixer) Fix(parent context.Context, since, until time.Time, initia
profitStats.TotalQuoteProfit = fixedpoint.Zero
profitStats.ArbitrageCount = 0
defer log.Infof("profit fix is done")
defer log.Infof("profitFixer: done")
/*
if profitStats.Since != nil && profitStats.Since.Before(since) {
log.Infof("profitStats.since %s is ealier than the given since %s, setting since to %s", profitStats.Since, since, profitStats.Since)
since = *profitStats.Since
}
*/
if profitStats.Since != nil && profitStats.Since.Before(since) {
log.Infof("profitFixer: profitStats.since %s is ealier than the given since %s, setting since to %s", profitStats.Since, since, profitStats.Since)
since = *profitStats.Since
}
ctx, cancel := context.WithTimeout(parent, 15*time.Minute)
defer cancel()
@ -46,6 +44,10 @@ func (f *ProfitFixer) Fix(parent context.Context, since, until time.Time, initia
q := &batch.ClosedOrderBatchQuery{ExchangeTradeHistoryService: f.historyService}
orderC, errC := q.Query(ctx, f.symbol, since, until, initialOrderID)
defer func() {
log.Infof("profitFixer: fixed profitStats=%#v", profitStats)
}()
for {
select {
case <-ctx.Done():
@ -90,7 +92,6 @@ func (f *ProfitFixer) Fix(parent context.Context, since, until time.Time, initia
profitStats.ArbitrageCount++
log.Debugf("profitFixer: filledSellOrder=%#v", order)
log.Debugf("profitFixer: profitStats=%#v", profitStats)
}
}
}