Filter the currencies in Agora

master
Mark Veidemanis 2 years ago
parent 9360af7588
commit 165fe48234
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -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:

@ -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):

Loading…
Cancel
Save