Implement closing trades on OANDA

This commit is contained in:
Mark Veidemanis 2023-01-02 18:42:03 +00:00
parent 2fa61fb195
commit 9835219e51
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 12 additions and 0 deletions

View File

@ -121,6 +121,11 @@ class AlpacaExchange(BaseExchange):
trade.save() trade.save()
return order return order
def close_trade(self, trade_id): # TODO
"""
Close a trade
"""
def get_trade(self, trade_id): def get_trade(self, trade_id):
pass # TODO pass # TODO

View File

@ -94,6 +94,13 @@ class OANDAExchange(BaseExchange):
trade.save() trade.save()
return response 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): def get_trade(self, trade_id):
# OANDA is off by one... # OANDA is off by one...
r = trades.TradeDetails(accountID=self.account_id, tradeID=trade_id) r = trades.TradeDetails(accountID=self.account_id, tradeID=trade_id)