Libraries refactor and add some sinks #4

Closed
m wants to merge 136 commits from library-refactor into master
3 changed files with 9 additions and 10 deletions
Showing only changes of commit d535852ce6 - Show all commits

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):