extend status bot command to query specific trades
This commit is contained in:
parent
572f5f9186
commit
6d40814dbf
@ -144,13 +144,17 @@ class RPC:
|
|||||||
}
|
}
|
||||||
return val
|
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
|
Below follows the RPC backend it is prefixed with rpc_ to raise awareness that it is
|
||||||
a remotely exposed function
|
a remotely exposed function
|
||||||
"""
|
"""
|
||||||
# Fetch open trade
|
# Fetch open trades
|
||||||
trades = Trade.get_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:
|
if not trades:
|
||||||
raise RPCException('no active trade')
|
raise RPCException('no active trade')
|
||||||
else:
|
else:
|
||||||
|
@ -277,7 +277,13 @@ class Telegram(RPCHandler):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
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 = []
|
messages = []
|
||||||
for r in results:
|
for r in results:
|
||||||
|
Loading…
Reference in New Issue
Block a user