A Python-based Binance trading bot that executes trades based on signals from a Telegram channel. It includes a comprehensive Telegram admin panel for real-time control and configuration.
- Telegram Signal Listener: Uses Telethon to monitor a specific chat for new trade signals.
- Advanced Message Parsing: A flexible regex-based parser to extract trade details from messages.
- Binance Integration: Connects to Binance (Testnet by default) to execute future trades.
- Configurable Risk Management: Automatically calculates trade sizes based on account balance or a fixed investment amount.
- Dynamic Admin Panel: An interactive Telegram admin panel to:
- Toggle auto-investment.
- Switch between REST (safe) and WebSocket (fast) order modes.
- Adjust leverage, cooldown periods, and other settings on the fly.
- View account balance.
- Safety First:
- Runs on Testnet by default.
- Securely stores API keys using a
.envfile. - Includes a cooldown timer to prevent trade spam.
shipitdev-tradebot/
├── .env.example # Example environment file for secrets
├── config.json # Main configuration for the bot
├── requirements.txt # Project dependencies
├── src/ # Source code
│ ├── main.py # Main application entry point
│ ├── binance_handler.py # Handles all Binance API interactions
│ ├── telegram_handler.py # Manages Telegram listening and admin panel
│ ├── risk_management.py# Calculates trade size and risk
│ └── message_parser.py # Parses trade signals from messages
└── tests/ # Unit tests
└── ...
1. Prerequisites
- Python 3.8+
- A Telegram account
- A Binance account (Testnet is recommended for setup)
2. Clone the Repository
If you haven't already, get the code on your local machine.
git clone <repository-url>
cd shipitdev-tradebot3. Set up a Virtual Environment
It is highly recommended to use a virtual environment to manage dependencies.
python3 -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`4. Install Dependencies
pip install -r requirements.txt5. Configure Environment Secrets
- Rename
.env.exampleto.env. - Open the
.envfile and fill in your credentials:BINANCE_API_KEYandBINANCE_API_SECRET: Get these from your Binance account.TELEGRAM_BOT_TOKEN: Get this from Telegram's "BotFather".TELEGRAM_API_IDandTELEGRAM_API_HASH: Get these from my.telegram.org under "API development tools".
6. Configure the Bot
- Open
config.json. - Set
telegram_chat_idto the ID of the Telegram channel/group you want to listen to. You can get this ID from a bot like@userinfobot. - Adjust other settings like
leverage,investment, etc., as needed.
Once everything is configured, start the bot with the following command:
python3 -m src.mainThe bot will connect to Binance and start listening for messages on Telegram.
- Trade Execution: The bot will automatically listen for and process new messages in the target chat that match the signal format.
- Admin Panel:
- Open a private chat with your bot on Telegram.
- Use the
/startcommand to get a welcome message. - Use the
/admincommand to open the interactive control panel. - Use the buttons to monitor and control the bot in real-time.