Skip to content

Commit

Permalink
Corrected cash field
Browse files Browse the repository at this point in the history
  • Loading branch information
ystxn committed Feb 18, 2025
1 parent 8e70b25 commit 3116f3d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ibkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def get_positions(self):
data = self.get_data()
attempts += 1

cash = self.client.portfolio_summary(account_id = self.account_id).data['availablefunds']['amount']
cash = self.client.portfolio_summary(account_id = self.account_id).data['totalcashvalue']['amount']
cash_obj = {'ticker': 'CASH', 'name': 'Cash', 'lastPrice': 0, 'dailyPnl': 0, 'changePercent': 0, 'unrealizedPnl': 0, 'unrealizedPnlPercent': 0, 'mktValue': cash}

if attempts == 3:
Expand All @@ -127,6 +127,6 @@ def get_summary(self):
self.account_id = self.client.portfolio_accounts().data[0]['id']
full_positions = self.client.positions(account_id = self.account_id).data
holdings = sum(item['mktValue'] for item in full_positions)
cash = self.client.portfolio_summary(account_id = self.account_id).data['availablefunds']['amount']
cash = self.client.portfolio_summary(account_id = self.account_id).data['totalcashvalue']['amount']
fx = self.client.currency_exchange_rate('USD', 'SGD').data['rate']
return dict(fx = fx, broker = 'IBKR', brokerColour = 'd81222', holdings = holdings, cash = cash)

0 comments on commit 3116f3d

Please sign in to comment.