Libraries refactor and add some sinks #4

Closed
m wants to merge 136 commits from library-refactor into master
2 changed files with 37 additions and 0 deletions
Showing only changes of commit 6eff2b76e7 - Show all commits

View File

@ -465,3 +465,23 @@ class IRCCommands(object):
def run(cmd, spl, length, authed, msg, agora, revolut, tx, notify): def run(cmd, spl, length, authed, msg, agora, revolut, tx, notify):
total = tx.get_total_with_trades() total = tx.get_total_with_trades()
msg(f"${total}") msg(f"${total}")
class profit(object):
name = "profit"
authed = True
helptext = "Get total profit."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, revolut, tx, notify):
total = tx.get_profit()
msg(f"Profit: {total}USD")
class tprofit(object):
name = "tprofit"
authed = True
helptext = "Get total profit with open trades."
@staticmethod
def run(cmd, spl, length, authed, msg, agora, revolut, tx, notify):
total = tx.get_profit(True)
msg(f"Profit: {total}USD")

View File

@ -485,6 +485,23 @@ class Transactions(object):
return remaining return remaining
# TODO: move to money
def get_profit(self, trades=False):
"""
Check how much total profit we have made.
:return: profit in USD
:rtype: float
"""
total_usd = self.get_total_usd()
if not total_usd:
return False
if trades:
trades_usd = self.get_open_trades_usd()
total_usd += trades_usd
profit = total_usd - float(settings.Money.BaseUSD)
return profit
def get_open_trades_usd(self): def get_open_trades_usd(self):
""" """
Get total value of open trades in USD. Get total value of open trades in USD.