Skip to content

Commit

Permalink
Merge pull request #440 from 0jc1/main
Browse files Browse the repository at this point in the history
Total holdings across brokers
  • Loading branch information
NelsonDane authored Nov 23, 2024
2 parents 608515d + 1031864 commit c8a3321
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions autoRSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def nicknames(broker):
# broker name + type of function
def fun_run(orderObj: stockOrder, command, botObj=None, loop=None):
if command in [("_init", "_holdings"), ("_init", "_transaction")]:
totalValue = 0
for broker in orderObj.get_brokers():
if broker in orderObj.get_notbrokers():
continue
Expand Down Expand Up @@ -195,11 +196,19 @@ def fun_run(orderObj: stockOrder, command, botObj=None, loop=None):
f"All {broker.capitalize()} transactions complete",
loop,
)
# Add to total sum
totalValue += sum(
account["total"] for account in orderObj.get_logged_in(broker).get_account_totals().values()
)
except Exception as ex:
print(traceback.format_exc())
print(f"Error in {fun_name} with {broker}: {ex}")
print(orderObj)
print()

# Print final total value and closing message
if "_holdings" in command:
printAndDiscord(f"Total Value of All Accounts: ${format(totalValue, '0.2f')}", loop)
printAndDiscord("All commands complete in all brokers", loop)
else:
print(f"Error: {command} is not a valid command")
Expand Down
2 changes: 1 addition & 1 deletion helperAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def set_account_totals(self, parent_name: str, account_name: str, total: float):
self.__account_totals[parent_name] = {}
self.__account_totals[parent_name][account_name] = round(float(total), 2)
self.__account_totals[parent_name]["total"] = sum(
self.__account_totals[parent_name].values()
value for key, value in self.__account_totals[parent_name].items() if key != "total"
)

def set_account_type(self, parent_name: str, account_name: str, account_type: str):
Expand Down

0 comments on commit c8a3321

Please sign in to comment.