Skip to content

nssanta/crypto-macd-bot

Repository files navigation

Crypto Trading Bot (MACD Strategy)

Python 3.10+ License: MIT

A comprehensive cryptocurrency trading bot implementing the MACD strategy with support for multiple exchanges (OKX, Bybit, MEXC). It features a Telegram bot interface for control and monitoring, and can receive signals via WebHooks or Email.

Русская версия | English


🚀 Features

  • Multi-Exchange Support: OKX, Bybit, MEXC.

  • Trading Strategy: MACD (Moving Average Convergence Divergence).

  • Signal Sources:

    • WebHooks: Receive trading signals via HTTP POST requests.
    • Email: Parse trading signals from TradingView email alerts.
  • Telegram Bot Interface:

    • Start/Stop bot.
    • Monitor open positions and PNL.
    • Manual trade execution (Long/Short).
    • Configuration management (Leverage, Stop-Loss, Take-Profit, etc.).

    Main Menu Settings

  • Risk Management:

    • Stop-Loss & Take-Profit.
    • Trailing Stop (Move-Loss).
    • Averaging (DCA) support.
  • Backtesting: Includes a module for backtesting the strategy on historical data.


🛠️ Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/crypto-trading-bot.git
    cd crypto-trading-bot
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configuration:

    • Copy .env.example to .env:
      cp .env.example .env
    • Fill in the .env file with your API keys and settings:
      • TELEGRAM_BOT_TOKEN: Your Telegram Bot Token.
      • BOT_PASSWORD: Password to access the bot.
      • ALLOWED_USERS: Comma-separated list of Telegram User IDs allowed to use the bot.
      • OKX_API_KEY, OKX_SECRET_KEY, OKX_PASSPHRASE: Your OKX API credentials.
      • (Optional) Bybit and MEXC keys if using those exchanges.
      • (Optional) Email settings if using Email signals.

▶️ Usage

Running the Bot

To start the main Telegram bot with WebHook support:

python main.py

To start the bot with Email signal processing:

python main_email.py

Telegram Bot Commands

  • /start: Start the bot and show the main menu.
  • /passauth: Authenticate using the password from .env.
  • /help: Get help or reset UI.

WebHook Setup (TradingView)

Configure your TradingView alert to send a POST request to your server's IP/domain:

  • URL: http://your-server-ip:80/signal
  • Body:
    {
      "signal": "Buy",
      "MACD": {{plot("MACD")}},
      "Signal": {{plot("Signal Line")}}
    }

📂 Project Structure

  • main.py: Entry point for the WebHook-based bot.
  • main_email.py: Entry point for the Email-based bot.
  • Engine/: Core trading logic (WebHook.py, EmailOkx.py).
  • Exchange/: Exchange API wrappers (Okx.py, Bybit.py, Mexc.py).
  • TelBot/: Telegram bot handlers and UI.
  • TehnicalIndicator/: Technical analysis indicators (MACD, EMA, SMA).
  • BackTest/: Backtesting modules.

⚠️ Disclaimer

This software is for educational purposes only. Do not risk money which you are afraid to lose. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.


📄 License

MIT License

About

Automated crypto trading bot (MACD) for OKX, Bybit, and MEXC with Telegram control

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages