mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 19:13:52 +00:00
xmaker: improve if condition
This commit is contained in:
parent
59862303aa
commit
1210a79fc7
|
@ -1467,18 +1467,21 @@ func (s *Strategy) hedgeWorker(ctx context.Context) {
|
||||||
coveredPosition := s.CoveredPosition.Get()
|
coveredPosition := s.CoveredPosition.Get()
|
||||||
uncoverPosition := position.Sub(coveredPosition)
|
uncoverPosition := position.Sub(coveredPosition)
|
||||||
absPos := uncoverPosition.Abs()
|
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())
|
if !s.DisableHedge {
|
||||||
profitChanged = true
|
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:
|
case <-reportTicker.C:
|
||||||
if profitChanged {
|
if profitChanged {
|
||||||
if s.reportProfitStatsRateLimiter.Allow() {
|
if s.reportProfitStatsRateLimiter.Allow() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user