xmaker: adjust credit buffer algo

This commit is contained in:
c9s 2024-08-28 16:37:39 +08:00
parent 1d6282a10b
commit 77b7b29739
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -402,14 +402,14 @@ func (s *Strategy) updateQuote(ctx context.Context) {
if quote, ok := hedgeAccount.Balance(s.sourceMarket.QuoteCurrency); ok {
netQuote := quote.Net()
if netQuote.Sign() > 0 {
hedgeQuota.BaseAsset.Add(netQuote.Mul(creditBufferRatio).Div(bestBid.Price))
hedgeQuota.QuoteAsset.Add(netQuote.Mul(creditBufferRatio))
}
}
if base, ok := hedgeAccount.Balance(s.sourceMarket.BaseCurrency); ok {
netBase := base.Net()
if netBase.Sign() > 0 {
hedgeQuota.QuoteAsset.Add(netBase.Mul(creditBufferRatio).Mul(bestAsk.Price))
hedgeQuota.BaseAsset.Add(netBase.Mul(creditBufferRatio))
}
}
// netValueInUsd, err := s.accountValueCalculator.NetValue(ctx)