add more logs to profitFixer

This commit is contained in:
c9s 2024-03-06 17:47:18 +08:00
parent be89292cbb
commit 188231e2fb
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 13 additions and 2 deletions

View File

@ -47,6 +47,7 @@ func (f *ProfitFixer) batchQueryTrades(
}
func (f *ProfitFixer) Fix(ctx context.Context, since, until time.Time, stats *types.ProfitStats, position *types.Position) error {
log.Infof("starting profitFixer with time range %s <=> %s", since, until)
var mu sync.Mutex
var allTrades = make([]types.Trade, 0, 1000)
@ -80,5 +81,6 @@ func (f *ProfitFixer) Fix(ctx context.Context, since, until time.Time, stats *ty
position.AddTrade(trade)
}
log.Infof("profitFixer done: profitStats and position are updated from %d trades", len(allTrades))
return nil
}

View File

@ -320,6 +320,8 @@ func (s *Strategy) CrossRun(
log.Infof("makerSession: %s hedgeSession: %s", makerSession.Name, hedgeSession.Name)
if s.ProfitFixerConfig != nil {
log.Infof("profitFixer is enabled, checking checkpoint: %+v", s.ProfitFixerConfig.TradesSince)
if s.ProfitFixerConfig.TradesSince.Time().IsZero() {
return errors.New("tradesSince time can not be zero")
}
@ -329,8 +331,15 @@ func (s *Strategy) CrossRun(
s.CrossExchangeMarketMakingStrategy.ProfitStats = types.NewProfitStats(makerMarket)
fixer := NewProfitFixer(makerMarket)
fixer.AddExchange(makerSession.Name, makerSession.Exchange.(types.ExchangeTradeHistoryService))
fixer.AddExchange(hedgeSession.Name, hedgeSession.Exchange.(types.ExchangeTradeHistoryService))
if ss, ok := makerSession.Exchange.(types.ExchangeTradeHistoryService); ok {
log.Infof("adding makerSession %s to profitFixer", makerSession.Name)
fixer.AddExchange(makerSession.Name, ss)
}
if ss, ok := hedgeSession.Exchange.(types.ExchangeTradeHistoryService); ok {
log.Infof("adding hedgeSession %s to profitFixer", hedgeSession.Name)
fixer.AddExchange(hedgeSession.Name, ss)
}
if err2 := fixer.Fix(ctx, s.ProfitFixerConfig.TradesSince.Time(), time.Now(), s.CrossExchangeMarketMakingStrategy.ProfitStats, s.CrossExchangeMarketMakingStrategy.Position); err2 != nil {
return err2