From f1919a2b437346cecbb6f8f5fe96afef70078822 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 26 Apr 2023 23:34:56 +0800 Subject: [PATCH] grid2: check profitStats.Since for the since time range --- pkg/strategy/grid2/profit_fixer.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/strategy/grid2/profit_fixer.go b/pkg/strategy/grid2/profit_fixer.go index 40e41c416..c572a61bb 100644 --- a/pkg/strategy/grid2/profit_fixer.go +++ b/pkg/strategy/grid2/profit_fixer.go @@ -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) } } }