Sending Screener Notifications On Telegram With Python

Easily send signals over to telegram on a schedule

Georgi Samardzhiev
Quant Factory
3 min readSep 12, 2022

--

Photo by Lewis Kang'ethe Ngugi on Unsplash

In our current times staying on top of the latest signals can be challenging. Especially if the screeners are not automated to provide the most up-to-date information on the latest signals. That’s why tying a screener to telegram can make one aware of a lot of opportunities. It can notify you when a new signal is found (and we all get the dopamine hit when a new notification arrives on our smartphones). You can also share this screener with people for fun (and of course profit).

To be able to follow along you

  • know you way around Python
  • have a Telegram account
  • have a screener, that outputs a string when it finds a new signal

Working with telegram

Although there are many excellent solutions to sending your signals over to telegram I prefer to use pyTelegramBotAPI - you just need a token and you are off to the races.

How to get your telegram token

In order to get your telegram token you need to go through a couple of steps:

  1. Open Telegram and find @botfarther
  2. [Optional] To see all available commands type /help
  3. To create a new bot just write /newbot
  4. Go through the prompts from botfather
  5. At the end it will give you your API key.

How to get your channel id

  1. Login with a browser version of telegram: https://web.telegram.org/
  2. Click on your channel.
  3. At the end of your current url after the # should be your channel id. It always starts with a minus.

Combining it with your screener

However do note that this bot is only sending messages to a telegram channel and does not respond to any messages, targeted at it. But for our use case, this is plenty.

Running the screener on a schedule

As shown above, to send a single message its quite simple. A way to automate it is to host that script and run it on a schedule using crontab - good article on it.

Another way to automate it, within python is to use a library to automate this process. I used schedule.

Something to take into an account is that you need to wrap all of your code into a single function. A simple refactor you could do is shown below.

Adding schedule

Let’s assume you want to send a message every hour, exactly at 00.

Easy enough.

Combining it all together

Conclusion

In this article I showcased how easy it is to send your screener notifications and signals over to telegram and run it on a schedule. That’s all there is to it.

If you have any questions, suggestions or thoughts, always feel free to share them with me! And if you like to see more how-tos on deploying your screeners and strategies, make sure to follow me and receive the most recent updates.

A Message from QuantFactory:

Thank you for being part of our community! Before you go:

  • Master Quantitative Research with Python👉 here.
  • Join our Premium Discord Server👉 here.
  • Subscribe to our Exclusive Stocks Newsletter 👉 here.
  • If you liked the story feel free to clap 👏 and follow the author
  • For more stories from the Algorithmic Trading and Quantitative Analysis world you should follow the Quant Factory Publication

*Note that this article does not provide personal investment advice and I am not a qualified licensed investment advisor. All information found here is for entertainment or educational purposes only and should not be construed as personal investment advice.

--

--