xmaker: set profitChanged only when Hedge is called

This commit is contained in:
c9s 2024-08-27 22:45:11 +08:00
parent 652c9b62e8
commit 6011fd5157
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -677,12 +677,6 @@ func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
}
}
notional := quantity.Mul(lastPrice)
if notional.Compare(s.sourceMarket.MinNotional) <= 0 {
log.Warnf("%s %v less than min notional, skipping hedge", s.Symbol, notional)
return
}
// adjust quantity according to the balances
account := s.sourceSession.GetAccount()
switch side {
@ -934,10 +928,9 @@ func (s *Strategy) hedgeWorker(ctx context.Context) {
)
s.Hedge(ctx, uncoverPosition.Neg())
profitChanged = true
}
profitChanged = true
case <-reportTicker.C:
if profitChanged {
if s.reportProfitStatsRateLimiter.Allow() {