From f7d086420894edfca6fea444bc718dd9aa5a45b3 Mon Sep 17 00:00:00 2001 From: Red S Date: Sun, 14 Jul 2024 20:31:41 -0700 Subject: [PATCH] feat: IBKR add balance assertions for positions --- beancount_reds_importers/importers/ibkr/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/beancount_reds_importers/importers/ibkr/__init__.py b/beancount_reds_importers/importers/ibkr/__init__.py index b166fd3..a21015e 100644 --- a/beancount_reds_importers/importers/ibkr/__init__.py +++ b/beancount_reds_importers/importers/ibkr/__init__.py @@ -176,3 +176,11 @@ def get_available_cash(self, settlement_fund_balance=0): """ ac = list(self.get_xpath_elements('/FlexQueryResponse/FlexStatements/FlexStatement/CashReport/CashReportCurrency'))[0] return D(ac['slbNetCash']) + + def get_balance_positions(self): + for pos in self.get_xpath_elements('/FlexQueryResponse/FlexStatements/FlexStatement/OpenPositions/OpenPosition'): + balance = { + 'security': pos['isin'], + 'units': D(pos['position']), + } + yield DictToObject(balance)