Implement changing the online_provider when creating an ad
This commit is contained in:
parent
21b5a839c1
commit
768ad84982
|
@ -383,24 +383,18 @@ class Agora(object):
|
||||||
all_assets = loads(settings.Agora.AssetList)
|
all_assets = loads(settings.Agora.AssetList)
|
||||||
assets_not_run = set(all_assets) ^ set(self.cheat_run_on)
|
assets_not_run = set(all_assets) ^ set(self.cheat_run_on)
|
||||||
if not assets_not_run:
|
if not assets_not_run:
|
||||||
print("TOP")
|
|
||||||
self.cheat_run_on = []
|
self.cheat_run_on = []
|
||||||
asset = list(all_assets).pop()
|
asset = list(all_assets).pop()
|
||||||
self.cheat_run_on.append(asset)
|
self.cheat_run_on.append(asset)
|
||||||
else:
|
else:
|
||||||
print("BOTTOM")
|
|
||||||
asset = assets_not_run.pop()
|
asset = assets_not_run.pop()
|
||||||
self.cheat_run_on.append(asset)
|
self.cheat_run_on.append(asset)
|
||||||
print("end cheat", self.cheat_run_on)
|
|
||||||
if asset == "XMR":
|
if asset == "XMR":
|
||||||
deferToThread(self.update_prices, True, False) # XMR, BTC
|
deferToThread(self.update_prices, True, False) # XMR, BTC
|
||||||
print("Running cheat on XMR")
|
|
||||||
elif asset == "BTC":
|
elif asset == "BTC":
|
||||||
deferToThread(self.update_prices, False, True) # XMR, BTC
|
deferToThread(self.update_prices, False, True) # XMR, BTC
|
||||||
print("Running cheat on BTC")
|
|
||||||
return asset
|
return asset
|
||||||
else:
|
else:
|
||||||
print("Running cheat normally")
|
|
||||||
deferToThread(self.update_prices, xmr, btc)
|
deferToThread(self.update_prices, xmr, btc)
|
||||||
|
|
||||||
@handle_exceptions
|
@handle_exceptions
|
||||||
|
@ -479,7 +473,6 @@ class Agora(object):
|
||||||
self.log.info("Rate for {currency}: {margin}", currency=currency, margin=new_margin)
|
self.log.info("Rate for {currency}: {margin}", currency=currency, margin=new_margin)
|
||||||
else:
|
else:
|
||||||
self.log.info("Not changed rate for {currency}, keeping old margin of {margin}", currency=currency, margin=our_margin)
|
self.log.info("Not changed rate for {currency}, keeping old margin of {margin}", currency=currency, margin=our_margin)
|
||||||
print("TO UPDATE", to_update)
|
|
||||||
self.slow_ad_update(to_update)
|
self.slow_ad_update(to_update)
|
||||||
|
|
||||||
def slow_ad_update(self, ads):
|
def slow_ad_update(self, ads):
|
||||||
|
@ -495,7 +488,6 @@ class Agora(object):
|
||||||
while not all([x[4] for x in ads]) or iterations == 1000:
|
while not all([x[4] for x in ads]) or iterations == 1000:
|
||||||
for ad_index in range(len(ads)):
|
for ad_index in range(len(ads)):
|
||||||
ad_id, new_formula, asset, currency, actioned = ads[ad_index]
|
ad_id, new_formula, asset, currency, actioned = ads[ad_index]
|
||||||
print("SLOW ITER", ad_id, new_formula, asset, currency, actioned)
|
|
||||||
assets.add(asset)
|
assets.add(asset)
|
||||||
currencies.add(currency)
|
currencies.add(currency)
|
||||||
self.log.error("ASSET {a}", a=asset)
|
self.log.error("ASSET {a}", a=asset)
|
||||||
|
@ -652,7 +644,7 @@ class Agora(object):
|
||||||
return (min_local, max_local)
|
return (min_local, max_local)
|
||||||
|
|
||||||
@handle_exceptions
|
@handle_exceptions
|
||||||
def create_ad(self, asset, countrycode, currency):
|
def create_ad(self, asset, countrycode, currency, online_provider):
|
||||||
"""
|
"""
|
||||||
Post an ad with the given asset in a country with a given currency.
|
Post an ad with the given asset in a country with a given currency.
|
||||||
Convert the min and max amounts from settings to the given currency with CurrencyRates.
|
Convert the min and max amounts from settings to the given currency with CurrencyRates.
|
||||||
|
@ -707,7 +699,7 @@ class Agora(object):
|
||||||
"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,
|
||||||
"online_provider": "REVOLUT",
|
"online_provider": online_provider,
|
||||||
"msg": ad,
|
"msg": ad,
|
||||||
"min_amount": min_amount,
|
"min_amount": min_amount,
|
||||||
"max_amount": max_amount,
|
"max_amount": max_amount,
|
||||||
|
@ -730,51 +722,11 @@ class Agora(object):
|
||||||
"""
|
"""
|
||||||
for asset in loads(settings.Agora.AssetList):
|
for asset in loads(settings.Agora.AssetList):
|
||||||
for currency, countrycode in loads(settings.Agora.DistList):
|
for currency, countrycode in loads(settings.Agora.DistList):
|
||||||
rtrn = self.create_ad(asset, countrycode, currency)
|
rtrn = self.create_ad(asset, countrycode, currency, "REVOLUT")
|
||||||
if rtrn is False:
|
if rtrn is False:
|
||||||
return False
|
return False
|
||||||
yield rtrn
|
yield rtrn
|
||||||
|
|
||||||
# def get_combinations(self):
|
|
||||||
# """
|
|
||||||
# Get all combinations of currencies and countries from the configuration.
|
|
||||||
# :return: list of [country, currency]
|
|
||||||
# :rtype: list
|
|
||||||
# """
|
|
||||||
# currencies = loads(settings.Agora.BruteCurrencies)
|
|
||||||
# countries = loads(settings.Agora.BruteCountries)
|
|
||||||
# combinations = [[country, currency] for country in countries for currency in currencies]
|
|
||||||
# return combinations
|
|
||||||
|
|
||||||
# def dist_bruteforce(self):
|
|
||||||
# """
|
|
||||||
# Bruteforce all possible ads from the currencies and countries in the config.
|
|
||||||
# Does not exit on errors.
|
|
||||||
# :return: False or dict with response
|
|
||||||
# :rtype: bool or dict
|
|
||||||
# """
|
|
||||||
# combinations = self.get_combinations()
|
|
||||||
# for country, currency in combinations:
|
|
||||||
# rtrn = self.create_ad(country, currency)
|
|
||||||
# if not rtrn:
|
|
||||||
# yield False
|
|
||||||
# yield rtrn
|
|
||||||
#
|
|
||||||
# def bruteforce_fill_blanks(self):
|
|
||||||
# """
|
|
||||||
# Get the ads that we want to configure but have not, and fill in the blanks.
|
|
||||||
# :return: False or dict with response
|
|
||||||
# :rtype: bool or dict
|
|
||||||
# """
|
|
||||||
# existing_ads = self.enum_ads()
|
|
||||||
# combinations = self.get_combinations()
|
|
||||||
# for country, currency in combinations:
|
|
||||||
# if not [country, currency] in existing_ads:
|
|
||||||
# rtrn = self.create_ad(country, currency)
|
|
||||||
# if not rtrn:
|
|
||||||
# yield False
|
|
||||||
# yield rtrn
|
|
||||||
|
|
||||||
@handle_exceptions
|
@handle_exceptions
|
||||||
def strip_duplicate_ads(self):
|
def strip_duplicate_ads(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -40,7 +40,7 @@ class IRCCommands(object):
|
||||||
if spl[1] not in loads(settings.Agora.AssetList):
|
if spl[1] not in loads(settings.Agora.AssetList):
|
||||||
msg(f"Not a valid asset: {spl[1]}")
|
msg(f"Not a valid asset: {spl[1]}")
|
||||||
return
|
return
|
||||||
posted = agora.create_ad(spl[1], spl[2], spl[3])
|
posted = agora.create_ad(spl[1], spl[2], spl[3], "REVOLUT")
|
||||||
if posted["success"]:
|
if posted["success"]:
|
||||||
msg(f"{posted['response']['data']['message']}: {posted['response']['data']['ad_id']}")
|
msg(f"{posted['response']['data']['message']}: {posted['response']['data']['ad_id']}")
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue