xfunding: always sync funding fee

This commit is contained in:
c9s 2023-07-06 16:02:37 +08:00
parent dc16e0c299
commit f9eba64816
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -350,9 +350,7 @@ func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.Order
bbgo.Notify("Neutral Position", s.NeutralPosition)
// sync funding fee txns
if !s.ProfitStats.LastFundingFeeTime.IsZero() {
s.syncFundingFeeRecords(ctx, s.ProfitStats.LastFundingFeeTime)
}
s.syncFundingFeeRecords(ctx, s.ProfitStats.LastFundingFeeTime)
// TEST CODE:
// s.syncFundingFeeRecords(ctx, time.Now().Add(-3*24*time.Hour))
@ -538,6 +536,10 @@ func (s *Strategy) handleAccountUpdate(ctx context.Context, e *binance.AccountUp
func (s *Strategy) syncFundingFeeRecords(ctx context.Context, since time.Time) {
now := time.Now()
if since.IsZero() {
since = now.AddDate(0, -3, 0)
}
log.Infof("syncing funding fee records from the income history query: %s <=> %s", since, now)
defer log.Infof("sync funding fee records done")