How to Transform a Telegram Bot into an Effective Trading Dashboard

SmartLever
5 min readMar 29, 2023

--

The countries with the highest robot density have among the lowest unemployment rates. “Technology and humans combined in the right way will drive prosperity.” Ulrich Spiesshofer

How do you do it?

Real-time tracking of trade positions, account balances, and service availability is essential. Here is a simple and free solution: a telegram-dashboard-bot.

This article will teach you how to use Python and Telegram as a second set of “eyes” for your trading and build a reliable real-time service available around the clock to keep tabs and offer analysis. A trading platform would be incomplete without a dashboard where account balances and open trades can be tracked and the health of the platform’s core features can be viewed. In addition, you can configure alerts to be sent to you personally whenever there are discrepancies between your virtual and actual positions or whenever a service goes down.

Telegram is like WhatsApp but with anfetamina

Telegram is a messaging app with many useful features beyond the standard conversation, and the greatest thing is that it includes a Python-accessible API to use.

Smartbots uses a Telegram-dashboard-bot to keep track of everything, as I explain in this post: Backtesting is only one important component of a trading platform; there are other important components, and having a dashboard is one of them.

The Setup

  1. Install Docker and Docker Compose. To start, make sure you have Docker and Docker Compose installed on your system by following the instructions from the official documentation:

2. Create a Telegram bot and obtain the token. Steps:

  • Open the Telegram app and search for the “BotFather”.
  • Start a conversation and send the command “/newbot”.
  • Follow the instructions to create your bot and obtain the token.

3. Clone the project.

4. Navigate into the project’s folder.

cd SmartBots/docker

5. Prerequisites: SmartBots running:

  • Basktesting. Here's a post.
  • Virtual o real trading: If the results of your backtesting are satisfactory, you can begin trading in real or virtual. This requires all services on the SmartBots platform to be active, such as “Data Feed Provider” “Broker,” and “Portfolio,” which the Telegram bot will keep tabs on. Below is an example for the Kukoin cryptocurrency exchange, but you can modify it to suit your own purposes. Modify docker/compose.env file:
  • Get the Broker service going so that trade orders can be taken:
docker compose -f docker-compose_crypto.yml --env-file ./compose.env up - broker_crypto1
  • Launch the Data Feed Provider; this service creates the “events” that feed Portfolio:
docker compose -f docker-compose_crypto.yml --env-file ./compose.env up -d data_provider1
  • Launch the Portfolio, which is where the strategy logic lives and is fed by Data Feed Provider. Investment signals will be generated and transmitted to the Broker:
docker compose -f docker-compose_crypto.yml --env-file ./compose.env up -d bot_crypto_trading1

These three services keep records of their operations in a database.

6. Set the dashboard configuration.

To integrate the Telegram bot into the SmartBots platform, add the token obtained in the configuration file (docker/compose.env), and also add a series of additional parameters in this configuration:

  • TOKEN_TELEGRAM_CRYPTO (obtained in step 2)
  • LIST_SERVICES_CRYPTO. List of services to monitor.
  • LIST_OF_ADMINS_CRYPTO : You can add as many users as you wish, but at least your Telegram ID should be included.
  • CRYPTO_SYMBOLS. List of symbols to be traded.
  • INITIAL_BALANCE_CRYPTO. Initial broker balance for calculating ratios.
  • BROKER_CRYPTO, the name of the exchange with which we are operating.

Back-end services:

Launch it:

docker compose -f docker-compose_crypto.yml --env-file ./compose.env up -d telegram_crypto1

Let’s run it

Use and customize commands in the Telegram-bot.

The Python script for Telegram, located at src/application/bots/telegram_bot.py

There are basic commands that are predefined and ready to use. You can also edit or add new commands to meet your specific needs.

Predefined basic commands:

/status: Displays the health of Docker services.

/positions: Displays real and simulated positions.

/mi_id: Displays your Telegram ID.

/start: Starts the bot.

/balance: Displays the balance in the broker.

Customizable commands (recommendations):

/portfolio: provides an overview of your portfolio.

/historical_data: retrieves historical price data.

/performance: analyzes the performance of your investments.

To add or change commands, change the telegram_bot.py script in SmartBots by following the existing code's rules and structure.

Happy trading! 24/7 information:

Main Takeaways

A trading platform’s dashboard is an essential component. We require “eyes” to monitor what is happening with the trading.

Telegram is a powerful tool for staying informed on your phone at all times. It also has a solid API, and the privacy and security aspects make it an excellent pick.

You don’t have to reinvent the wheel because SmartBots is a platform that completes the trading cycle for you.

Subscribe to all our news here.

The train is in the station, and you can’t miss it, so join us on this journey. We are an open community and if you want to collaborate with us, please send us an email: andres@smartlever.tech

--

--