fix/general-order-executor: do not check for base balance for futures orders in reduceQuantityAndSubmitOrder()

This commit is contained in:
Andy Cheng 2022-10-18 18:59:04 +08:00
parent 79c93e9a0f
commit 06c95a4735

View File

@ -230,13 +230,15 @@ func (e *GeneralOrderExecutor) reduceQuantityAndSubmitOrder(ctx context.Context,
var err error var err error
for i := 0; i < submitOrderRetryLimit; i++ { for i := 0; i < submitOrderRetryLimit; i++ {
q := submitOrder.Quantity.Mul(fixedpoint.One.Sub(quantityReduceDelta)) q := submitOrder.Quantity.Mul(fixedpoint.One.Sub(quantityReduceDelta))
if submitOrder.Side == types.SideTypeSell { if !e.session.Futures {
if baseBalance, ok := e.session.GetAccount().Balance(e.position.Market.BaseCurrency); ok { if submitOrder.Side == types.SideTypeSell {
q = fixedpoint.Min(q, baseBalance.Available) if baseBalance, ok := e.session.GetAccount().Balance(e.position.Market.BaseCurrency); ok {
} q = fixedpoint.Min(q, baseBalance.Available)
} else { }
if quoteBalance, ok := e.session.GetAccount().Balance(e.position.Market.QuoteCurrency); ok { } else {
q = fixedpoint.Min(q, quoteBalance.Available.Div(price)) if quoteBalance, ok := e.session.GetAccount().Balance(e.position.Market.QuoteCurrency); ok {
q = fixedpoint.Min(q, quoteBalance.Available.Div(price))
}
} }
} }
log.Warnf("retrying order, adjusting order quantity: %v -> %v", submitOrder.Quantity, q) log.Warnf("retrying order, adjusting order quantity: %v -> %v", submitOrder.Quantity, q)