Libraries refactor and add some sinks #4

Closed
m wants to merge 136 commits from library-refactor into master
1 changed files with 27 additions and 0 deletions
Showing only changes of commit 8f3faaab6d - Show all commits

View File

@ -78,3 +78,30 @@ class Money(object):
else: else:
rates = self.get_rates_all() rates = self.get_rates_all()
return float(amount) / rates[currency] 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