mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 08:15:15 +00:00
Merge pull request #996 from andycheng123/fix/general-order-executor
fix/general-order-executor: do not check for base balance for futures
This commit is contained in:
commit
7dd951e39c
|
@ -230,13 +230,15 @@ func (e *GeneralOrderExecutor) reduceQuantityAndSubmitOrder(ctx context.Context,
|
|||
var err error
|
||||
for i := 0; i < submitOrderRetryLimit; i++ {
|
||||
q := submitOrder.Quantity.Mul(fixedpoint.One.Sub(quantityReduceDelta))
|
||||
if submitOrder.Side == types.SideTypeSell {
|
||||
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 {
|
||||
q = fixedpoint.Min(q, quoteBalance.Available.Div(price))
|
||||
if !e.session.Futures {
|
||||
if submitOrder.Side == types.SideTypeSell {
|
||||
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 {
|
||||
q = fixedpoint.Min(q, quoteBalance.Available.Div(price))
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Warnf("retrying order, adjusting order quantity: %v -> %v", submitOrder.Quantity, q)
|
||||
|
|
Loading…
Reference in New Issue
Block a user