From d350806cdc40e9f86fa38124b858e9a36ed565cc Mon Sep 17 00:00:00 2001 From: Andy Cheng Date: Mon, 17 Oct 2022 12:07:58 +0800 Subject: [PATCH] fix/risk: remove balance check in the futures part of CalculateBaseQuantity() --- pkg/bbgo/risk.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkg/bbgo/risk.go b/pkg/bbgo/risk.go index 8648424d9..eb9230dd0 100644 --- a/pkg/bbgo/risk.go +++ b/pkg/bbgo/risk.go @@ -227,7 +227,6 @@ func CalculateBaseQuantity(session *ExchangeSession, market types.Market, price, } baseBalance, hasBaseBalance := session.Account.Balance(market.BaseCurrency) - quoteBalance, _ := session.Account.Balance(market.QuoteCurrency) balances := session.Account.Balances() usingLeverage := session.Margin || session.IsolatedMargin || session.Futures || session.IsolatedFutures @@ -321,12 +320,7 @@ func CalculateBaseQuantity(session *ExchangeSession, market types.Market, price, } if session.Futures || session.IsolatedFutures { - // TODO: get mark price here maxPositionQuantity := risk.CalculateMaxPosition(price, totalUsdValue, leverage) - requiredPositionCost := risk.CalculatePositionCost(price, price, maxPositionQuantity, leverage, types.SideTypeSell) - if quoteBalance.Available.Compare(requiredPositionCost) < 0 { - return maxPositionQuantity, fmt.Errorf("margin total usd value %f is not enough, can not submit order", totalUsdValue.Float64()) - } return maxPositionQuantity, nil }