Merge pull request #1409 from c9s/edwin/bybit/pint-log

CHORE: [bybit] print fee rate log
This commit is contained in:
bailantaotao 2023-11-13 12:28:55 +08:00 committed by GitHub
commit 594ad89c67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,8 @@ import (
"sync" "sync"
"time" "time"
"golang.org/x/time/rate"
"github.com/c9s/bbgo/pkg/exchange/bybit/bybitapi" "github.com/c9s/bbgo/pkg/exchange/bybit/bybitapi"
) )
@ -15,6 +17,10 @@ const (
feeRatePollingPeriod = time.Minute feeRatePollingPeriod = time.Minute
) )
var (
pollFeeRateRateLimiter = rate.NewLimiter(rate.Every(10*time.Minute), 1)
)
type symbolFeeDetail struct { type symbolFeeDetail struct {
bybitapi.FeeRate bybitapi.FeeRate
@ -78,6 +84,10 @@ func (p *feeRatePoller) poll(ctx context.Context) error {
p.symbolFeeDetail = symbolFeeRate p.symbolFeeDetail = symbolFeeRate
p.mu.Unlock() p.mu.Unlock()
if pollFeeRateRateLimiter.Allow() {
log.Infof("updated fee rate: %+v", p.symbolFeeDetail)
}
return nil return nil
} }