xmaker: improve if condition

This commit is contained in:
c9s 2024-10-15 18:45:16 +08:00
parent 59862303aa
commit 1210a79fc7
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -1467,18 +1467,21 @@ func (s *Strategy) hedgeWorker(ctx context.Context) {
coveredPosition := s.CoveredPosition.Get()
uncoverPosition := position.Sub(coveredPosition)
absPos := uncoverPosition.Abs()
if !s.DisableHedge && absPos.Compare(s.sourceMarket.MinQuantity) > 0 {
s.logger.Infof("%s base position %v coveredPosition: %v uncoverPosition: %v",
s.Symbol,
position,
coveredPosition,
uncoverPosition,
)
s.Hedge(ctx, uncoverPosition.Neg())
profitChanged = true
if !s.DisableHedge {
continue
}
s.logger.Infof("%s base position %v coveredPosition: %v uncoverPosition: %v",
s.Symbol,
position,
coveredPosition,
uncoverPosition,
)
s.Hedge(ctx, uncoverPosition.Neg())
profitChanged = true
case <-reportTicker.C:
if profitChanged {
if s.reportProfitStatsRateLimiter.Allow() {