Skip to content

Commit f93a722

Browse files
committed
Display both USD and CA available balances
Even accounts that indicate that their currency is CAD can have USD positions and cash balances. So when displaying the cash balance, display both CAD and USD balances. Signed-off-by: Brian J. Murrell <brian@interlinx.bc.ca>
1 parent d44df04 commit f93a722

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ class WSApiTest:
151151

152152
# Cash and positions balances
153153
balances = ws.get_account_balances(account['id'])
154-
cash_balance_key = 'sec-c-usd' if account['currency'] == 'USD' else 'sec-c-cad'
155-
cash_balance = float(balances.get(cash_balance_key, 0))
156-
print(f" Available (cash) balance: {cash_balance} {account['currency']}")
154+
for cash_balance_key in [ 'sec-c-usd', 'sec-c-cad']:
155+
cash_balance = float(balances.get(cash_balance_key, 0))
156+
print(f" Available (cash) balance: {cash_balance} {cash_balance_key.split('-')[-1].upper()}")
157157

158158
if len(balances) > 1:
159159
print(" Assets:")
@@ -199,4 +199,4 @@ if __name__ == "__main__":
199199
Projects Using It
200200
-----------------
201201

202-
- [wealthgrabber](https://github.com/ebastos/wealthgrabber) - Wealthsimple portfolio analytics
202+
- [wealthgrabber](https://github.com/ebastos/wealthgrabber) - Wealthsimple portfolio analytics

0 commit comments

Comments
 (0)