bbgo: fix balance lock issue

This commit is contained in:
c9s 2022-09-11 17:46:23 +08:00
parent ad6f07a40c
commit 7b68e5ee27
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -271,6 +271,11 @@ func (e *GeneralOrderExecutor) ClosePosition(ctx context.Context, percentage fix
return nil
}
// check base balance and adjust the close position order
if baseBalance, ok := e.session.Account.Balance(e.position.Market.BaseCurrency); ok {
submitOrder.Quantity = fixedpoint.Min(submitOrder.Quantity, baseBalance.Available)
}
tagStr := strings.Join(tags, ",")
submitOrder.Tag = tagStr