From 24006110b1f67b11e51ce42450e18b579cec273a Mon Sep 17 00:00:00 2001 From: Evgeniy Zhmakin Date: Sun, 19 Jan 2025 06:39:48 +0100 Subject: [PATCH] fix: use equity field for balance in Unified Account API --- backtrader_bybit/bybit_store.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backtrader_bybit/bybit_store.py b/backtrader_bybit/bybit_store.py index fd992de..22689bd 100644 --- a/backtrader_bybit/bybit_store.py +++ b/backtrader_bybit/bybit_store.py @@ -89,10 +89,11 @@ def get_asset_balance(self, asset): balance = {} if w and 'result' in w and w['result'] and 'list' in w['result'] and w['result']['list']: for _coin in w['result']['list'][0]['coin']: - locked = _coin['locked'] if 'locked' in _coin else 0 - balance[_coin['coin']] = {"free": _coin['availableToWithdraw'], - "usdValue": _coin['usdValue'], - "locked": locked, } + balance[_coin['coin']] = { + "free": _coin['equity'], + "usdValue": _coin['usdValue'], + "locked": _coin['locked'] + } if asset in balance.keys(): return float(balance[asset]['free']), float(balance[asset]['locked']) else: