grid2: add more log

This commit is contained in:
c9s 2023-04-26 23:07:01 +08:00
parent df236e4342
commit bd5e98e543
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 16 additions and 1 deletions

View File

@ -27,9 +27,19 @@ func newProfitFixer(grid *Grid, symbol string, historyService types.ExchangeTrad
// Fix fixes the total quote profit of the given grid
func (f *ProfitFixer) Fix(ctx context.Context, since, until time.Time, initialOrderID uint64, profitStats *GridProfitStats) error {
// reset profit
profitStats.TotalQuoteProfit = fixedpoint.Zero
profitStats.ArbitrageCount = 0
defer log.Infof("profit fix is 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
}
*/
q := &batch.ClosedOrderBatchQuery{ExchangeTradeHistoryService: f.historyService}
orderC, errC := q.Query(ctx, f.symbol, since, until, initialOrderID)

View File

@ -82,7 +82,12 @@ func (s *Strategy) recoverByScanningTrades(ctx context.Context, session *bbgo.Ex
fixer := newProfitFixer(s.grid, s.Symbol, historyService)
// set initial order ID = 0 instead of s.GridProfitStats.InitialOrderID because the order ID could be incorrect
return fixer.Fix(ctx, since, until, 0, s.GridProfitStats)
err := fixer.Fix(ctx, since, until, 0, s.GridProfitStats)
if err != nil {
return err
}
s.logger.Infof("fixed profitStats: %#v", s.GridProfitStats)
}
return nil