Move performance-calculation to persistence

This commit is contained in:
Matthias
2019-10-29 11:09:41 +01:00
parent 669a6cf119
commit f20f5cebbe
3 changed files with 45 additions and 15 deletions

View File

@@ -442,18 +442,7 @@ class RPC:
Handler for performance.
Shows a performance statistic from finished trades
"""
pair_rates = Trade.session.query(Trade.pair,
sql.func.sum(Trade.close_profit).label('profit_sum'),
sql.func.count(Trade.pair).label('count')) \
.filter(Trade.is_open.is_(False)) \
.group_by(Trade.pair) \
.order_by(sql.text('profit_sum DESC')) \
.all()
return [
{'pair': pair, 'profit': round(rate * 100, 2), 'count': count}
for pair, rate, count in pair_rates
]
return Trade.get_overall_performance()
def _rpc_count(self) -> Dict[str, float]:
""" Returns the number of trades running """