add get_position exchange wrapper

This commit is contained in:
Matthias
2022-02-18 07:00:39 +01:00
parent 9f4f65e457
commit ed65692257
2 changed files with 29 additions and 38 deletions

View File

@@ -23,6 +23,7 @@ class Wallet(NamedTuple):
free: float = 0
used: float = 0
total: float = 0
position: float = 0
class Wallets:
@@ -108,6 +109,18 @@ class Wallets:
for currency in deepcopy(self._wallets):
if currency not in balances:
del self._wallets[currency]
# TODO-lev: Implement dry-run/backtest counterpart
positions = self._exchange.get_positions()
for position in positions:
symbol = position['symbol']
if position['side'] is None:
# Position is not open ...
continue
size = self._exchange._contracts_to_amount(symbol, position['contracts'])
self._wallets[symbol] = Wallet(
symbol, position=size
)
def update(self, require_update: bool = True) -> None:
"""