feat: support /profit long, too
This commit is contained in:
@@ -191,8 +191,8 @@ class Telegram(RPCHandler):
|
|||||||
r"/mix_tags",
|
r"/mix_tags",
|
||||||
r"/daily$",
|
r"/daily$",
|
||||||
r"/daily \d+$",
|
r"/daily \d+$",
|
||||||
r"/profit$",
|
r"/profit([_ ]long|[_ ]short)?$",
|
||||||
r"/profit \d+",
|
r"/profit([_ ]long|[_ ]short)? \d+$",
|
||||||
r"/stats$",
|
r"/stats$",
|
||||||
r"/count$",
|
r"/count$",
|
||||||
r"/locks$",
|
r"/locks$",
|
||||||
@@ -1126,6 +1126,11 @@ class Telegram(RPCHandler):
|
|||||||
timescale = None
|
timescale = None
|
||||||
try:
|
try:
|
||||||
if context.args:
|
if context.args:
|
||||||
|
if not direction:
|
||||||
|
arg = context.args[0].lower()
|
||||||
|
if arg in ("short", "long"):
|
||||||
|
direction = arg
|
||||||
|
context.args.pop(0) # Remove direction from args
|
||||||
timescale = int(context.args[0]) - 1
|
timescale = int(context.args[0]) - 1
|
||||||
today_start = datetime.combine(date.today(), datetime.min.time())
|
today_start = datetime.combine(date.today(), datetime.min.time())
|
||||||
start_date = today_start - timedelta(days=timescale)
|
start_date = today_start - timedelta(days=timescale)
|
||||||
|
|||||||
@@ -3006,11 +3006,28 @@ async def test_telegram_profit_long_short_handle(
|
|||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
assert "No long trades yet." in msg_mock.call_args_list[0][0][0]
|
assert "No long trades yet." in msg_mock.call_args_list[0][0][0]
|
||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
|
|
||||||
|
# Test support with "/profit long"
|
||||||
|
context = MagicMock()
|
||||||
|
context.args = ["long"]
|
||||||
|
await telegram._profit(update=update, context=context)
|
||||||
|
assert msg_mock.call_count == 1
|
||||||
|
assert "No long trades yet." in msg_mock.call_args_list[0][0][0]
|
||||||
|
msg_mock.reset_mock()
|
||||||
|
|
||||||
await telegram._profit_short(update=update, context=MagicMock())
|
await telegram._profit_short(update=update, context=MagicMock())
|
||||||
assert msg_mock.call_count == 1
|
assert msg_mock.call_count == 1
|
||||||
assert "No short trades yet." in msg_mock.call_args_list[0][0][0]
|
assert "No short trades yet." in msg_mock.call_args_list[0][0][0]
|
||||||
msg_mock.reset_mock()
|
msg_mock.reset_mock()
|
||||||
|
|
||||||
|
# Test support with "/profit short"
|
||||||
|
context = MagicMock()
|
||||||
|
context.args = ["short"]
|
||||||
|
await telegram._profit(update=update, context=context)
|
||||||
|
assert msg_mock.call_count == 1
|
||||||
|
assert "No short trades yet." in msg_mock.call_args_list[0][0][0]
|
||||||
|
msg_mock.reset_mock()
|
||||||
|
|
||||||
# When there are trades
|
# When there are trades
|
||||||
create_mock_trades_usdt(fee)
|
create_mock_trades_usdt(fee)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user