Fix posting BTC ads

This commit is contained in:
Mark Veidemanis 2022-01-23 17:08:01 +00:00
parent 38425173b9
commit 7e42bbebf3
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 34 additions and 22 deletions

View File

@ -464,33 +464,42 @@ class Agora(object):
paymentdetailstext = paymentdetails.replace("$PAYMENT$", settings.Agora.DefaultDetailsPayment) paymentdetailstext = paymentdetails.replace("$PAYMENT$", settings.Agora.DefaultDetailsPayment)
ad = ad.replace("$ASSET$", asset) ad = ad.replace("$ASSET$", asset)
rates = self.get_rates_all() rates = self.get_rates_all()
if asset == "XMR":
min_usd = float(settings.Agora.MinUSDXMR)
max_usd = float(settings.Agora.MaxUSDXMR)
elif asset == "BTC":
min_usd = float(settings.Agora.MinUSDBTC)
max_usd = float(settings.Agora.MaxUSDBTC)
if currency == "USD": if currency == "USD":
min_amount = float(settings.Agora.MinUSD) min_amount = min_usd
max_amount = float(settings.Agora.MaxUSD) max_amount = max_usd
else: else:
min_amount = rates[currency] * float(settings.Agora.MinUSD) min_amount = rates[currency] * min_usd
max_amount = rates[currency] * float(settings.Agora.MaxUSD) max_amount = rates[currency] * max_usd
price_formula = f"coingeckoxmrusd*usd{currency.lower()}*{settings.Agora.Margin}" price_formula = f"coingecko{asset.lower()}usd*usd{currency.lower()}*{settings.Agora.Margin}"
# price_formula = f"coingeckoxmrusd*{settings.Agora.Margin}" # price_formula = f"coingeckoxmrusd*{settings.Agora.Margin}"
ad = settings.Agora.Ad ad = settings.Agora.Ad
ad = ad.replace("\\t", "\t") ad = ad.replace("\\t", "\t")
ad = self.agora.ad_create(
country_code=countrycode, form = {"country_code": countrycode,
currency=currency, "currency": currency,
trade_type="ONLINE_SELL", "trade_type": "ONLINE_SELL",
asset=asset, "asset": asset,
price_equation=price_formula, "price_equation": price_formula,
track_max_amount=False, "track_max_amount": False,
require_trusted_by_advertiser=False, "require_trusted_by_advertiser": False,
# verified_email_required = False, "online_provider": "REVOLUT",
online_provider="REVOLUT", "msg": adtext,
msg=adtext, "min_amount": min_amount,
min_amount=min_amount, "max_amount": max_amount,
max_amount=max_amount, "payment_method_details": settings.Agora.PaymentMethodDetails,
payment_method_details=settings.Agora.PaymentMethodDetails, "account_info": paymentdetailstext,
# require_feedback_score = 0, }
account_info=paymentdetailstext,
) # Dirty hack to test
#if asset == "BTC":
# del form["min_amount"]
ad = self.agora.ad_create(**form)
return ad return ad
def dist_countries(self): def dist_countries(self):
@ -501,8 +510,11 @@ class Agora(object):
:rtype: bool or dict :rtype: bool or dict
""" """
for asset in loads(settings.Agora.AssetList): for asset in loads(settings.Agora.AssetList):
print("DIST ASSET", asset)
for currency, countrycode in loads(settings.Agora.DistList): for currency, countrycode in loads(settings.Agora.DistList):
print("DIST C/CC", currency, countrycode)
rtrn = self.create_ad(asset, countrycode, currency) rtrn = self.create_ad(asset, countrycode, currency)
print("RTRN", rtrn)
if not rtrn: if not rtrn:
return False return False
yield rtrn yield rtrn