mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 08:15:15 +00:00
fix: inequality on quantites of balances and submitted orders in backtest
This commit is contained in:
parent
2720ee90b1
commit
f7398f163a
|
@ -148,11 +148,13 @@ func (m *SimplePriceMatching) PlaceOrder(o types.SubmitOrder) (*types.Order, *ty
|
|||
price = o.Price
|
||||
}
|
||||
|
||||
o.Quantity = m.Market.TruncateQuantity(o.Quantity)
|
||||
|
||||
if o.Quantity.Compare(m.Market.MinQuantity) < 0 {
|
||||
return nil, nil, fmt.Errorf("order quantity %s is less than minQuantity %s, order: %+v", o.Quantity.String(), m.Market.MinQuantity.String(), o)
|
||||
}
|
||||
|
||||
quoteQuantity := o.Quantity.Mul(price)
|
||||
quoteQuantity := m.Market.TruncateQuantity(o.Quantity.Mul(price))
|
||||
if quoteQuantity.Compare(m.Market.MinNotional) < 0 {
|
||||
return nil, nil, fmt.Errorf("order amount %s is less than minNotional %s, order: %+v", quoteQuantity.String(), m.Market.MinNotional.String(), o)
|
||||
}
|
||||
|
@ -297,7 +299,7 @@ func (m *SimplePriceMatching) newTradeFromOrder(order *types.Order, isMaker bool
|
|||
// BINANCE uses 0.1% for both maker and taker
|
||||
// MAX uses 0.050% for maker and 0.15% for taker
|
||||
var feeRate = m.getFeeRate(isMaker)
|
||||
var quoteQuantity = order.Quantity.Mul(price)
|
||||
var quoteQuantity = m.Market.TruncateQuantity(order.Quantity.Mul(price))
|
||||
var fee fixedpoint.Value
|
||||
var feeCurrency string
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ func (a *Account) UseLockedBalance(currency string, fund fixedpoint.Value) error
|
|||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("trying to use more than locked: locked %v < want to use %v", balance.Locked, fund)
|
||||
return fmt.Errorf("trying to use more than locked: locked %v < want to use %v diff %v", balance.Locked, fund, balance.Locked.Sub(fund))
|
||||
}
|
||||
|
||||
var QuantityDelta = fixedpoint.MustNewFromString("0.00000000001")
|
||||
|
|
Loading…
Reference in New Issue
Block a user