xfunding: adjust quote investment according to the fee rate

This commit is contained in:
c9s 2023-03-23 00:56:28 +08:00
parent 6848e11e8a
commit 6ca85b175a
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -196,7 +196,10 @@ func (s *Strategy) CrossRun(ctx context.Context, orderExecutionRouter bbgo.Order
// adjust QuoteInvestment
if b, ok := s.spotSession.Account.Balance(s.spotMarket.QuoteCurrency); ok {
originalQuoteInvestment := s.QuoteInvestment
s.QuoteInvestment = fixedpoint.Min(b.Available, s.QuoteInvestment)
// adjust available quote with the fee rate
available := b.Available.Mul(fixedpoint.NewFromFloat(1.0 - (0.01 * 0.075)))
s.QuoteInvestment = fixedpoint.Min(available, s.QuoteInvestment)
if originalQuoteInvestment.Compare(s.QuoteInvestment) != 0 {
log.Infof("adjusted quoteInvestment from %s to %s according to the balance",