|
|
@ -11,19 +11,28 @@ class Markets(util.Base):
|
|
|
|
Markets handler for generic market functions.
|
|
|
|
Markets handler for generic market functions.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def get_all_assets(self):
|
|
|
|
def get_all_assets(self, platform):
|
|
|
|
assets = loads(settings.Agora.AssetList)
|
|
|
|
if platform == "agora":
|
|
|
|
|
|
|
|
assets = loads(settings.Agora.AssetList)
|
|
|
|
|
|
|
|
elif platform == "lbtc":
|
|
|
|
|
|
|
|
assets = loads(settings.LocalBitcoins.AssetList)
|
|
|
|
return assets
|
|
|
|
return assets
|
|
|
|
|
|
|
|
|
|
|
|
def get_all_providers(self):
|
|
|
|
def get_all_providers(self, platform):
|
|
|
|
providers = loads(settings.Agora.ProviderList)
|
|
|
|
if platform == "agora":
|
|
|
|
|
|
|
|
providers = loads(settings.Agora.ProviderList)
|
|
|
|
|
|
|
|
elif platform == "lbtc":
|
|
|
|
|
|
|
|
providers = loads(settings.LocalBitcoins.ProviderList)
|
|
|
|
return providers
|
|
|
|
return providers
|
|
|
|
|
|
|
|
|
|
|
|
def get_all_currencies(self):
|
|
|
|
def get_all_currencies(self, platform):
|
|
|
|
currencies = list(set([x[0] for x in loads(settings.Agora.DistList)]))
|
|
|
|
if platform == "agora":
|
|
|
|
|
|
|
|
currencies = list(set([x[0] for x in loads(settings.Agora.DistList)]))
|
|
|
|
|
|
|
|
elif platform == "lbtc":
|
|
|
|
|
|
|
|
currencies = list(set([x[0] for x in loads(settings.Agora.DistList)]))
|
|
|
|
return currencies
|
|
|
|
return currencies
|
|
|
|
|
|
|
|
|
|
|
|
def get_new_ad_equations(self, public_ads, assets=None):
|
|
|
|
def get_new_ad_equations(self, platform, public_ads, assets=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Update all our prices.
|
|
|
|
Update all our prices.
|
|
|
|
:param public_ads: dictionary of public ads keyed by currency
|
|
|
|
:param public_ads: dictionary of public ads keyed by currency
|
|
|
@ -31,6 +40,10 @@ class Markets(util.Base):
|
|
|
|
:return: list of ads to modify
|
|
|
|
:return: list of ads to modify
|
|
|
|
:rtype: list
|
|
|
|
:rtype: list
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
if platform == "agora":
|
|
|
|
|
|
|
|
username = settings.Agora.Username
|
|
|
|
|
|
|
|
elif platform == "lbtc":
|
|
|
|
|
|
|
|
username = settings.LocalBitcoins.Username
|
|
|
|
to_update = []
|
|
|
|
to_update = []
|
|
|
|
|
|
|
|
|
|
|
|
# NOTES:
|
|
|
|
# NOTES:
|
|
|
@ -40,9 +53,9 @@ class Markets(util.Base):
|
|
|
|
|
|
|
|
|
|
|
|
# (asset, currency, provider)
|
|
|
|
# (asset, currency, provider)
|
|
|
|
if not assets:
|
|
|
|
if not assets:
|
|
|
|
assets = self.get_all_assets()
|
|
|
|
assets = self.get_all_assets(platform)
|
|
|
|
currencies = self.get_all_currencies()
|
|
|
|
currencies = self.get_all_currencies(platform)
|
|
|
|
providers = self.get_all_providers()
|
|
|
|
providers = self.get_all_providers(platform)
|
|
|
|
|
|
|
|
|
|
|
|
brute = [(asset, currency, provider) for asset in assets for currency in currencies for provider in providers]
|
|
|
|
brute = [(asset, currency, provider) for asset in assets for currency in currencies for provider in providers]
|
|
|
|
for asset, currency, provider in brute:
|
|
|
|
for asset, currency, provider in brute:
|
|
|
@ -62,7 +75,7 @@ class Markets(util.Base):
|
|
|
|
# Filter provider
|
|
|
|
# Filter provider
|
|
|
|
public_ads_filtered = [ad for ad in public_ads_filtered if ad[3] == provider]
|
|
|
|
public_ads_filtered = [ad for ad in public_ads_filtered if ad[3] == provider]
|
|
|
|
|
|
|
|
|
|
|
|
our_ads = [ad for ad in public_ads_filtered if ad[1] == settings.Agora.Username]
|
|
|
|
our_ads = [ad for ad in public_ads_filtered if ad[1] == username]
|
|
|
|
if not our_ads:
|
|
|
|
if not our_ads:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
new_margin = self.autoprice(public_ads_filtered, currency)
|
|
|
|
new_margin = self.autoprice(public_ads_filtered, currency)
|
|
|
|