xmaker: call TruncateQuantity when the quantity is adjusted

This commit is contained in:
c9s 2021-12-26 15:45:39 +08:00
parent 902e27ede4
commit 65da02af2c

View File

@ -538,6 +538,7 @@ func (s *Strategy) Hedge(ctx context.Context, pos fixedpoint.Value) {
if quote.Available < notional { if quote.Available < notional {
// adjust price to higher 0.1%, so that we can ensure that the order can be executed // adjust price to higher 0.1%, so that we can ensure that the order can be executed
quantity = bbgo.AdjustQuantityByMaxAmount(quantity, fixedpoint.NewFromFloat(lastPrice*1.001), quote.Available) quantity = bbgo.AdjustQuantityByMaxAmount(quantity, fixedpoint.NewFromFloat(lastPrice*1.001), quote.Available)
quantity = s.sourceMarket.TruncateQuantity(quantity)
} }
} }