From 9835219e51aba52ee4115c08d5eb43c303ecb570 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Mon, 2 Jan 2023 18:42:03 +0000 Subject: [PATCH] Implement closing trades on OANDA --- core/exchanges/alpaca.py | 5 +++++ core/exchanges/oanda.py | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/core/exchanges/alpaca.py b/core/exchanges/alpaca.py index 0c0103f..03861d9 100644 --- a/core/exchanges/alpaca.py +++ b/core/exchanges/alpaca.py @@ -121,6 +121,11 @@ class AlpacaExchange(BaseExchange): trade.save() return order + def close_trade(self, trade_id): # TODO + """ + Close a trade + """ + def get_trade(self, trade_id): pass # TODO diff --git a/core/exchanges/oanda.py b/core/exchanges/oanda.py index af7a8d7..ae62306 100644 --- a/core/exchanges/oanda.py +++ b/core/exchanges/oanda.py @@ -94,6 +94,13 @@ class OANDAExchange(BaseExchange): trade.save() return response + def close_trade(self, trade_id): + """ + Close a trade. + """ + r = trades.TradeClose(accountID=self.account_id, tradeID=trade_id) + return self.call(r) + def get_trade(self, trade_id): # OANDA is off by one... r = trades.TradeDetails(accountID=self.account_id, tradeID=trade_id)