Libraries refactor and add some sinks #4
|
@ -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