From 3417e6166ac37292754882d96eae6c0f9a452e6b Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 9 Feb 2022 14:57:11 +0000 Subject: [PATCH] Fix minor bugs with the cheat system --- handler/agora.py | 2 +- handler/commands.py | 8 ++++---- handler/markets.py | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/handler/agora.py b/handler/agora.py index d6a30b7..bb9ab27 100644 --- a/handler/agora.py +++ b/handler/agora.py @@ -71,7 +71,7 @@ class Agora(object): self.lc_dash = LoopingCall(self.loop_check) self.lc_dash.start(int(settings.Agora.RefreshSec)) if settings.Agora.Cheat == "1": - self.lc_cheat = LoopingCall(self._update_prices, None, None) + self.lc_cheat = LoopingCall(self.run_cheat_in_thread) self.lc_cheat.start(int(settings.Agora.CheatSec)) @handle_exceptions diff --git a/handler/commands.py b/handler/commands.py index 9f3d803..e88656c 100644 --- a/handler/commands.py +++ b/handler/commands.py @@ -321,7 +321,7 @@ class IRCCommands(object): class pubads(object): name = "pubads" authed = True - helptext = "View public adverts. Usage: pubads " + helptext = "View public adverts. Usage: pubads []" @staticmethod def run(cmd, spl, length, authed, msg, agora, revolut, tx, notify): @@ -333,7 +333,7 @@ class IRCCommands(object): currency = spl[2] rtrn = agora.wrap_public_ads(asset, currency) for ad in rtrn: - msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[4]}") + msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[4]} {ad[5]}") elif length == 4: asset = spl[1] if asset not in loads(settings.Agora.AssetList): @@ -343,7 +343,7 @@ class IRCCommands(object): currency = spl[2] rtrn = agora.wrap_public_ads(asset, currency, providers) for ad in rtrn: - msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]}") + msg(f"({ad[0]}) {ad[1]} {ad[2]} {ad[3]} {ad[4]} {ad[5]}") class cheat(object): name = "cheat" @@ -371,7 +371,7 @@ class IRCCommands(object): @staticmethod def run(cmd, spl, length, authed, msg, agora, revolut, tx, notify): if length == 1: - asset = agora._update_prices(None, None) + asset = agora.run_cheat_in_thread() msg(f"Running next asset for cheat in thread: {asset}") class ads(object): diff --git a/handler/markets.py b/handler/markets.py index a3f026f..46b96b3 100644 --- a/handler/markets.py +++ b/handler/markets.py @@ -56,6 +56,9 @@ class Markets(object): public_ads_currency = public_ads[currency] except KeyError: self.log.error("Error getting public ads for currency {currency}", currency=currency) + if currency == "USD": + self.log.error("Error getting public ads for currency USD, aborting") + break continue # Filter asset @@ -68,6 +71,7 @@ class Markets(object): if not our_ads: continue new_margin = self.autoprice(public_ads_filtered, currency) + self.log.info("New rate for {currency}: {rate}", currency=currency, rate=new_margin) new_formula = f"coingecko{asset.lower()}usd*usd{currency.lower()}*{new_margin}" for ad in our_ads: ad_id = ad[0]