xmaker: improve dust quantity check

This commit is contained in:
c9s 2024-08-27 15:48:02 +08:00
parent 4af12a7e5d
commit 3819feacf3
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -612,13 +612,8 @@ func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
// truncate quantity for the supported precision // truncate quantity for the supported precision
quantity = s.sourceMarket.TruncateQuantity(quantity) quantity = s.sourceMarket.TruncateQuantity(quantity)
if notional.Compare(s.sourceMarket.MinNotional.Mul(minGap)) <= 0 { if s.sourceMarket.IsDustQuantity(quantity, lastPrice) {
log.Warnf("the adjusted amount %v is less than minimal notional %v, skipping hedge", notional, s.sourceMarket.MinNotional) log.Warnf("skip dust quantity: %s", quantity.String())
return
}
if quantity.Compare(s.sourceMarket.MinQuantity.Mul(minGap)) <= 0 {
log.Warnf("the adjusted quantity %v is less than minimal quantity %v, skipping hedge", quantity, s.sourceMarket.MinQuantity)
return return
} }