mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xfunding: always transfer balance out when reducing the futures position
This commit is contained in:
parent
c818f79932
commit
5d0bdd19e3
|
@ -635,6 +635,17 @@ func (s *Strategy) reduceFuturesPosition(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spotBase := s.SpotPosition.GetBase()
|
||||||
|
if !s.spotMarket.IsDustQuantity(spotBase, s.SpotPosition.AverageCost) {
|
||||||
|
if balance, ok := s.futuresSession.Account.Balance(s.futuresMarket.BaseCurrency); ok && balance.Available.Sign() > 0 {
|
||||||
|
if err := backoff.RetryGeneral(ctx, func() error {
|
||||||
|
return s.transferOut(ctx, s.binanceSpot, s.spotMarket.BaseCurrency, balance.Available)
|
||||||
|
}); err != nil {
|
||||||
|
log.WithError(err).Errorf("spot-to-futures transfer in retry failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if futuresBase.Compare(fixedpoint.Zero) < 0 {
|
if futuresBase.Compare(fixedpoint.Zero) < 0 {
|
||||||
orderPrice := ticker.Buy
|
orderPrice := ticker.Buy
|
||||||
orderQuantity := futuresBase.Abs()
|
orderQuantity := futuresBase.Abs()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user