diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 1e304f01b..03108b0f4 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -144,13 +144,17 @@ class RPC: } return val - def _rpc_trade_status(self) -> List[Dict[str, Any]]: + def _rpc_trade_status(self, trade_ids=None) -> List[Dict[str, Any]]: """ Below follows the RPC backend it is prefixed with rpc_ to raise awareness that it is a remotely exposed function """ - # Fetch open trade - trades = Trade.get_open_trades() + # Fetch open trades + if trade_ids: + trades = Trade.get_trades(trade_filter=Trade.id.in_(trade_ids)) + else: + trades = Trade.get_open_trades() + if not trades: raise RPCException('no active trade') else: diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 7ec67e5d0..d304188c2 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -277,7 +277,13 @@ class Telegram(RPCHandler): return try: - results = self._rpc._rpc_trade_status() + + # Check if there's at least one numerical ID provided. If so, try to get only these trades. + trade_ids = None + if context.args and len(context.args) > 0: + trade_ids = [i for i in context.args if i.isnumeric()] + + results = self._rpc._rpc_trade_status(trade_ids=trade_ids) messages = [] for r in results: