|
|
|
|
@ -12,6 +12,7 @@ from unittest.mock import ANY, MagicMock
|
|
|
|
|
|
|
|
|
|
import arrow
|
|
|
|
|
import pytest
|
|
|
|
|
import time_machine
|
|
|
|
|
from pandas import DataFrame
|
|
|
|
|
from telegram import Chat, Message, ReplyKeyboardMarkup, Update
|
|
|
|
|
from telegram.error import BadRequest, NetworkError, TelegramError
|
|
|
|
|
@ -2065,41 +2066,42 @@ def test_send_msg_sell_fill_notification(default_conf, mocker, direction,
|
|
|
|
|
default_conf['telegram']['notification_settings']['exit_fill'] = 'on'
|
|
|
|
|
telegram, _, msg_mock = get_telegram_testobject(mocker, default_conf)
|
|
|
|
|
|
|
|
|
|
telegram.send_msg({
|
|
|
|
|
'type': RPCMessageType.EXIT_FILL,
|
|
|
|
|
'trade_id': 1,
|
|
|
|
|
'exchange': 'Binance',
|
|
|
|
|
'pair': 'KEY/ETH',
|
|
|
|
|
'leverage': leverage,
|
|
|
|
|
'direction': direction,
|
|
|
|
|
'gain': 'loss',
|
|
|
|
|
'limit': 3.201e-05,
|
|
|
|
|
'amount': 1333.3333333333335,
|
|
|
|
|
'order_type': 'market',
|
|
|
|
|
'open_rate': 7.5e-05,
|
|
|
|
|
'close_rate': 3.201e-05,
|
|
|
|
|
'profit_amount': -0.05746268,
|
|
|
|
|
'profit_ratio': -0.57405275,
|
|
|
|
|
'stake_currency': 'ETH',
|
|
|
|
|
'enter_tag': enter_signal,
|
|
|
|
|
'exit_reason': ExitType.STOP_LOSS.value,
|
|
|
|
|
'open_date': arrow.utcnow().shift(days=-1, hours=-2, minutes=-30),
|
|
|
|
|
'close_date': arrow.utcnow(),
|
|
|
|
|
})
|
|
|
|
|
with time_machine.travel("2022-09-01 05:00:00 +00:00", tick=False) as t:
|
|
|
|
|
telegram.send_msg({
|
|
|
|
|
'type': RPCMessageType.EXIT_FILL,
|
|
|
|
|
'trade_id': 1,
|
|
|
|
|
'exchange': 'Binance',
|
|
|
|
|
'pair': 'KEY/ETH',
|
|
|
|
|
'leverage': leverage,
|
|
|
|
|
'direction': direction,
|
|
|
|
|
'gain': 'loss',
|
|
|
|
|
'limit': 3.201e-05,
|
|
|
|
|
'amount': 1333.3333333333335,
|
|
|
|
|
'order_type': 'market',
|
|
|
|
|
'open_rate': 7.5e-05,
|
|
|
|
|
'close_rate': 3.201e-05,
|
|
|
|
|
'profit_amount': -0.05746268,
|
|
|
|
|
'profit_ratio': -0.57405275,
|
|
|
|
|
'stake_currency': 'ETH',
|
|
|
|
|
'enter_tag': enter_signal,
|
|
|
|
|
'exit_reason': ExitType.STOP_LOSS.value,
|
|
|
|
|
'open_date': arrow.utcnow().shift(days=-1, hours=-2, minutes=-30),
|
|
|
|
|
'close_date': arrow.utcnow(),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
leverage_text = f'*Leverage:* `{leverage}`\n' if leverage and leverage != 1.0 else ''
|
|
|
|
|
assert msg_mock.call_args[0][0] == (
|
|
|
|
|
'\N{WARNING SIGN} *Binance (dry):* Exited KEY/ETH (#1)\n'
|
|
|
|
|
'*Profit:* `-57.41% (loss: -0.05746268 ETH)`\n'
|
|
|
|
|
f'*Enter Tag:* `{enter_signal}`\n'
|
|
|
|
|
'*Exit Reason:* `stop_loss`\n'
|
|
|
|
|
f"*Direction:* `{direction}`\n"
|
|
|
|
|
f"{leverage_text}"
|
|
|
|
|
'*Amount:* `1333.33333333`\n'
|
|
|
|
|
'*Open Rate:* `0.00007500`\n'
|
|
|
|
|
'*Exit Rate:* `0.00003201`\n'
|
|
|
|
|
'*Duration:* `1 day, 2:30:00 (1590.0 min)`'
|
|
|
|
|
)
|
|
|
|
|
leverage_text = f'*Leverage:* `{leverage}`\n' if leverage and leverage != 1.0 else ''
|
|
|
|
|
assert msg_mock.call_args[0][0] == (
|
|
|
|
|
'\N{WARNING SIGN} *Binance (dry):* Exited KEY/ETH (#1)\n'
|
|
|
|
|
'*Profit:* `-57.41% (loss: -0.05746268 ETH)`\n'
|
|
|
|
|
f'*Enter Tag:* `{enter_signal}`\n'
|
|
|
|
|
'*Exit Reason:* `stop_loss`\n'
|
|
|
|
|
f"*Direction:* `{direction}`\n"
|
|
|
|
|
f"{leverage_text}"
|
|
|
|
|
'*Amount:* `1333.33333333`\n'
|
|
|
|
|
'*Open Rate:* `0.00007500`\n'
|
|
|
|
|
'*Exit Rate:* `0.00003201`\n'
|
|
|
|
|
'*Duration:* `1 day, 2:30:00 (1590.0 min)`'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_send_msg_status_notification(default_conf, mocker) -> None:
|
|
|
|
|
|