Implement stub functions for OANDA

This commit is contained in:
2022-10-30 11:21:48 +00:00
parent f6fa9bdbb6
commit f22fcfdaaa
5 changed files with 55 additions and 19 deletions

View File

@@ -1,15 +1,21 @@
from core.exchanges import BaseExchange
from oandapyV20 import API
from oandapyV20.endpoints import trades
from oandapyV20.endpoints import positions
from oandapyV20.endpoints import accounts, orders, positions, trades
from core.exchanges import BaseExchange
class OANDAExchange(BaseExchange):
def connect(self):
self.client = API(access_token=self.account.api_secret)
self.account_id = self.account.api_key
def get_account(self):
r = accounts.AccountDetails(self.account_id)
self.client.request(r)
return r.response
def get_supported_assets(self):
raise NotImplementedError
return False
def get_balance(self):
raise NotImplementedError
@@ -19,18 +25,32 @@ class OANDAExchange(BaseExchange):
def post_trade(self, trade):
raise NotImplementedError
r = orders.OrderCreate(accountID, data=data)
self.client.request(r)
return r.response
def get_trade(self, trade_id):
raise NotImplementedError
r = accounts.TradeDetails(accountID=self.account_id, tradeID=trade_id)
self.client.request(r)
return r.response
def update_trade(self, trade):
raise NotImplementedError
r = orders.OrderReplace(
accountID=self.account_id, orderID=trade.order_id, data=data
)
self.client.request(r)
return r.response
def cancel_trade(self, trade_id):
raise NotImplementedError
def get_position_info(self, asset_id):
raise NotImplementedError
r = positions.PositionDetails(self.account_id, asset_id)
self.client.request(r)
return r.response
def get_all_positions(self):
pass
r = positions.OpenPositions(accountID=self.account_id)
self.client.request(r)
return r.response["positions"]