Pass platform to open trades USD parse dash

This commit is contained in:
Mark Veidemanis 2022-05-08 11:11:13 +01:00
parent 086128396a
commit df5ea51226
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 7 additions and 4 deletions

View File

@ -368,7 +368,7 @@ class Money(util.Base):
self.write_to_es("get_remaining", cast_es) self.write_to_es("get_remaining", cast_es)
return remaining return remaining
def open_trades_usd_parse_dash(self, dash, rates): def open_trades_usd_parse_dash(self, platform, dash, rates):
cumul_usd = 0 cumul_usd = 0
for contact_id, contact in dash.items(): for contact_id, contact in dash.items():
# We need created at in order to look up the historical prices # We need created at in order to look up the historical prices
@ -388,7 +388,10 @@ class Money(util.Base):
date_formatted = date_parsed.strftime("%d-%m-%Y") date_formatted = date_parsed.strftime("%d-%m-%Y")
# Get the historical rates for the right asset, extract the price # Get the historical rates for the right asset, extract the price
if platform == "agora":
asset = contact["data"]["advertisement"]["asset"] asset = contact["data"]["advertisement"]["asset"]
elif platform == "lbtc":
asset = "BTC"
if asset == "XMR": if asset == "XMR":
amount_crypto = contact["data"]["amount_xmr"] amount_crypto = contact["data"]["amount_xmr"]
history = self.cg.get_coin_history_by_id(id="monero", date=date_formatted) history = self.cg.get_coin_history_by_id(id="monero", date=date_formatted)
@ -427,8 +430,8 @@ class Money(util.Base):
return False return False
rates = self.get_rates_all() rates = self.get_rates_all()
cumul_usd_agora = self.open_trades_usd_parse_dash(dash_agora, rates) cumul_usd_agora = self.open_trades_usd_parse_dash("agora", dash_agora, rates)
cumul_usd_lbtc = self.open_trades_usd_parse_dash(dash_lbtc, rates) cumul_usd_lbtc = self.open_trades_usd_parse_dash("lbtc", dash_lbtc, rates)
cumul_usd = cumul_usd_agora + cumul_usd_lbtc cumul_usd = cumul_usd_agora + cumul_usd_lbtc
cast_es = { cast_es = {