rpc refactor 8/
This commit is contained in:
@@ -380,6 +380,7 @@ def rpc_stop():
|
||||
return (True, '*Status:* `already stopped`')
|
||||
|
||||
|
||||
# FIX: no test for this!!!!
|
||||
def rpc_forcesell(trade_id) -> None:
|
||||
"""
|
||||
Handler for forcesell <id>.
|
||||
@@ -405,3 +406,25 @@ def rpc_forcesell(trade_id) -> None:
|
||||
return (True, 'Invalid argument. See `/help` to view usage')
|
||||
|
||||
_exec_forcesell(trade)
|
||||
|
||||
|
||||
def rpc_performance() -> None:
|
||||
"""
|
||||
Handler for performance.
|
||||
Shows a performance statistic from finished trades
|
||||
"""
|
||||
if get_state() != State.RUNNING:
|
||||
return (True, '`trader is not running`')
|
||||
|
||||
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()
|
||||
trades = []
|
||||
for (pair, rate, count) in pair_rates:
|
||||
trades.append({'pair': pair, 'profit': round(rate * 100, 2), 'count': count})
|
||||
|
||||
return (False, trades)
|
||||
|
||||
Reference in New Issue
Block a user