Continue implementing live risk checks
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user