Move to_usd to Money library

This commit is contained in:
Mark Veidemanis 2022-02-22 20:12:26 +00:00
parent 859c1d20ef
commit b6a5a2f96d
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 9 additions and 10 deletions

View File

@ -684,11 +684,3 @@ class Agora(object):
self.irc.sendmsg(f"Withdrawal: {rtrn1['success']} | {rtrn2['success']}") self.irc.sendmsg(f"Withdrawal: {rtrn1['success']} | {rtrn2['success']}")
self.notify.notify_withdrawal(half_rounded) 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]

View File

@ -70,3 +70,10 @@ class Money(object):
min_local = min_usd * rates[currency] min_local = min_usd * rates[currency]
max_local = max_usd * rates[currency] max_local = max_usd * rates[currency]
return (min_local, max_local) 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]

View File

@ -31,11 +31,11 @@ class Notify(object):
) )
def notify_new_trade(self, amount, currency): 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") self.sendmsg(f"Total: {amount_usd}", title="New trade", tags="trades", priority="2")
def notify_complete_trade(self, amount, currency): 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") self.sendmsg(f"Total: {amount_usd}", title="Trade complete", tags="trades,profit", priority="3")
def notify_withdrawal(self, amount_usd): def notify_withdrawal(self, amount_usd):