From b6a5a2f96d9a449c30cbd50ef68d091455871827 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Tue, 22 Feb 2022 20:12:26 +0000 Subject: [PATCH] Move to_usd to Money library --- handler/agora.py | 8 -------- handler/money.py | 7 +++++++ handler/notify.py | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/handler/agora.py b/handler/agora.py index ddd0e98..7e7b5c7 100644 --- a/handler/agora.py +++ b/handler/agora.py @@ -684,11 +684,3 @@ class Agora(object): self.irc.sendmsg(f"Withdrawal: {rtrn1['success']} | {rtrn2['success']}") self.notify.notify_withdrawal(half_rounded) - - # TODO: move to money - def to_usd(self, amount, currency): - if currency == "USD": - return float(amount) - else: - rates = self.money.get_rates_all() - return float(amount) / rates[currency] diff --git a/handler/money.py b/handler/money.py index 0cb4b00..7a8af45 100644 --- a/handler/money.py +++ b/handler/money.py @@ -70,3 +70,10 @@ class Money(object): min_local = min_usd * rates[currency] max_local = max_usd * rates[currency] return (min_local, max_local) + + def to_usd(self, amount, currency): + if currency == "USD": + return float(amount) + else: + rates = self.get_rates_all() + return float(amount) / rates[currency] diff --git a/handler/notify.py b/handler/notify.py index 7d9226c..f78374a 100644 --- a/handler/notify.py +++ b/handler/notify.py @@ -31,11 +31,11 @@ class Notify(object): ) def notify_new_trade(self, amount, currency): - amount_usd = self.agora.to_usd(amount, currency) + amount_usd = self.money.to_usd(amount, currency) self.sendmsg(f"Total: {amount_usd}", title="New trade", tags="trades", priority="2") def notify_complete_trade(self, amount, currency): - amount_usd = self.agora.to_usd(amount, currency) + amount_usd = self.money.to_usd(amount, currency) self.sendmsg(f"Total: {amount_usd}", title="Trade complete", tags="trades,profit", priority="3") def notify_withdrawal(self, amount_usd):