From df5ea51226165797ca58c3f469b4f55e45f51497 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 8 May 2022 11:11:13 +0100 Subject: [PATCH] Pass platform to open trades USD parse dash --- handler/lib/money.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/handler/lib/money.py b/handler/lib/money.py index 122ad21..41d0cd8 100644 --- a/handler/lib/money.py +++ b/handler/lib/money.py @@ -368,7 +368,7 @@ class Money(util.Base): self.write_to_es("get_remaining", cast_es) return remaining - def open_trades_usd_parse_dash(self, dash, rates): + def open_trades_usd_parse_dash(self, platform, dash, rates): cumul_usd = 0 for contact_id, contact in dash.items(): # 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") # Get the historical rates for the right asset, extract the price - asset = contact["data"]["advertisement"]["asset"] + if platform == "agora": + asset = contact["data"]["advertisement"]["asset"] + elif platform == "lbtc": + asset = "BTC" if asset == "XMR": amount_crypto = contact["data"]["amount_xmr"] history = self.cg.get_coin_history_by_id(id="monero", date=date_formatted) @@ -427,8 +430,8 @@ class Money(util.Base): return False rates = self.get_rates_all() - cumul_usd_agora = self.open_trades_usd_parse_dash(dash_agora, rates) - cumul_usd_lbtc = self.open_trades_usd_parse_dash(dash_lbtc, rates) + cumul_usd_agora = self.open_trades_usd_parse_dash("agora", dash_agora, rates) + cumul_usd_lbtc = self.open_trades_usd_parse_dash("lbtc", dash_lbtc, rates) cumul_usd = cumul_usd_agora + cumul_usd_lbtc cast_es = {