xmaker: calculate maximum leveraged account value

This commit is contained in:
c9s 2024-09-01 01:31:50 +08:00 committed by lychiyu
parent f864974efe
commit ace8466acb

View File

@ -532,6 +532,11 @@ func (s *Strategy) updateQuote(ctx context.Context) {
// calculate credit buffer
s.logger.Infof("hedge account net value in usd: %f", netValueInUsd.Float64())
maximumHedgeAccountLeverage := fixedpoint.NewFromFloat(1.2)
netValueInUsd = netValueInUsd.Mul(maximumHedgeAccountLeverage)
s.logger.Infof("hedge account maximum leveraged value in usd: %f", netValueInUsd.Float64())
if quote, ok := hedgeAccount.Balance(s.sourceMarket.QuoteCurrency); ok {
debt := quote.Debt()
quota := netValueInUsd.Sub(debt)