xfunding: fix balance check

This commit is contained in:
c9s 2023-06-16 17:41:47 +08:00
parent 017278826b
commit a766d88d60
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -866,11 +866,13 @@ func (s *Strategy) syncSpotPosition(ctx context.Context) {
orderPrice := ticker.Sell
orderQuantity := diffQuantity
b, ok := s.spotSession.Account.Balance(s.spotMarket.BaseCurrency)
if ok {
orderQuantity = fixedpoint.Min(b.Available, orderQuantity)
if !ok {
log.Warnf("%s balance not found, can not sync spot position", s.spotMarket.BaseCurrency)
return
}
orderQuantity = fixedpoint.Min(b.Available, orderQuantity)
// avoid increase the order size
if s.spotMarket.IsDustQuantity(orderQuantity, orderPrice) {
log.Infof("skip spot order with dust quantity %s, market=%+v balance=%+v", orderQuantity.String(), s.spotMarket, b)