From c31175fea097c6495163adc38d82fe6803d98d95 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 5 May 2022 18:24:40 +0100 Subject: [PATCH] Neaten up various money calls --- handler/lib/money.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/handler/lib/money.py b/handler/lib/money.py index a453d78..ffe8208 100644 --- a/handler/lib/money.py +++ b/handler/lib/money.py @@ -52,8 +52,8 @@ class Money(util.Base): """ self.get_total() self.get_remaining() - self.money.get_profit() - self.money.get_profit(True) + self.get_profit() + self.get_profit(True) self.get_open_trades_usd() self.get_total_remaining() self.get_total_with_trades() @@ -170,11 +170,11 @@ class Money(util.Base): :return: profit in USD :rtype: float """ - total_usd = yield self.tx.get_total_usd() + total_usd = yield self.get_total_usd() if not total_usd: return False if trades: - trades_usd = yield self.tx.get_open_trades_usd() + trades_usd = yield self.get_open_trades_usd() total_usd += trades_usd profit = total_usd - float(settings.Money.BaseUSD) @@ -198,9 +198,9 @@ class Money(util.Base): :rtype float: """ total_sinks_usd = self.sinks.get_total_usd() - agora_wallet_xmr = yield self.agora.agora.wallet_balance_xmr() - agora_wallet_btc = yield self.agora.agora.wallet_balance() - lbtc_wallet_btc = yield self.lbtc.lbtc.wallet_balance() + agora_wallet_xmr = yield self.agora.api.wallet_balance_xmr() + agora_wallet_btc = yield self.agora.api.wallet_balance() + lbtc_wallet_btc = yield self.lbtc.api.wallet_balance() if not agora_wallet_xmr["success"]: return False if not agora_wallet_btc["success"]: @@ -261,17 +261,21 @@ class Money(util.Base): :rtype: tuple(tuple(float, float, float), tuple(float, float), tuple(float, float)) """ total_sinks_usd = self.sinks.get_total_usd() - agora_wallet_xmr = yield self.agora.agora.wallet_balance_xmr() + agora_wallet_xmr = yield self.agora.api.wallet_balance_xmr() + agora_wallet_btc = yield self.agora.api.wallet_balance() + lbtc_wallet_btc = yield self.lbtc.api.wallet_balance() if not agora_wallet_xmr["success"]: - self.log.error("Could not get Agora XMR wallet total.") return False - agora_wallet_btc = yield self.agora.agora.wallet_balance() if not agora_wallet_btc["success"]: - self.log.error("Could not get Agora BTC wallet total.") return False - lbtc_wallet_btc = yield self.lbtc.lbtc.wallet_balance() if not lbtc_wallet_btc["success"]: return False + if not agora_wallet_xmr["response"]: + return False + if not agora_wallet_btc["response"]: + return False + if not lbtc_wallet_btc["response"]: + return False total_xmr_agora = agora_wallet_xmr["response"]["data"]["total"]["balance"] total_btc_agora = agora_wallet_btc["response"]["data"]["total"]["balance"] total_btc_lbtc = lbtc_wallet_btc["response"]["data"]["total"]["balance"]