|
|
|
@ -458,3 +458,37 @@ class Transactions(object):
|
|
|
|
|
remaining = withdraw_threshold - total_usd
|
|
|
|
|
|
|
|
|
|
return remaining
|
|
|
|
|
|
|
|
|
|
def get_open_trades_usd(self):
|
|
|
|
|
dash = self.agora.wrap_dashboard()
|
|
|
|
|
if dash is False:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
rates = self.agora.get_rates_all()
|
|
|
|
|
cumul_usd = 0
|
|
|
|
|
for contact_id, contact in dash.items():
|
|
|
|
|
amount = contact["data"]["amount"]
|
|
|
|
|
currency = contact["data"]["currency"]
|
|
|
|
|
if not contact["data"]["is_selling"]:
|
|
|
|
|
continue
|
|
|
|
|
if currency == "USD":
|
|
|
|
|
cumul_usd += amount
|
|
|
|
|
else:
|
|
|
|
|
rate = rates[currency]
|
|
|
|
|
amount_usd = float(amount) / rate
|
|
|
|
|
print("AMOUTN USD", amount_usd)
|
|
|
|
|
cumul_usd += amount_usd
|
|
|
|
|
|
|
|
|
|
return cumul_usd
|
|
|
|
|
|
|
|
|
|
def get_total_remaining(self):
|
|
|
|
|
total_usd = self.get_total_usd()
|
|
|
|
|
total_trades_usd = self.get_open_trades_usd()
|
|
|
|
|
if not total_usd:
|
|
|
|
|
return False
|
|
|
|
|
total_usd += total_trades_usd
|
|
|
|
|
|
|
|
|
|
withdraw_threshold = float(settings.Money.BaseUSD) + float(settings.Money.WithdrawLimit)
|
|
|
|
|
remaining = withdraw_threshold - total_usd
|
|
|
|
|
|
|
|
|
|
return remaining
|
|
|
|
|