From 165fe4823478d2df3d0d07e14745b0ff1b84f9cb Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 20 Apr 2022 12:55:08 +0100 Subject: [PATCH] Filter the currencies in Agora --- handler/sources/agora.py | 4 +++- handler/sources/localbitcoins.py | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/handler/sources/agora.py b/handler/sources/agora.py index 3346270..2e1ff92 100644 --- a/handler/sources/agora.py +++ b/handler/sources/agora.py @@ -259,7 +259,6 @@ class Agora(util.Base): @util.handle_exceptions def enum_public_ads(self, asset, currency, providers=None, page=0): to_return = [] - if asset == "XMR": coin = "monero" elif asset == "BTC": @@ -366,6 +365,9 @@ class Agora(util.Base): currencies = self.markets.get_all_currencies(self.platform) if not providers: providers = self.markets.get_all_providers(self.platform) + sinks_currencies = self.sinks.currencies + supported_currencies = [currency for currency in currencies if currency in sinks_currencies] + currencies = supported_currencies # We want to get the ads for each of these currencies and return the result rates = self.money.cg.get_price(ids=["monero", "bitcoin"], vs_currencies=currencies) for asset in assets: diff --git a/handler/sources/localbitcoins.py b/handler/sources/localbitcoins.py index 7fc8ad5..8c4429a 100644 --- a/handler/sources/localbitcoins.py +++ b/handler/sources/localbitcoins.py @@ -277,23 +277,31 @@ class LBTC(util.Base): # Work around weirdness calling it bitcoins # with open("pub.json", "a") as f: - # import json - # f.write(json.dumps([page, currency, asset, ads])+"\n") + # import json + # + # f.write(json.dumps([page, currency, asset, ads]) + "\n") # f.close() if ads is None: + print("ASDS IS NONE") return False if ads is False: + print("ADS IS FALSE") return False if ads["response"] is None: + print("NO RESPONSE") return False if "data" not in ads["response"]: + print("NO DATAS") return False for ad in ads["response"]["data"]["ad_list"]: if self.map_provider(ad["data"]["online_provider"]) not in providers: + print(ad["data"]["online_provider"], "is not in", providers) + print(ad["data"]["online_provider"] in providers) continue date_last_seen = ad["data"]["profile"]["last_online"] # Check if this person was seen recently if not util.last_online_recent(date_last_seen): + print("NOT SEEN RECENTLTY") continue ad_id = str(ad["data"]["ad_id"]) username = ad["data"]["profile"]["username"] @@ -340,13 +348,16 @@ class LBTC(util.Base): @util.handle_exceptions def update_prices(self, assets=None): + print("UPDATE_PRICES", assets) # Get all public ads for the given assets public_ads = self.get_all_public_ads(assets) if not public_ads: + print("NOT PUBLIC ADS") return False # Get the ads to update to_update = self.markets.get_new_ad_equations(self.platform, public_ads, assets) + print("TO UPdATE", to_update) self.slow_ad_update(to_update) # TODO: make generic and move to markets @@ -357,6 +368,7 @@ class LBTC(util.Base): :return: dict of public ads keyed by currency :rtype: dict """ + print("GET ALL PUBLIC ADS") public_ads = {} crypto_map = { "BTC": "bitcoin", @@ -382,11 +394,14 @@ class LBTC(util.Base): except KeyError: # self.log.error("Error getting public ads for currency {currency}", currency=currency) continue + print("ABOUT TO RUN ENUM PUBLIC ADS WITH ", asset, currency, providers) ads_list = self.enum_public_ads(asset, currency, providers) + print("ADS LIST", ads_list) if not ads_list: continue ads = self.money.lookup_rates(self.platform, ads_list, rates=rates) if not ads: + print("NOT ADS CONTINUE") continue self.write_to_es_ads("ads", ads) if currency in public_ads: @@ -395,6 +410,7 @@ class LBTC(util.Base): public_ads[currency].append(ad) else: public_ads[currency] = ads + print("RETURNING PUBLIC ADS", public_ads) return public_ads def write_to_es_ads(self, msgtype, ads):