From b5beadceb4ddad4ba66c361aa5c693952a19e9ef Mon Sep 17 00:00:00 2001 From: Andy Cheng Date: Tue, 16 Aug 2022 15:06:13 +0800 Subject: [PATCH] exhange/binance: exclude unrealized pnl from balance calculation --- pkg/exchange/binance/exchange.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/exchange/binance/exchange.go b/pkg/exchange/binance/exchange.go index 03a0506ef..76535c9bd 100644 --- a/pkg/exchange/binance/exchange.go +++ b/pkg/exchange/binance/exchange.go @@ -651,10 +651,11 @@ func (e *Exchange) QueryFuturesAccount(ctx context.Context) (*types.Account, err for _, b := range accountBalances { balanceAvailable := fixedpoint.Must(fixedpoint.NewFromString(b.AvailableBalance)) balanceTotal := fixedpoint.Must(fixedpoint.NewFromString(b.Balance)) + unrealizedPnl := fixedpoint.Must(fixedpoint.NewFromString(b.CrossUnPnl)) balances[b.Asset] = types.Balance{ Currency: b.Asset, Available: balanceAvailable, - Locked: balanceTotal.Sub(balanceAvailable), + Locked: balanceTotal.Sub(balanceAvailable.Sub(unrealizedPnl)), } }