Continue implementing live risk checks

This commit is contained in:
2023-01-11 19:46:47 +00:00
parent 93be9e6ffe
commit e55f903f42
12 changed files with 527 additions and 244 deletions

View File

@@ -36,18 +36,25 @@ class OANDAExchange(BaseExchange):
response = self.get_instruments()
return [x["name"] for x in response["itemlist"]]
def get_balance(self):
def get_balance(self, return_usd=False):
r = accounts.AccountSummary(self.account_id)
response = self.call(r)
print("RESPONSE", response)
balance = float(response["balance"])
currency = response["currency"]
balance_usd = common.to_currency("sell", self.account, balance, currency, "USD")
print("BALANCE", balance)
print("BALANCE USD", balance_usd)
common.get_balance_hook(
self.account.user.id,
self.account.user.username,
self.account.id,
self.account.name,
balance,
balance_usd,
)
if return_usd:
return balance_usd
return balance
def get_market_value(self, symbol):
@@ -138,7 +145,7 @@ class OANDAExchange(BaseExchange):
def get_all_open_trades(self):
r = trades.OpenTrades(accountID=self.account_id)
return self.call(r)
return self.call(r)["itemlist"]
def close_position(self, side, symbol):
data = {