Skip to content

Repository files navigation

shipitdev-tradebot

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.

Features

  • 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 .env file.
    • Includes a cooldown timer to prevent trade spam.

Project Structure

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
    └── ...

Setup and Installation

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-tradebot

3. 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.txt

5. Configure Environment Secrets

  • Rename .env.example to .env.
  • Open the .env file and fill in your credentials:
    • BINANCE_API_KEY and BINANCE_API_SECRET: Get these from your Binance account.
    • TELEGRAM_BOT_TOKEN: Get this from Telegram's "BotFather".
    • TELEGRAM_API_ID and TELEGRAM_API_HASH: Get these from my.telegram.org under "API development tools".

6. Configure the Bot

  • Open config.json.
  • Set telegram_chat_id to 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.

How to Run the Bot

Once everything is configured, start the bot with the following command:

python3 -m src.main

The bot will connect to Binance and start listening for messages on Telegram.

Usage

  • 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 /start command to get a welcome message.
    • Use the /admin command to open the interactive control panel.
    • Use the buttons to monitor and control the bot in real-time.

About

Vibe coded a Binance futures bot at 3am because quant trading looked interesting. Reads Telegram signals, executes trades, has a full admin panel. Still works.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages