Move get_profit to money

This commit is contained in:
Mark Veidemanis 2022-02-24 22:28:00 +00:00
parent 3d3e9b0279
commit 8f3faaab6d
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 27 additions and 0 deletions

View File

@ -78,3 +78,30 @@ class Money(object):
else:
rates = self.get_rates_all()
return float(amount) / rates[currency]
# 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.tx.get_total_usd()
if not total_usd:
return False
if trades:
trades_usd = self.tx.get_open_trades_usd()
total_usd += trades_usd
profit = total_usd - float(settings.Money.BaseUSD)
if trades:
cast_es = {
"profit_trades_usd": profit,
}
else:
cast_es = {
"profit_usd": profit,
}
self.tx.write_to_es("get_profit", cast_es)
return profit