From adb96cac39d332e8d0084266ef95d7b79ea2bab3 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 14 Jul 2022 17:38:11 +0800 Subject: [PATCH] pivotshort: check maximum margin leverage --- pkg/strategy/pivotshort/breaklow.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/strategy/pivotshort/breaklow.go b/pkg/strategy/pivotshort/breaklow.go index f029daa6b..d3ee0496b 100644 --- a/pkg/strategy/pivotshort/breaklow.go +++ b/pkg/strategy/pivotshort/breaklow.go @@ -231,6 +231,14 @@ func useQuantityOrBaseBalance(session *bbgo.ExchangeSession, market types.Market baseBalanceValue := baseBalance.Total().Mul(price) accountValue := baseBalanceValue.Add(quoteBalance.Total()) + if session.IsolatedMargin { + originLeverage := leverage + leverage = fixedpoint.Max(leverage, fixedpoint.NewFromInt(10)) + log.Infof("using isolated margin, maxLeverage=10 originalLeverage=%f currentLeverage=%f", + originLeverage.Float64(), + leverage.Float64()) + } + // spot margin use the equity value, so we use the total quote balance here maxPositionQuantity := risk.CalculateMaxPosition(price, accountValue, leverage)