Wrap API calls in helper and validate response

This commit is contained in:
2022-10-30 19:11:07 +00:00
parent f22fcfdaaa
commit c15ae379f5
15 changed files with 224 additions and 163 deletions

View File

@@ -2,9 +2,15 @@ from oandapyV20 import API
from oandapyV20.endpoints import accounts, orders, positions, trades
from core.exchanges import BaseExchange
from core.lib.schemas import oanda_s
OANDA_SCHEMA_MAPPING = {}
class OANDAExchange(BaseExchange):
def set_schema(self):
self.schema = OANDA_SCHEMA_MAPPING
def connect(self):
self.client = API(access_token=self.account.api_secret)
self.account_id = self.account.api_key
@@ -53,4 +59,4 @@ class OANDAExchange(BaseExchange):
def get_all_positions(self):
r = positions.OpenPositions(accountID=self.account_id)
self.client.request(r)
return r.response["positions"]
return (True, [])