Set account ID in exchange library instead of the view

This commit is contained in:
Mark Veidemanis 2022-11-02 18:28:31 +00:00
parent 5cb7d08614
commit 1f75da40af
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 3 additions and 3 deletions

View File

@ -146,6 +146,7 @@ class AlpacaExchange(BaseExchange):
return (success, response) return (success, response)
for item in response["itemlist"]: for item in response["itemlist"]:
item["account"] = self.account.name
item["account_id"] = self.account.id item["account_id"] = self.account.id
item["unrealized_pl"] = float(item["unrealized_pl"]) item["unrealized_pl"] = float(item["unrealized_pl"])
items.append(item) items.append(item)

View File

@ -85,7 +85,8 @@ class OANDAExchange(BaseExchange):
print("Positions", response) print("Positions", response)
for item in response["itemlist"]: for item in response["itemlist"]:
item["account_id"] = self.account.id item["account"] = self.account.name
item["account_id"] = self.account_id
item["unrealized_pl"] = float(item["unrealized_pl"]) item["unrealized_pl"] = float(item["unrealized_pl"])
items.append(item) items.append(item)
return (True, items) return (True, items)

View File

@ -21,8 +21,6 @@ def get_positions(user, account_id=None):
if not success: if not success:
items.append({"name": account.name, "status": "error"}) items.append({"name": account.name, "status": "error"})
continue continue
for position in positions:
position["account"] = account.name
for item in positions: for item in positions:
items.append(item) items.append(item)