Move get_profit to money
This commit is contained in:
parent
6de9c4d564
commit
c17e311f7e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue