setup_telegram_logging#

API documentation for tradeexecutor.cli.log.setup_telegram_logging Python function.

setup_telegram_logging(telegram_api_key, telegram_chat_id)[source]#

Setup Telegram logger.

Set up a Python logging handler based on telegram_bot_logger to send trade output to a Telegram group chat.

Manual testing instructions.

Invite the bot to a group chat. Then send a message /start @botname to the bot in the group chat to activate it.

Then get chat id with:

curl https://api.telegram.org/bot$TELEGRAM_API_KEY/getUpdates | jq

Test with:

pytest --log-cli-level=info -k test_telegram_logging
Parameters:
  • telegram_api_key (str) –

  • telegram_chat_id (str) –

Return type:

telegram_bot_logger.TelegramMessageHandler