From d2d74a20868e0ee405fe82cd2ac4ae610c053dd2 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Mon, 18 Apr 2022 17:21:58 +0100 Subject: [PATCH] Add bank name to markets and filter currencies --- handler/markets.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/handler/markets.py b/handler/markets.py index ae0be1f..2739310 100644 --- a/handler/markets.py +++ b/handler/markets.py @@ -51,6 +51,9 @@ class Markets(util.Base): assets = self.get_all_assets(platform) currencies = self.get_all_currencies(platform) providers = self.get_all_providers(platform) + sinks_currencies = self.sinks.currencies + supported_currencies = [currency for currency in currencies if currency in sinks_currencies] + currencies = supported_currencies brute = [(asset, currency, provider) for asset in assets for currency in currencies for provider in providers] for asset, currency, provider in brute: @@ -75,7 +78,10 @@ class Markets(util.Base): continue new_margin = self.autoprice(username, min_margin, max_margin, 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}" + if platform == "agora": + new_formula = f"coingecko{asset.lower()}usd*usd{currency.lower()}*{new_margin}" + elif platform == "lbtc": + new_formula = f"btc_in_usd*{new_margin}" for ad in our_ads: ad_id = ad[0] asset = ad[4] @@ -178,10 +184,10 @@ class Markets(util.Base): else: yield (asset, countrycode, currency, provider) - def get_valid_account_details(self): + def get_valid_account_details(self, platform): currencies = self.sinks.currencies account_info = self.sinks.account_info - all_currencies = self.get_all_currencies() + all_currencies = self.get_all_currencies(platform) supported_currencies = [currency for currency in currencies if currency in all_currencies] currency_account_info_map = {} for currency in supported_currencies: @@ -189,6 +195,7 @@ class Markets(util.Base): for account in accounts: if account["currency"] == currency: currency_account_info_map[currency] = account["account_number"] + currency_account_info_map[currency]["bank"] = bank.split("_")[0] return (supported_currencies, currency_account_info_map) def _distribute_account_details(self, platform, currencies=None, account_info=None):