From 1f75da40afff6996abc97e6db23b2563d243ce0d Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 2 Nov 2022 18:28:31 +0000 Subject: [PATCH] Set account ID in exchange library instead of the view --- core/exchanges/alpaca.py | 1 + core/exchanges/oanda.py | 3 ++- core/views/positions.py | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/exchanges/alpaca.py b/core/exchanges/alpaca.py index ba419bb..ed39f28 100644 --- a/core/exchanges/alpaca.py +++ b/core/exchanges/alpaca.py @@ -146,6 +146,7 @@ class AlpacaExchange(BaseExchange): return (success, response) for item in response["itemlist"]: + item["account"] = self.account.name item["account_id"] = self.account.id item["unrealized_pl"] = float(item["unrealized_pl"]) items.append(item) diff --git a/core/exchanges/oanda.py b/core/exchanges/oanda.py index df7b26d..5fae4fa 100644 --- a/core/exchanges/oanda.py +++ b/core/exchanges/oanda.py @@ -85,7 +85,8 @@ class OANDAExchange(BaseExchange): print("Positions", response) 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"]) items.append(item) return (True, items) diff --git a/core/views/positions.py b/core/views/positions.py index fcee4b9..831ed9f 100644 --- a/core/views/positions.py +++ b/core/views/positions.py @@ -21,8 +21,6 @@ def get_positions(user, account_id=None): if not success: items.append({"name": account.name, "status": "error"}) continue - for position in positions: - position["account"] = account.name for item in positions: items.append(item)