Add commands to get various totals

This commit is contained in:
Mark Veidemanis 2022-02-15 22:27:42 +00:00
parent 6872e0d164
commit f116ed7cf3
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 27 additions and 0 deletions

View File

@ -445,3 +445,23 @@ class IRCCommands(object):
def run(cmd, spl, length, authed, msg, agora, revolut, tx, notify):
remaining = tx.get_total_remaining()
msg(f"Total remaining: {remaining}USD")
class tradetotal(object):
name = "tradetotal"
authed = True
helptext = "Get total value of all open trades in USD."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, revolut, tx, notify):
total = tx.get_open_trades_usd()
msg(f"Total trades: {total}USD")
class dollar(object):
name = "$"
authed = True
helptext = "Get total value of everything, including open trades."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, revolut, tx, notify):
total = tx.get_total_with_trades()
msg(f"${total}")

View File

@ -524,3 +524,10 @@ class Transactions(object):
withdraw_threshold = float(settings.Money.BaseUSD) + float(settings.Money.WithdrawLimit)
remaining = withdraw_threshold - total_usd
return remaining
def get_total_with_trades(self):
total_usd = self.get_total_usd()
if not total_usd:
return False
total_trades_usd = self.get_open_trades_usd()
return total_usd + total_trades_usd