diff --git a/docs/strategy-customization.md b/docs/strategy-customization.md index 71d6f3e8f..b3b6e3548 100644 --- a/docs/strategy-customization.md +++ b/docs/strategy-customization.md @@ -415,7 +415,7 @@ At the top of the file, import Trade. from freqtrade.persistence import Trade ``` -The following example queries for the current pair and trades from today, however other filters easily be added. +The following example queries for the current pair and trades from today, however other filters can easily be added. ``` python if self.config['runmode'] in ('live', 'dry_run'): @@ -442,10 +442,10 @@ if self.config['runmode'] in ('live', 'dry_run'): performance = Trade.get_overall_performance() ``` -Sample return value: ETH/BTC had 5 trades, with a total profit of 1.5%. +Sample return value: ETH/BTC had 5 trades, with a total profit of 1.5% (ratio of 0.015). ``` json -{'pair': "ETH/BTC", 'profit': 1.5, 'count': 5} +{'pair': "ETH/BTC", 'profit': 0.015, 'count': 5} ``` !!! Warning diff --git a/freqtrade/persistence.py b/freqtrade/persistence.py index 27a283378..735c740c3 100644 --- a/freqtrade/persistence.py +++ b/freqtrade/persistence.py @@ -437,7 +437,7 @@ class Trade(_DECL_BASE): return total_open_stake_amount or 0 @staticmethod - def get_overall_performance() -> List[Dict]: + def get_overall_performance() -> List[Dict[str, Any]]: """ Returns List of dicts containing all Trades, including profit and trade count """ @@ -452,7 +452,7 @@ class Trade(_DECL_BASE): return [ { 'pair': pair, - 'profit': round(rate * 100, 2), + 'profit': rate, 'count': count } for pair, rate, count in pair_rates diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 8eecb04f9..4aed48f74 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -428,12 +428,15 @@ class RPC: else: return None - def _rpc_performance(self) -> List[Dict]: + def _rpc_performance(self) -> List[Dict[str, Any]]: """ Handler for performance. Shows a performance statistic from finished trades """ - return Trade.get_overall_performance() + pair_rates = Trade.get_overall_performance() + # Round and convert to % + [x.update({'profit': round(x['profit'] * 100, 2)}) for x in pair_rates] + return pair_rates def _rpc_count(self) -> Dict[str, float]: """ Returns the number of trades running """