mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
add more logs to profitFixer
This commit is contained in:
parent
be89292cbb
commit
188231e2fb
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user