Fix balance calculation

This commit is contained in:
Larry850806 2021-02-10 21:06:00 +08:00
parent 9f6d9028fa
commit ca31179b40

View File

@ -142,12 +142,12 @@ func (s *Strategy) generateGridBuyOrders(session *bbgo.ExchangeSession) ([]types
Price: price,
TimeInForce: "GTC",
}
quotaQuantity := fixedpoint.NewFromFloat(order.Quantity).MulFloat64(price)
if quoteBalance < quotaQuantity {
quoteQuantity := fixedpoint.NewFromFloat(order.Quantity).MulFloat64(price)
if quoteBalance < quoteQuantity {
log.Infof("quote balance %f is not enough, stop generating buy orders", quoteBalance.Float64())
break
}
quoteBalance = quotaQuantity.Sub(quotaQuantity)
quoteBalance = quoteBalance.Sub(quoteQuantity)
log.Infof("submitting order: %s", order.String())
orders = append(orders, order)
}