Add commands to check only profit
This commit is contained in:
parent
9a50865480
commit
b88f49b6ae
|
@ -465,3 +465,23 @@ class IRCCommands(object):
|
|||
def run(cmd, spl, length, authed, msg, agora, revolut, tx, notify):
|
||||
total = tx.get_total_with_trades()
|
||||
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")
|
||||
|
|
|
@ -485,6 +485,23 @@ class Transactions(object):
|
|||
|
||||
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):
|
||||
"""
|
||||
Get total value of open trades in USD.
|
||||
|
|
Loading…
Reference in New Issue