From 2f261dd0a5e2206115293a267aebc404b68d74db Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 20 Nov 2024 13:44:06 +0800 Subject: [PATCH] xmaker: add MaxQuoteUsageRatio option --- pkg/strategy/xmaker/strategy.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/xmaker/strategy.go b/pkg/strategy/xmaker/strategy.go index b57ab3d70..14c4723dc 100644 --- a/pkg/strategy/xmaker/strategy.go +++ b/pkg/strategy/xmaker/strategy.go @@ -179,6 +179,8 @@ type Strategy struct { RecoverTradeScanPeriod types.Duration `json:"recoverTradeScanPeriod"` + MaxQuoteUsageRatio fixedpoint.Value `json:"maxQuoteUsageRatio"` + NumLayers int `json:"numLayers"` // Pips is the pips of the layer prices @@ -696,7 +698,14 @@ func (s *Strategy) updateQuote(ctx context.Context) error { if b, ok := makerBalances[s.makerMarket.QuoteCurrency]; ok { if b.Available.Compare(s.makerMarket.MinNotional) > 0 { - makerQuota.QuoteAsset.Add(b.Available) + if s.MaxQuoteUsageRatio.Sign() > 0 { + quoteAvailable := b.Available.Mul(s.MaxQuoteUsageRatio) + makerQuota.QuoteAsset.Add(quoteAvailable) + } else { + // use all quote balances as much as possible + makerQuota.QuoteAsset.Add(b.Available) + } + } else { disableMakerBid = true s.logger.Infof("%s maker bid disabled: insufficient quote balance %s", s.Symbol, b.String())