diff --git a/app/urls.py b/app/urls.py index ff2c5c6..0b0ab0d 100644 --- a/app/urls.py +++ b/app/urls.py @@ -124,7 +124,7 @@ urlpatterns = [ name="trade_update", ), path( - "trades//view//", + "trades//view///", trades.TradeAction.as_view(), name="trade_action", ), diff --git a/core/exchanges/oanda.py b/core/exchanges/oanda.py index d5b9eec..4589e78 100644 --- a/core/exchanges/oanda.py +++ b/core/exchanges/oanda.py @@ -103,7 +103,10 @@ class OANDAExchange(BaseExchange): def get_position_info(self, symbol): r = positions.PositionDetails(self.account_id, symbol) - return self.call(r) + response = self.call(r) + response["account"] = self.account.name + response["account_id"] = self.account.id + return response def get_all_positions(self): items = [] diff --git a/core/models.py b/core/models.py index 334d683..1b4ae06 100644 --- a/core/models.py +++ b/core/models.py @@ -235,12 +235,16 @@ class Trade(models.Model): return cls.objects.get(id=trade_id, user=user) @classmethod - def get_by_id_or_order(cls, trade_id, user): + def get_by_id_or_order(cls, trade_id, account_id, user): try: - return cls.objects.get(id=trade_id, user=user) + account = Account.objects.get(id=account_id, user=user) + except Account.DoesNotExist: + return None + try: + return cls.objects.get(id=trade_id, account=account, user=user) except cls.DoesNotExist: try: - return cls.objects.get(order_id=trade_id, user=user) + return cls.objects.get(order_id=trade_id, account=account, user=user) except cls.DoesNotExist: return None diff --git a/core/templates/partials/position-detail.html b/core/templates/partials/position-detail.html index 9b06a5e..f2621d4 100644 --- a/core/templates/partials/position-detail.html +++ b/core/templates/partials/position-detail.html @@ -10,7 +10,7 @@ {% for trade_id in item %}